I am trying to make a drawing app in Xamarin.Forms. I am able to draw paths. My problem is, how can I remove part of a path, when user try to erase on the drawing. I have tried the following:
if (IsEraseClicked)
{
switch (args.Type)
{
case TouchActionType.Pressed:
if (!inProgressPaths.ContainsKey(args.Id))
{
SKPath path = new SKPath();
path.MoveTo(ConvertToPixel(args.Location));
inProgressPaths.Add(args.Id, path);
UpdateBitmap();
}
break;
case TouchActionType.Moved:
if (inProgressPaths.ContainsKey(args.Id))
{
SKPath path = inProgressPaths[args.Id];
path.LineTo(ConvertToPixel(args.Location));
UpdateBitmap();
}
break;
case TouchActionType.Released:
if (inProgressPaths.ContainsKey(args.Id))
{
if (completedPaths.Contains(inProgressPaths[args.Id]))
{
completedPaths.Remove(inProgressPaths[args.Id]);
inProgressPaths.Remove(args.Id);
UpdateBitmap();
}
}
break;
case TouchActionType.Cancelled:
if (inProgressPaths.ContainsKey(args.Id))
{
inProgressPaths.Remove(args.Id);
UpdateBitmap();
}
break;
}
}
I am using the SkiaSharp library.
Just need to change the SKPaint to these setting when the erase is clicked.
And set back to when pencil is clicked.