I'm trying draw something like following shapes with 3 parameters
the cut out part is bottom of the circle.
I figured out that I can use
var path = new GraphicsPath();
path.AddEllipse(new RectangleF(center.X - radius, center.Y - radius, radius*2, radius*2))
// ....
g.DrawPath(path);
but, how can I draw such thing?
BTW, What is the name of that shape? I could't search previous questions or something due to lack of terminology.
Thanks.
Here you go, place this in some paint event:
// set up your values
float radius = 50;
PointF center = new Point( 60,60);
float cutOutLen = 20;
RectangleF circleRect =
new RectangleF(center.X - radius, center.Y - radius, radius * 2, radius * 2);
// the angle
float alpha = (float) (Math.Asin(1f * (radius - cutOutLen) / radius) / Math.PI * 180);
var path = new GraphicsPath();
path.AddArc(circleRect, 180 - alpha, 180 + 2 * alpha);
path.CloseFigure();
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.FillPath(Brushes.Yellow, path);
e.Graphics.DrawPath(Pens.Red, path);
path.Dispose();
Here is the result:
I'm not sure about the term of a cut circle; in effect it is a Thales Cirlce.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With