about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-25 17:07:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-25 17:07:19 -0700
commitbce43b56b0e26cbee9b7c544071b1e23d3f69df6 (patch)
tree2df2816792ce0604c62475737227713fd3ee9d2b
parentf49e2fd104ed8aa8959ba3ae969551fda4251c1a (diff)
downloadtext.love-bce43b56b0e26cbee9b7c544071b1e23d3f69df6.tar.gz
few more transitions between shapes
-rw-r--r--drawing.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/drawing.lua b/drawing.lua
index cab5dea..5575904 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -388,6 +388,8 @@ function Drawing.keychord_pressed(chord)
       end
     elseif drawing.pending.mode == 'circle' or drawing.pending.mode == 'arc' then
       drawing.pending.vertices = {drawing.pending.center}
+    elseif drawing.pending.mode == 'polygon' or drawing.pending.mode == 'square' then
+      -- reuse existing (1-2) vertices
     end
     drawing.pending.mode = 'rectangle'
   elseif chord == 'C-s' and not love.mouse.isDown('1') then
@@ -403,6 +405,12 @@ function Drawing.keychord_pressed(chord)
       end
     elseif drawing.pending.mode == 'circle' or drawing.pending.mode == 'arc' then
       drawing.pending.vertices = {drawing.pending.center}
+    elseif drawing.pending.mode == 'rectangle' then
+      -- reuse existing (1-2) vertices
+    elseif drawing.pending.mode == 'polygon' then
+      while #drawing.pending.vertices > 2 do
+        table.remove(drawing.pending.vertices)
+      end
     end
     drawing.pending.mode = 'square'
   elseif love.mouse.isDown('1') and chord == 'p' and (Current_drawing_mode == 'polygon' or Current_drawing_mode == 'rectangle' or Current_drawing_mode == 'square') then
@@ -427,7 +435,7 @@ function Drawing.keychord_pressed(chord)
       drawing.pending.center = Drawing.insert_point(drawing.points, drawing.pending.points[1].x, drawing.pending.points[1].y)
     elseif drawing.pending.mode == 'line' or drawing.pending.mode == 'manhattan' then
       drawing.pending.center = drawing.pending.p1
-    elseif drawing.pending.mode == 'polygon' then
+    elseif drawing.pending.mode == 'polygon' or drawing.pending.mode == 'rectangle' or drawing.pending.mode == 'square' then
       drawing.pending.center = drawing.pending.vertices[1]
     end
     drawing.pending.mode = 'circle'
@@ -455,7 +463,7 @@ function Drawing.keychord_pressed(chord)
       drawing.pending.p1 = Drawing.insert_point(drawing.points, drawing.pending.points[1].x, drawing.pending.points[1].y)
     elseif drawing.pending.mode == 'line' then
       -- do nothing
-    elseif drawing.pending.mode == 'polygon' then
+    elseif drawing.pending.mode == 'polygon' or drawing.pending.mode == 'rectangle' or drawing.pending.mode == 'square' then
       drawing.pending.p1 = drawing.pending.vertices[1]
     elseif drawing.pending.mode == 'circle' or drawing.pending.mode == 'arc' then
       drawing.pending.p1 = drawing.pending.center