次のコードを使用してSkiaSharpキャンバスビューで円弧を描こうとしています。SkiaSharp ArcToメソッドで曲線が描画されない
path3.ArcTo(new SKPoint(0, h/2), 1.57f, SKPathArcSize.Large,
SKPathDirection.Clockwise, new SKPoint(w/2, h));
しかし、カーブではなく、直線を描いています。どのように曲線にするには?
完全なコード
private void OnPainting(object sender, SKPaintSurfaceEventArgs e)
{
var surface = e.Surface;
var canvas = surface.Canvas;
canvas.Clear(SKColors.White);
var w = e.Info.Width;
var h = e.Info.Height;
var pathStroke3 = new SKPaint
{
IsAntialias = true,
Style = SKPaintStyle.StrokeAndFill,
Color = new SKColor(240, 0, 100, 250),
StrokeWidth = 5
};
var path3 = new SKPath { FillType = SKPathFillType.EvenOdd };
path3.MoveTo(0, h/2);
path3.ArcTo(new SKPoint(0, h/2), 1.57f, SKPathArcSize.Large, SKPathDirection.Clockwise, new SKPoint(w/2, h));
path3.LineTo(0, h);
path3.Close();
canvas.DrawPath(path3, pathStroke3);
}
XAML
<Grid x:Name="controlGrid" ColumnSpacing="0" RowSpacing="0" Padding="0" BackgroundColor="White" >
<Grid.RowDefinitions>
<RowDefinition Height="4*" />
<RowDefinition Height="6*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<views:SKCanvasView PaintSurface="OnPainting" EnableTouchEvents="True"
Touch="OnTouch" HeightRequest="300" Grid.Row="0"/>
</Grid>