about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--file.lua10
-rw-r--r--manual_tests3
2 files changed, 11 insertions, 2 deletions
diff --git a/file.lua b/file.lua
index c305869..932d2c2 100644
--- a/file.lua
+++ b/file.lua
@@ -51,12 +51,15 @@ function load_drawing(infile_next_line)
     if shape.mode == 'line' or shape.mode == 'manhattan' then
       shape.p1 = Drawing.insert_point(drawing.points, shape.p1.x, shape.p1.y)
       shape.p2 = Drawing.insert_point(drawing.points, shape.p2.x, shape.p2.y)
-    elseif shape.mode == 'polygon' then
+    elseif shape.mode == 'polygon' or shape.mode == 'rectangle' or shape.mode == 'square' then
       for i,p in ipairs(shape.vertices) do
         shape.vertices[i] = Drawing.insert_point(drawing.points, p.x,p.y)
       end
     elseif shape.mode == 'circle' or shape.mode == 'arc' then
       shape.center = Drawing.insert_point(drawing.points, shape.center.x,shape.center.y)
+    else
+      print(shape.mode)
+      assert(false)
     end
     table.insert(drawing.shapes, shape)
   end
@@ -71,7 +74,7 @@ function store_drawing(outfile, drawing)
     elseif shape.mode == 'line' or shape.mode == 'manhattan' then
       local line = json.encode({mode=shape.mode, p1=drawing.points[shape.p1], p2=drawing.points[shape.p2]})
       outfile:write(line..'\n')
-    elseif shape.mode == 'polygon' then
+    elseif shape.mode == 'polygon' or shape.mode == 'rectangle' or shape.mode == 'square' then
       local obj = {mode=shape.mode, vertices={}}
       for _,p in ipairs(shape.vertices) do
         table.insert(obj.vertices, drawing.points[p])
@@ -82,6 +85,9 @@ function store_drawing(outfile, drawing)
       outfile:write(json.encode({mode=shape.mode, center=drawing.points[shape.center], radius=shape.radius})..'\n')
     elseif shape.mode == 'arc' then
       outfile:write(json.encode({mode=shape.mode, center=drawing.points[shape.center], radius=shape.radius, start_angle=shape.start_angle, end_angle=shape.end_angle})..'\n')
+    else
+      print(shape.mode)
+      assert(false)
     end
   end
   outfile:write('```\n')
diff --git a/manual_tests b/manual_tests
index eb0936a..36ea677 100644
--- a/manual_tests
+++ b/manual_tests
@@ -26,3 +26,6 @@ scrolling:
     if previous line (above top of screen) wrapped, it scrolls up by only one screen line
   'down' arrow with cursor at bottom of screen scrolls down one line (drawings still fully in or out)
     if cursor line wrapped before, it scrolls down by only one screen line
+
+persistence:
+  draw a line, circle, rectangle, square, polygon, quit, restart. All the shapes you drew should still be visible.