about summary refs log tree commit diff stats
path: root/drawing.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-09-15 23:56:49 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-09-15 23:56:49 -0700
commit09c76c82c2a415839ad0d50d9fc14e883caeae6e (patch)
tree104401a62623498d9cf9eabe50159e6eec1668f3 /drawing.lua
parent1a88b4a2907a78fd4a1febf32c74d0305aff6ba0 (diff)
parent715c6fd32fadf8b14f4755cc31bacfb21c7f7dac (diff)
downloadview.love-09c76c82c2a415839ad0d50d9fc14e883caeae6e.tar.gz
Merge lines.love
Diffstat (limited to 'drawing.lua')
-rw-r--r--drawing.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/drawing.lua b/drawing.lua
index 5af25fb..a98f5b2 100644
--- a/drawing.lua
+++ b/drawing.lua
@@ -191,8 +191,9 @@ function Drawing.draw_pending_shape(drawing, top, left,right)
     if mx < 0 or mx >= 256 or my < 0 or my >= drawing.h then
       return
     end
+    local r = round(geom.dist(center.x, center.y, mx, my))
     local cx,cy = px(center.x), py(center.y)
-    love.graphics.circle('line', cx,cy, geom.dist(cx,cy, App.mouse_x(),App.mouse_y()))
+    love.graphics.circle('line', cx,cy, Drawing.pixels(r, width))
   elseif shape.mode == 'arc' then
     local center = drawing.points[shape.center]
     if mx < 0 or mx >= 256 or my < 0 or my >= drawing.h then
@@ -248,6 +249,12 @@ function Drawing.update(State)
   if State.lines.current_drawing == nil then return end
   local drawing = State.lines.current_drawing
   local line_cache = State.line_cache[State.lines.current_drawing_index]
+  if line_cache.starty == nil then
+    -- some event cleared starty just this frame
+    -- draw in this frame will soon set starty
+    -- just skip this frame
+    return
+  end
   assert(drawing.mode == 'drawing')
   local pmx, pmy = App.mouse_x(), App.mouse_y()
   local mx = Drawing.coord(pmx-State.left, State.width)