UWP InkCanvas fills a drawn shape with color
I am currently working on a UWP application that should allow the user to draw any shape they want on the InkCanvas. These form edges are auto-completed so there is no open space (up to this point everything works fine).
Now my question is, how do I automatically fill this shape with one color (or pattern)? I know there is a Point in Polygon algorithm, but I have no idea how to implement it in UWP InkCanvas because I really don't understand how to search for points within a form without iterating each point onto the canvas.
Edit: I actually did it using "canvas" as an overlay to draw the polyline. Using Polyline.Fill () method it worked. But I only need the same effect on the "InkCanvas".
source to share
Now my question is, how do I automatically fill this shape with one color (or pattern)? I know there is a "Point in Polygon" algorithm, but I have no idea how to implement it in UWP InkCanvas
You can redraw existing ink strokes in Ink Canvas by setting a new one InkDrawingAttributes
for InkStroke.DrawingAttributes
.
private void Button_Click(object sender, RoutedEventArgs e)
{
InkDrawingAttributes attr = new InkDrawingAttributes();
attr.Color = Colors.Red;
attr.IgnorePressure = true;
attr.PenTip = PenTipShape.Circle;
attr.Size = new Size(4, 10);
attr.PenTipTransform = Matrix3x2.CreateRotation((float)(70 * Math.PI / 180));
IReadOnlyList<InkStroke> InkStrokeList = MyInk.InkPresenter.StrokeContainer.GetStrokes();
foreach (InkStroke temp in InkStrokeList)
{
temp.DrawingAttributes = attr;
}
}
source to share