Reputation: 19
I've just started using ImageSharp to draw images. The documentation on Six Labors web page is clean, but there is no examples to find anywhere about ImageSharp. So I struggle from time to time, all by myself :)
I want to draw a circle with PathBuilder and a given position in x and y as a center point, and a given radius.
I tried to use an EllipsePolygon where you can define x, y, and radius. And then I wanted to draw it in my PathBuilder but PathBuilder only has "AddEllipticalArc" what I can find.
So I have used this function to draw circles instead, like this for example:
pb.AddEllipticalArc(new Point(300, 200), 10, 10, 0, 0, 360);
Is there a better way to draw circles? Or am I supposed to use AddEllipticalArc?
Bonus question: I also have to draw Arcs with only a centerPoint, startPoint and endPoint given to me. But I guess I have to translate these given points and calculate the startAngle and sweepAngle myself. What could be the easiest alternative for this?
Upvotes: 0
Views: 804
Reputation: 2604
You can create a EllipsePolygon object and draw it onto the image:
var polygon = new EllipsePolygon(new Point(radius, radius), radius);
image.Mutate(x => x.Draw(Color.White, 5, polygon));
Upvotes: 0