Eraser in SKCanvas

Hi, Please let us know the way to integrate Eraser in SKCanvas. We are drawing using SKPaint, But we need to integrate Eraser with some stoke width.



  • mattleibowmattleibow ZAXamarin Team Xamurai
    edited June 2017

    This can be done by setting the paint's BlendMode:

    // create a bitmap that is solid blue (represents our canvas that we want to erase)
    var bitmap = new SKBitmap(256, 256);
    // now "erase" a section, making a "hole"
    using (var canvas = new SKCanvas(bitmap))
    using (var paint = new SKPaint())
        paint.IsAntialias = true;
        paint.Color = SKColors.Transparent;
        paint.BlendMode = SKBlendMode.Src;
        canvas.DrawCircle(100, 100, 80, paint);

    The bitmap will now have a "hole" in it. In the same way, you can just erase any surface by setting the BlendMode to be SKBlendMode.Src. This just takes the properties of the paint, and forces a replace of the pixels:

    Only the source will be present. [Porter Duff Compositing Operators]

  • AmitsainiAmitsaini INMember

    Thanks Matthew.

    I have tried with above and able to integrate the Eraser.


  • mattleibowmattleibow ZAXamarin Team Xamurai


  • rkshrnairrkshrnair Member
    edited July 2018


Sign In or Register to comment.