[英]how i can draw small circle inside big one on c#?
i draw a circle and i know the radius of it and center point so how i can draw a small circle inside it and on the center that's is the code of the big circle 我画一个圆,我知道它的半径和中心点,所以我怎么能在里面和中心画一个小圆,这就是大圆的代码
g.DrawEllipse(
yellowPen,
(float)(Properties.Settings.Default.CenterXBall - rad),
(float)(Properties.Settings.Default.CenterYBall - rad),
(float)(rad * 2),
(float)(rad * 2));
//CenterXBall is the X of center big Circle
//CenterYBall is the X of center big Circle
//rad is radius
i want to draw small circle on the center of this circle on code 我想在代码上在该圆圈的中心绘制一个小圆圈
You just need to offset the position using the Radius size. 您只需要使用“半径”大小来偏移位置。
The Offset is PointF(CenterX - Radius1, CenterY - Radius2)
. 偏移量为
PointF(CenterX - Radius1, CenterY - Radius2)
。
The Size of the drawing rectangle will then be 2 * Radius
in each dimension. 然后,在每个尺寸中,绘图矩形的大小将为
2 * Radius
。
Here I assume the inner circle is half the size of the outer one. 在这里,我假设内圆是外圆的一半。
The center point is set to PointF(120, 120)
. 中心点设置为
PointF(120, 120)
。
The drawing is performed in the Paint event of a PictureBox. 在PictureBox的Paint事件中执行绘制。
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
float Radius1a = 100F;
float Radius1b = 100F;
float Radius2a = Radius1a / 2;
float Radius2b = Radius1b / 2;
PointF CentrePoint = new PointF(120, 120);
PointF Position1 = new PointF(CentrePoint.X - Radius1a, CentrePoint.Y - Radius1b);
PointF Position2 = new PointF(CentrePoint.X - Radius2a, CentrePoint.Y - Radius2b);
RectangleF Rectangle1 = new RectangleF(Position1, new SizeF(Radius1a * 2, Radius1b * 2));
RectangleF Rectangle2 = new RectangleF(Position2, new SizeF(Radius2a * 2, Radius2b * 2));
e.Graphics.DrawEllipse(new Pen(Brushes.Black, 2), Rectangle1);
e.Graphics.DrawEllipse(new Pen(Brushes.Red, 2), Rectangle2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.