Forum Xamarin Xamarin.Forms

set drawing limits

I'm using SkiaSharp to draw inside an image.
But I would like it to be drawn only within the outline of the horse, if the user tries to take a risk outside that area of ​​the horse for example, there is no risk of the outline.
Could someone give me a hint how to do this?


  • LeonLuLeonLu Member, Xamarin Team Xamurai

    You can enable the TouchEvents for your SKCanvasView, then add the touche event.

     <forms:SKCanvasView x:Name="SkCanvasView" 
        PaintSurface="SkCanvasView_OnPaintSurface" />

    Then you can subscribte to it and handle the it.

     private void SkCanvasView_Touch(
      object sender, SKTouchEventArgs e)
    if (e.ActionType == 
        _lastTouchPoint = e.Location;
        e.Handled = true;
    _lastTouchPoint = e.Location;
    // update the Canvas as you wish

    According to the location, then you can judge the border. then update your canvans.

    There is a blog about it.

Sign In or Register to comment.