From 65879591caaeadaa884a8223a255835bbef0f394 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 3 Aug 2022 18:40:07 -0700 Subject: [PATCH] bugfix: imprecision in drawing scenario: slowly press down mouse button and drag to draw a line release mouse button Before this commit the point would jump just a little bit on release, and points would go slightly to the left of where I expect. Yet another thing it's hard to write an automated test for. --- Manual_tests.md | 1 + drawing.lua | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Manual_tests.md b/Manual_tests.md index 8d121d9..e258940 100644 --- a/Manual_tests.md +++ b/Manual_tests.md @@ -12,6 +12,7 @@ record those here. * How the screen looks. Our tests use a level of indirection to check text and graphics printed to screen, but not the precise pixels they translate to. - where exactly the cursor is drawn to highlight a given character + - analogously, how a shape precisely looks as you draw it ### Other compromises diff --git a/drawing.lua b/drawing.lua index 33bdbc0..8263dd9 100644 --- a/drawing.lua +++ b/drawing.lua @@ -126,6 +126,9 @@ function Drawing.draw_pending_shape(drawing, top, left,right) local function py(y) return Drawing.pixels(y, width)+top end local mx = Drawing.coord(pmx-left, width) local my = Drawing.coord(pmy-top, width) + -- recreate pixels from coords to precisely mimic how the drawing will look + -- after mouse_released + pmx,pmy = px(mx), py(my) local shape = drawing.pending if shape.mode == nil then -- nothing pending