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.CreateScale(2 * blockSize, blockSize); // each row, move across a bit / offset offsetMatrix = SKMatrix.Concat(offsetMatrix, SKMatrix.CreateSkew(0.5f, 0)); // create the paint var paint = new SKPaint { PathEffect = SKPathEffect.Create2DPath(offsetMatrix, path), Color = SKColors.LightGray }; // draw a rectangle canvas.DrawRect(SKRect.Create(width + blockSize, height + blockSize), paint); }
private void OnPaintBackground(object sender, SKPaintSurfaceEventArgs e) { var scale = e.Info.Width / (float)((View)sender).Width; var blockSize = BaseBlockSize * scale; var offsetMatrix = SKMatrix.CreateScale(2 * blockSize, blockSize); var skewMatrix = SKMatrix.CreateSkew(0.5f, 0); var matrix = offsetMatrix.PreConcat(skewMatrix); using var path = new SKPath(); path.AddRect(SKRect.Create(blockSize / -2, blockSize / -2, blockSize, blockSize)); using var paint = new SKPaint { PathEffect = SKPathEffect.Create2DPath(matrix, path), Color = 0xFFF0F0F0 }; var canvas = e.Surface.Canvas; var area = SKRect.Create(e.Info.Width + blockSize, e.Info.Height + blockSize); canvas.DrawRect(area, paint); }