-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSKCanvasViewPage.xaml.cs
37 lines (33 loc) · 1012 Bytes
/
SKCanvasViewPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace SKCanvasViewLeak;
using SkiaSharp;
using SkiaSharp.Views.Maui;
public partial class SKCanvasViewPage : ContentPage
{
public SKCanvasViewPage()
{
InitializeComponent();
canvasView.InvalidateSurface();
}
protected override void OnAppearing()
{
base.OnAppearing();
canvasView.InvalidateSurface();
}
void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
SKImageInfo info = args.Info;
SKSurface surface = args.Surface;
SKCanvas canvas = surface.Canvas;
canvas.Clear();
float strokeWidth = 50;
float xRadius = (info.Width - strokeWidth) / 2;
float yRadius = (info.Height - strokeWidth) / 2;
SKPaint paint = new SKPaint
{
Style = SKPaintStyle.Stroke,
Color = SKColors.Blue,
StrokeWidth = strokeWidth
};
canvas.DrawOval(info.Width / 2, info.Height / 2, xRadius, yRadius, paint);
}
}