about summary refs log tree commit diff stats
path: root/file.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-21 14:03:06 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-21 14:03:06 -0700
commitbb9e23a6385675fa073ec187ba84d3fd8636dfc2 (patch)
tree957d2a6072f4a634e2877ed216a67ffd9a6c522e /file.lua
parent96df1874883e9d9700be394df6bcafdf9e3ad4b7 (diff)
downloadlines.love-bb9e23a6385675fa073ec187ba84d3fd8636dfc2.tar.gz
support for naming points
There's still an absence of affordance showing when you're in naming mode.
Diffstat (limited to 'file.lua')
-rw-r--r--file.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/file.lua b/file.lua
index 932d2c2..1087f55 100644
--- a/file.lua
+++ b/file.lua
@@ -48,15 +48,25 @@ function load_drawing(infile_next_line)
     assert(line)
     if line == '```' then break end
     local shape = json.decode(line)
-    if shape.mode == 'line' or shape.mode == 'manhattan' then
+    if shape.mode == 'freehand' then
+      -- no changes needed
+    elseif shape.mode == 'line' or shape.mode == 'manhattan' then
+      local name = shape.p1.name
       shape.p1 = Drawing.insert_point(drawing.points, shape.p1.x, shape.p1.y)
+      drawing.points[shape.p1].name = name
+      name = shape.p2.name
       shape.p2 = Drawing.insert_point(drawing.points, shape.p2.x, shape.p2.y)
+      drawing.points[shape.p2].name = name
     elseif shape.mode == 'polygon' or shape.mode == 'rectangle' or shape.mode == 'square' then
       for i,p in ipairs(shape.vertices) do
+        local name = p.name
         shape.vertices[i] = Drawing.insert_point(drawing.points, p.x,p.y)
+        drawing.points[shape.vertices[i]].name = name
       end
     elseif shape.mode == 'circle' or shape.mode == 'arc' then
+      local name = shape.center.name
       shape.center = Drawing.insert_point(drawing.points, shape.center.x,shape.center.y)
+      drawing.point[shape.center].name = name
     else
       print(shape.mode)
       assert(false)