about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-09-15 08:24:54 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-09-15 08:30:15 -0700
commit0e20565e17cd9f1580aa2451de8b16b863ae0382 (patch)
tree91c4ab11478d2fa3eb9ac7ce2d8cd981eeff4a06
parent1fd30c0462faf598d5ef7b2911379bc19a649253 (diff)
downloadview.love-0e20565e17cd9f1580aa2451de8b16b863ae0382.tar.gz
clean up a slight jitter when drawing circles
Earlier the ghost while drawing wouldn't quite match the final shape.
Now the math is identical in draw_pending_shape.

It's a little unfortunate that we have this duplication of formulae.

At least there are no other stray calls of App.mouse_x in
draw_pending_shape.
-rw-r--r--drawing.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/drawing.lua b/drawing.lua
index 5af25fb..ac4990a 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