我正在尝试绘制并填充一个三角形。我提到了一个 android - 问题如何在 android Canvas 上绘制填充三角形并执行了以下操作。它绘制了三角形,但没有填充它。如何填满?另外,是否可以用与线条颜色不同的颜色填充它?
Xamarin 表单
private void OnPainting(object sender, SKPaintSurfaceEventArgs e)
{
var surface = e.Surface;
var canvas = surface.Canvas;
canvas.Clear(SKColors.White);
var pathStroke2 = new SKPaint
{
IsAntialias = true,
Style = SKPaintStyle.StrokeAndFill,
Color = new SKColor(244, 0, 110, 200),
StrokeWidth = 5
};
var path2 = new SKPath { FillType = SKPathFillType.EvenOdd };
path2.MoveTo(0, 0);
path2.LineTo(0, 140);
path2.MoveTo(0, 140);
path2.LineTo(140, 140);
path2.MoveTo(140, 140);
path2.LineTo(0, 0);
path2.Close();
canvas.DrawPath(path2, pathStroke2);
}