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 288 forks source link

Need a good way to store "freehand" drawing. #696

Closed Ulucai closed 5 years ago

Ulucai commented 5 years ago

I am trying to create a map-maker for tabletop RPGs.

Right now I am trying to make a "freehand" drawing feature. Basically what I did was: Load some texture in a CanvasBitmap. Use it to create a CanvasImageBrush. Then, whenever the mouse is pressed, the app saves its location into a List<Vector2>.

On the drawing Loop It just go through the list and use each item to Draw.FillCircle()

I wonder if Win2d has: Some kind of container to store the "painted" area. A feature that would aid me into checking if an area is already painted by said texture to avoid waste.

shawnhar commented 5 years ago

If you want to store a region in vector format, look into CanvasGeometry and its associated set of manipulation methods. Win2D has very rich functionality for geometry operations such as intersection and hit testing.

If you want to store in bitmap format, look at CanvasRenderTarget.