Eraser in SkiaSharp (Finger Painting)

Is there any way to create an eraser to remove previously created SKPath's? I wish create a new transparent SKPath which will act as an eraser to any previously rendered SKPath's... Please, help me, guys, I'm really going nuts here, thanks in advance.

Answers

  • mario.moramario.mora USMember ✭✭

    Hi,
    I could achieve it by playing with the blending mode of the skpaint

    You have to set transparent color and blendmode as "Src", shomehow like this:

    SKPaint _paint = new SKPaint
    {
    Style = SKPaintStyle.Stroke,
    StrokeCap = SKStrokeCap.Round,
    StrokeJoin = SKStrokeJoin.Round,
    Color = _isDeleting? Color.Transparent : SomeForeColor,
    BlendMode = _isDeleting? SKBlendMode.Src : SKBlendMode.SrcOver
    (...)
    };

    when _isDeleting=true, then the drawing action will replace everything in its path for whatever is behind on that canvas' object (color or image)

Sign In or Register to comment.