microsoft / Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
http://microsoft.github.io/Win2D
Other
1.82k stars 287 forks source link

Eraser without using InkCanvas #698

Closed vas2 closed 5 years ago

vas2 commented 5 years ago

Im trying to erase the strokes or bitmaps drawn in my CanvasControl, the solution that was found was to draw the same color as the background but that seems a problem when I add a background image to my canvas. It is possible to remove only the Strokes drawn and saved in the Drawing Session?

shawnhar commented 5 years ago

I don't understand what you mean by saving things in a drawing session? Win2D is an immediate mode drawing API, so it just draws whatever you tell it to - there's no saving of anything other than if you explicitly tell it to store things into a CanvasCommandList or CanvasRenderTarget.

If you want to get rid of something you previously drew, you could either redraw everything except for the specific thing you want to remove, or you could redraw everything including the bit you want to erase, then draw whatever the background to the erased part was over the top of (which produces the same result as if you didn't draw that bit in the first place).