diff --git a/samples/SkiaSharpSample.Shared/Samples/PathEffect2DPathSample.cs b/samples/SkiaSharpSample.Shared/Samples/PathEffect2DPathSample.cs new file mode 100644 index 000000000..a52f9317e --- /dev/null +++ b/samples/SkiaSharpSample.Shared/Samples/PathEffect2DPathSample.cs @@ -0,0 +1,43 @@ +using SkiaSharp; + +namespace SkiaSharpSample.Samples +{ + [Preserve(AllMembers = true)] + public class PathEffect2DPathSample : SampleBase + { + [Preserve] + public PathEffect2DPathSample() + { + } + + public override string Title => "2D Path Effect"; + + public override SampleCategories Category => SampleCategories.PathEffects | SampleCategories.Paths; + + protected override void OnDrawSample(SKCanvas canvas, int width, int height) + { + canvas.Clear(SKColors.White); + + var blockSize = 30; + + // create the path + var path = new SKPath(); + // the rect must be offset as the path uses the center + var rect = SKRect.Create(blockSize / -2, blockSize / -2, blockSize, blockSize); + path.AddRect(rect); + + // move the path around: across 1 block + var offsetMatrix = SKMatrix.MakeScale(2 * blockSize, blockSize); + // each row, move across a bit / offset + SKMatrix.PreConcat(ref offsetMatrix, SKMatrix.MakeSkew(0.5f, 0)); + + // create the paint + var paint = new SKPaint(); + paint.PathEffect = SKPathEffect.Create2DPath(offsetMatrix, path); + paint.Color = SKColors.LightGray; + + // draw a rectangle + canvas.DrawRect(SKRect.Create(width, height), paint); + } + } +} diff --git a/samples/SkiaSharpSample.Shared/SkiaSharpSample.Shared.projitems b/samples/SkiaSharpSample.Shared/SkiaSharpSample.Shared.projitems index a2976bc37..5c9542908 100644 --- a/samples/SkiaSharpSample.Shared/SkiaSharpSample.Shared.projitems +++ b/samples/SkiaSharpSample.Shared/SkiaSharpSample.Shared.projitems @@ -54,6 +54,7 @@ +