Forum Libraries, Components, and Plugins
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Fill polygon with image/bitmap

Is there a option to fill a drawn polygon with an image/bitmap like image brushes on WPF?



  • DirkWeltzDirkWeltz DEMember ✭✭✭

    Ok, I found this myself. You have to use SKShader for this and assign this shader to SKPaint.Shader.

    Now I want to do the same with PathEffects. But I get strange outputs:

    I use the following code:

    paint.Style = SKPaintStyle.Stroke;
    paint.Color = fillColor.ToSkia(opacity);
    float scale = 10.0f;
    SKPath fillPath = new SKPath();
    SKMatrix matrix;
    fillPath.MoveTo(10, 10);
    fillPath.LineTo(0, 0);
    fillPath.MoveTo(0, 10);
    fillPath.LineTo(10, 0);
    matrix = SKMatrix.MakeScale(scale, scale);
    paint.PathEffect = SKPathEffect.Create2DPath(matrix, fillPath);
    canvas.DrawPath(path, paint);

    If I don't clip the path, I get the following result:

    Thank you for your help.

Sign In or Register to comment.