获取圆角矩形的线
private void DrawRoundRect(GraphicsPath gp, float X, float Y, float width, float height, float radius)
{
gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
gp.CloseFigure();
}
复制代码
绘制
//创建画板
Graphics g = CreateGraphics();
//清除
g.Clear(BackColor);
//圆角矩形的线
GraphicsPath gp = new GraphicsPath();
DrawRoundRect(gp, 900, 200, 100, 100, 10);
//绘制线
g.DrawPath(new Pen(Color.Gray, 2), gp);
//释放
gp.Dispose();
g.Dispose();
复制代码
效果

绘制圆角矩形填充内部
DrawPath只是绘制线,可以使用FillPath填充内部
g.FillPath(Brushes.SkyBlue, gp);
复制代码
效果

© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END




















![[桜井宁宁]COS和泉纱雾超可爱写真福利集-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/4d3cf227a85d7e79f5d6b4efb6bde3e8.jpg)

![[桜井宁宁] 爆乳奶牛少女cos写真-一一网](https://www.proyy.com/skycj/data/images/2020-12-13/d40483e126fcf567894e89c65eaca655.jpg)