excalidraw icon indicating copy to clipboard operation
excalidraw copied to clipboard

non-atomic erasing for linear & freedraw shapes

Open dwelle opened this issue 4 years ago • 14 comments

Instead of removing whole shapes, with linear and freedraw shapes we can erase points that are close in proximity to the cursor.

@maielo pointed out this behavior may actually be undesirable for most use cases that excalidraw is used for, where deleting whole shapes is faster than being forced to erase all individual points. So if we implement this we should make this opt-in from the properties pannel.

Spec:

  • it should split the shape into two when a middle point is removed
  • for better results, we should create new points at the edges of the split lines to minimize the effect on the resulting shape

image

Ultimately, a solution that creates even more points to better approximate the original shape would be ideal, but not easy:

image

dwelle avatar Mar 11 '22 16:03 dwelle

I'm not sure if this is really possible, but I really like the idea of being able to erase in a similar way to how one might erase in GoodNotes or the Apple Notes app: bit by bit. Like how I erase drawings. Pixel-by-pixel.

Also, is it possible to set the eraser (or any other tool) to the double-tap for the Apple Pencil? I'm not sure how this works exactly.

oak86 avatar Mar 12 '22 16:03 oak86

I'm not sure if this is really possible, but I really like the idea of being able to erase in a similar way to how one might erase in GoodNotes or the Apple Notes app: bit by bit. Like how I erase drawings. Pixel-by-pixel.

With SVGs (which is what we're using underneath), the only way to do this is the workflow shown above.

Also, is it possible to set the eraser (or any other tool) to the double-tap for the Apple Pencil? I'm not sure how this works exactly.

Tried, but sadly, no. To my knowledge it's not emitting any event we can subscribe to from javascript.

dwelle avatar May 15 '22 08:05 dwelle

+1 for the functionality for my use case which I think might be common - I am configuring my excalidraw extension on obsidian to be a simultaneous hand & typed note-taker as onenote. If you handwrite-annotate something on your typed note and need to erase only the annotation then the eraser tool assumes that you are erasing the whole object, which is both the annotation and typed note.

luutuankiet avatar Aug 17 '22 06:08 luutuankiet

+1 for this; erasing whole lines is not okay enough for really good freedraw experiences.

NyaomiDEV avatar Oct 27 '22 08:10 NyaomiDEV

+1 Just pitching in like everyone else. A free hand eraser for hand drawn notes would be amazing, especially if it applies only to the vector based portions of the excalidraw file and doesnt mess with images, text, etc.

DanTheRobot avatar Jan 02 '23 14:01 DanTheRobot

I don't know how applicable to the current situation this suggestion might be, but I would recommend taking a look at Clip Studio's vector eraser. At a first glance your current idea for implementation is very similar, which allows for some cool extra functionalities that would be near impossible to have in pixel based drawing layers such as erase to intersection.

Here is a short 2 min demonstration video of the vector eraser from Clip Studio's YouTube channel: https://www.youtube.com/watch?v=mGd1dF011oQ

DanTheRobot avatar Jan 16 '23 18:01 DanTheRobot

Could we add some support for the convenient switch between the pen and eraser? It would be a little time-consuming to find the eraser and then switch to the pen. Thanks!

lambtt avatar Mar 20 '23 19:03 lambtt

I'm not sure if this is really possible, but I really like the idea of being able to erase in a similar way to how one might erase in GoodNotes or the Apple Notes app: bit by bit. Like how I erase drawings. Pixel-by-pixel.

Is there an example of an open source application where I can see how it is implemented? Or an algorithm how they do it? An app like goodnotes "erases" a vector with incredible precision

sergey900553 avatar Mar 30 '23 02:03 sergey900553

Is there an example of an open source application where I can see how it is implemented? Or an algorithm how they do it? An app like goodnotes "erases" a vector with incredible precision

Xournal++ is an open source alternative to Goodnotes where the eraser also deletes drawings bit by bit.

Here is the link to the app website: https://xournalpp.github.io/ here is a link to the GitHub: https://github.com/xournalpp/xournalpp/

DanTheRobot avatar Apr 30 '23 15:04 DanTheRobot

I feel that both operations are distinct enough that they shouldn’t be conflated.

The current eraser deletes everything it touches wholesale. It’s very useful and should not be replaced if/when the part-wise eraser is implemented. I also don’t think it should be hidden in the options panel.

I understand you might not want to clutter the UI but I’d put „the deleter“ and „the eraser“ next to each other as two dedicated buttons.

For the here proposed eraser, I like how it works in browserboard, if that is possible to implement.

0x53A avatar Nov 06 '23 11:11 0x53A

Also, is it possible to set the eraser (or any other tool) to the double-tap for the Apple Pencil? I'm not sure how this works exactly.

Tried, but sadly, no. To my knowledge it's not emitting any event we can subscribe to from javascript.

I don’t think it’s possible in the browser, that is, in Safari, but it might be possible if the browser is hosted inside an app. Then the app should be able to capture the events and forward them to the browser instance.

That would be relevant for, for example, Obsidian with the excalidraw addon.

So you could provide a hook that’s non-functional inside the browser but can be triggered from a host.

0x53A avatar Nov 06 '23 11:11 0x53A

Why do complicated surgery on shapes and not just use SVG mask to subtract the eraser path from any given stroke?

mrzv avatar Nov 17 '23 05:11 mrzv

+1 would be really useful to have and would make me use excalidraw a lot more for a bunch of stuff.

Chryron avatar Apr 20 '24 01:04 Chryron

Looking forward to this!

CrocodileDuty avatar Apr 29 '24 14:04 CrocodileDuty