Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add rect using Skia Sharp and apply both fill color and stroke color to that object?

How to add rect or any shape using Skia Sharp and apply both fill color and stroke color to that object in iOS

like image 373
Devaraj Avatar asked Feb 17 '17 11:02

Devaraj


1 Answers

To draw both fill and stroke, you will have to do two paint operations:

// the rectangle
var rect = SKRect.Create(10, 10, 100, 100);

// the brush (fill with blue)
var paint = new SKPaint {
    Style = SKPaintStyle.Fill,
    Color = SKColors.Blue
};

// draw fill
canvas.DrawRect(rect, paint);

// change the brush (stroke with red)
paint.Style = SKPaintStyle.Stroke;
paint.Color = SKColors.Red;

// draw stroke
canvas.DrawRect(rect, paint);
like image 64
Matthew Avatar answered Oct 01 '22 03:10

Matthew