System.Drawing.Drawing2D.GraphicsPath.AddArc C# (CSharp) Method

AddArc() public method

public AddArc ( Rectangle rect, float start_angle, float sweep_angle ) : void
rect Rectangle
start_angle float
sweep_angle float
return void
        public void AddArc(Rectangle rect, float start_angle, float sweep_angle)
        {
            AppendArcs (rect.X, rect.Y, rect.Width, rect.Height, start_angle, sweep_angle);
        }

Same methods

GraphicsPath::AddArc ( RectangleF rect, float start_angle, float sweep_angle ) : void
GraphicsPath::AddArc ( float x, float y, float width, float height, float start_angle, float sweep_angle ) : void
GraphicsPath::AddArc ( int x, int y, int width, int height, float start_angle, float sweep_angle ) : void

Usage Example

Exemplo n.º 1
1
 // paramters:
 //      pen 绘制边框。可以为null,那样就整体一个填充色,没有边框
 //      brush   绘制填充色。可以为null,那样就只有边框
 public static void RoundRectangle(Graphics graphics,
     Pen pen,
     Brush brush,
     float x,
     float y,
     float width,
     float height,
     float radius)
 {
     using (GraphicsPath path = new GraphicsPath())
     {
         path.AddLine(x + radius, y, x + width - (radius * 2), y);
         path.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);
         path.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
         path.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
         path.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
         path.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
         path.AddLine(x, y + height - (radius * 2), x, y + radius);
         path.AddArc(x, y, radius * 2, radius * 2, 180, 90);
         path.CloseFigure();
         if (brush != null)
             graphics.FillPath(brush, path);
         if (pen != null)
             graphics.DrawPath(pen, path);
     }
 }
All Usage Examples Of System.Drawing.Drawing2D.GraphicsPath::AddArc