Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SkiaSharp: How to draw an Arc as shown in image

I am trying to create a remote control but not sure how to draw a path with an arc like the image below.

I considered to use SKPath.DrawArc to do the drawing of that button. When user click on a the screen, I can compare the touch point is inside the SKPath. At the moment, I don't know how to use the SKPath to draw the arc like in the photo.

enter image description here

like image 444
LittleFunny Avatar asked Dec 06 '25 05:12

LittleFunny


1 Answers

I am looking to create an additional library that contains helpful bits for SkiaSharp. Nothing to release yet, but drawing these shapes/arcs/sectors is one of the features in development.

Here is my code that will create the arc: https://github.com/mono/SkiaSharp/blob/322baee72a018a889e85fc48b42cde9764797dae/source/SkiaSharp.Extended/SkiaSharp.Extended.Shared/SKGeometry.cs#L19-L79

You will use it like:

SKPath path = SKGeometry.CreateSectorPath(0.625f, 0.875f, 100f, 50f);

This code is not yet available in a NuGet, nor do I think it will be in the very near future. But, you can go ahead and just add it into your app.

like image 154
Matthew Avatar answered Dec 09 '25 20:12

Matthew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!