about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-17 21:40:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-17 21:40:59 -0700
commitf3abc2cbf250be3de41d94fdfa1989e1e0683706 (patch)
treeaecd6bdfa3e2d459acbd100f6da9aab13ee30696
parentefbbdfc58645dbee12a36a1a2f4c22054b969acc (diff)
downloadtext.love-f3abc2cbf250be3de41d94fdfa1989e1e0683706.tar.gz
better handle moving points
This should hopefully address #5. I'm removing some constraints from
manhattan lines, rectangles and squares.
-rw-r--r--README.md15
-rw-r--r--drawing.lua5
2 files changed, 5 insertions, 15 deletions
diff --git a/README.md b/README.md
index d72ed73..8a29a90 100644
--- a/README.md
+++ b/README.md
@@ -91,21 +91,6 @@ found anything amiss: http://akkartik.name/contact
 * No clipping yet for drawings. In particular, circles/squares/rectangles and
   point labels can overflow a drawing.
 
-* Insufficient handling of constraints when moving points. For example, if you
-  draw a manhattan line and then move one of the points, you may not be able
-  to hover on it anymore.
-
-  There's two broad ways to fix this. The first is to relax constraints,
-  switch the manhattan line to not be manhattan. The second is to try to
-  maintain constraints. Either constrain the point to only move along one line
-  (but what if it's connected to two manhattan lines?!), or constrain the
-  other end of the line to move alongside. I'm not sure yet which would be
-  more useful. Getting into constraints would also make the program more
-  complex.
-
-  Bottomline: at the moment moving points connected to manhattan lines,
-  rectangles or squares can break drawings in subtle ways.
-
 * Touchpads can drag the mouse pointer using a light touch or a heavy click.
   On Linux, drags using the light touch get interrupted when a key is pressed.
   You'll have to press down to drag.
diff --git a/drawing.lua b/drawing.lua
index 9bf06c7..624fad7 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -248,6 +248,11 @@ function Drawing.update()
   elseif Current_drawing_mode == 'move' then
     if Drawing.in_drawing(drawing, x, y) then
       local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y)
+      if drawing.mode == 'manhattan' then
+        drawing.mode = 'line'
+      elseif drawing.mode == 'rectangle' or drawing.mode == 'square' then
+        drawing.mode = 'polygon'
+      end
       drawing.pending.target_point.x = mx
       drawing.pending.target_point.y = my
     end