我想在圆的底部放置一个矩形,如下所示,
但是我无法获得相交点来放置矩形。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); circleHeight = (circleWidth / 3) * 2;
this.panel1.Paint += Panel1_Paint;
}
int circleWidth = 314;
int circleHeight;
int FrameThickness = 12;
private void Panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
GraphicsPath pth = new GraphicsPath();
System.Drawing.Drawing2D.GraphicsPath basePath = new System.Drawing.Drawing2D.GraphicsPath();
int x = this.circleWidth;
int rectWidth = (int)Math.Ceiling(this.circleWidth * 0.94); // 94 % of the actual circle width
int rectRimWidth = rectWidth - (this.FrameThickness * 2);
int xOffset = (this.circleWidth - rectWidth) / 2;
int yOffset = (this.circleWidth - rectRimWidth) / 2;
Rectangle rect; Rectangle rectrim;
rect = new Rectangle(0 + xOffset, 0 + xOffset, rectWidth, rectWidth);
rectrim = new Rectangle(0 + yOffset, 0 + yOffset, rectRimWidth, rectRimWidth);
e.Graphics.FillEllipse(Brushes.Red, rect);
e.Graphics.FillEllipse(Brushes.Yellow, rectrim);
Point Center = new Point(circleWidth / 2, circleWidth / 2);
e.Graphics.FillRectangle(Brushes.Red, new Rectangle(rect.X, circleHeight - FrameThickness, rectWidth, FrameThickness));
}
private int GetInnerWidth()
{
return (int)(Math.Ceiling(circleWidth * 0.94) - (FrameThickness * 2));
}
private int GetWidth()
{
return GetInnerWidth() - (int)(GetInnerWidth() * 0.14); // 14% of adjacent circle
}
internal int InnerRimRadius
{
get
{
return GetInnerWidth() / 2 + GetFrameThickness() / 2;
}
}
}
我已经提到了大多数堆栈溢出后的帖子,不幸的是,这全无助于我得到我真正想要的东西。请帮助我找出代码。预先感谢。