如何绘制由圆弧构成的填充路径

How to draw a filled path built of arcs

可能是一个简单的问题:

如何绘制由直线和圆弧构建的填充图形路径?问题是,GDI+ 仅以顺时针方向定义从起始角到结束角的弧。

Image to be made

一个示例(任何语言)就太好了!

应该通过设置圆弧的终点为下一行的起点等来实现

一条路=>

  • 结果:

  • 代码(C#,VS 2015): (画在屏幕DC上进行测试):
using (Graphics gr = Graphics.FromHwnd(IntPtr.Zero))
{
   RectangleF rect = new Rectangle(500, 100, 400, 400 / 2);
   RectangleF rectArc;
   float nXradius = 60;
   float nYradius = 60;

   PointF point1, point2;
   GraphicsPath gp = new GraphicsPath();

   // Upper Left
   rectArc = new RectangleF(rect.X, rect.Y, 2 * nXradius, 2 * nYradius);
   gp.AddArc(rectArc, 180, 90);
   point1 = new PointF(rect.X + nXradius, rect.Y);                   

   // Top Border                   
   point2 = new PointF(rect.Right - nXradius, rect.Y);                   
   gp.AddLine(point1, point2);

   // Upper Right.
   rectArc = new RectangleF(rect.Right - 2 * nXradius, rect.Y, 2 * nXradius, 2 * nYradius);
   gp.AddArc(rectArc, 270, 90);
   point1 = new PointF(rect.Right, rect.Y + nYradius);

   // Right Border
   point2 = new PointF(rect.Right, rect.Bottom - nYradius);                   
   gp.AddLine(point1, point2);

   // Lower Right
   rectArc = new RectangleF(rect.Right, rect.Bottom - 2 * nYradius, 2 * nXradius, 2 * nYradius);
   gp.AddArc(rectArc, -180, -90);
   point1 = new PointF(rect.Right + nXradius, rect.Bottom);

   // Bottom Border                  
   point2 = new PointF(rect.X - nXradius, rect.Bottom);                  
   gp.AddLine(point1, point2);

   // Lower Left
   rectArc = new RectangleF(rect.X - 2 * nXradius, rect.Bottom - 2 * nYradius, 2 * nXradius, 2 * nYradius);
   gp.AddArc(rectArc, 90, -90);
   point1 = new PointF(rect.X, rect.Bottom - nYradius);                  

   // Left Border
   point2 = new PointF(rect.X, rect.Y + nYradius);                   
   gp.AddLine(point1, point2);

   gp.CloseFigure();
   System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 10);
   pen.LineJoin = LineJoin.Round;
   gr.SmoothingMode = SmoothingMode.AntiAlias;
   gr.DrawPath(pen, gp);
   gr.FillPath(System.Drawing.Brushes.Orange, gp);
}