flxzt / rnote

Sketch and take handwritten notes.
https://rnote.flxzt.net
GNU General Public License v3.0
8.35k stars 293 forks source link

Erasing faster skips some strokes #1247

Open mahdihasan2006 opened 1 month ago

mahdihasan2006 commented 1 month ago

Description
Erasing faster skips some strokes.

To Reproduce
Steps to reproduce the behavior:

  1. Open Rnote
  2. Draw some lines or anything
  3. Run the eraser over the lines slowly and then quickly
  4. You will see different results

Expected behavior
Eraser should erase all the lines it crosses.

Console Output

2024-10-04T08:29:30.801574Z DEBUG rnote: .. tracing subscriber initialized.

(rnote:2): Gtk-CRITICAL **: 14:29:43.443: The layout manager of type GtkBoxLayout 0x558474123790 does not create GtkLayoutChild instances

Video

https://github.com/user-attachments/assets/eb5a6e77-ac56-4254-80be-0fc0c1d5d07a

Desktop (please complete the following information):

Doublonmousse commented 1 month ago

If I'm not mistaken, the eraser works per event. Hence if you move fast, you may not have a (x,y) coordinate close to every line.

The fix would be to store the previous coordinate (x_0,y_0) and when a new event (x,y) happens, erase the polygon corresponding to the space that the eraser got through between the two events (Minkowski sum between the line between the two events and the eraser square)

mahdihasan2006 commented 1 month ago

Whatever it is. It's annoying when I try to do things quickly.

Doublonmousse commented 2 weeks ago

I've started to look at where/how I want to do this. Ideally, I'd want #1235 to land first though before starting this part.

It must be one of the most widespread bug for this kind of application (present in xournalpp, lorien, saber, journal ..)

It's made worse by this line https://github.com/flxzt/rnote/blob/7f3ff8aafcaf3137bec9993329667e5e9fbf4c4e/crates/rnote-engine/src/pens/penholder.rs#L497 That limits the event rate of the eraser to the display refresh rate (so if you have 3 events over a frame, only the last one is sent)