[英]how i can draw small circle inside big one on c#?
我画一个圆,我知道它的半径和中心点,所以我怎么能在里面和中心画一个小圆,这就是大圆的代码
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
我想在代码上在该圆圈的中心绘制一个小圆圈
您只需要使用“半径”大小来偏移位置。
偏移量为PointF(CenterX - Radius1, CenterY - Radius2)
。
然后,在每个尺寸中,绘图矩形的大小将为2 * Radius
。
在这里,我假设内圆是外圆的一半。
中心点设置为PointF(120, 120)
。
在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.