diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-05-14 16:10:41 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-05-14 16:10:41 -0700 |
commit | a995e796ff3bf4d248c8cb71f9f0721ab12b1c52 (patch) | |
tree | c0d699a3cf88963c12ae91e99dcb97e5b1d8761d | |
parent | 7d5a70379f5d2face8dcafb9d4816fff3c60599b (diff) | |
download | text.love-a995e796ff3bf4d248c8cb71f9f0721ab12b1c52.tar.gz |
snap lines to nearby points
-rw-r--r-- | main.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main.lua b/main.lua index 8b8f90b..a09e580 100644 --- a/main.lua +++ b/main.lua @@ -171,8 +171,10 @@ function propagate_to_drawings(x,y, button) end function insert_point(points, x,y) + local px,py = pixels(x),pixels(y) for i,point in ipairs(points) do - if point.x == x and point.y == y then + local cx,cy = pixels(point.x), pixels(point.y) + if (cx-px)*(cx-px) + (cy-py)*(cy-py) < 16 then return i end end |