Graphics.DrawArc 方法

定义

绘制一个弧线,表示由一对坐标、宽度和高度指定的椭圆部分。

重载

DrawArc(Pen, Rectangle, Single, Single)

绘制一个弧线,表示由 Rectangle 结构指定的椭圆部分。

DrawArc(Pen, RectangleF, Single, Single)

绘制一个弧线,表示由 RectangleF 结构指定的椭圆部分。

DrawArc(Pen, Int32, Int32, Int32, Int32, Int32, Int32)

绘制一个弧线,表示由一对坐标、宽度和高度指定的椭圆部分。

DrawArc(Pen, Single, Single, Single, Single, Single, Single)

绘制一个弧线,表示由一对坐标、宽度和高度指定的椭圆部分。

DrawArc(Pen, Rectangle, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制一个弧线,表示由 Rectangle 结构指定的椭圆部分。

public:
 void DrawArc(System::Drawing::Pen ^ pen, System::Drawing::Rectangle rect, float startAngle, float sweepAngle);
public void DrawArc (System.Drawing.Pen pen, System.Drawing.Rectangle rect, float startAngle, float sweepAngle);
member this.DrawArc : System.Drawing.Pen * System.Drawing.Rectangle * single * single -> unit
Public Sub DrawArc (pen As Pen, rect As Rectangle, startAngle As Single, sweepAngle As Single)

参数

pen
Pen

确定弧的颜色、宽度和样式的 Pen

rect
Rectangle

定义椭圆边界的 RectangleF 结构。

startAngle
Single

从 x 轴到弧线起点的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到弧的终点,以度为单位的角度。

例外

pen null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建黑色笔。

  • 创建一个矩形来绑定椭圆。

  • 定义开始(45 度)和横扫(270 度)角度。

  • 将椭圆弧绘制到屏幕。

结果是部分椭圆缺少 x 轴的 + 和 - 45 度之间的段。

private:
   void DrawArcRectangle( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create rectangle to bound ellipse.
      Rectangle rect = Rectangle(0,0,100,200);

      // Create start and sweep angles on ellipse.
      float startAngle = 45.0F;
      float sweepAngle = 270.0F;

      // Draw arc to screen.
      e->Graphics->DrawArc( blackPen, rect, startAngle, sweepAngle );
   }
private void DrawArcRectangle(PaintEventArgs e)
{
   // Create pen.
    Pen blackPen= new Pen(Color.Black, 3);
             
    // Create rectangle to bound ellipse.
    Rectangle rect = new Rectangle(0, 0, 100, 200);
             
    // Create start and sweep angles on ellipse.
    float startAngle =  45.0F;
    float sweepAngle = 270.0F;
             
    // Draw arc to screen.
    e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
}
Private Sub DrawArcRectangle(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create rectangle to bound ellipse.
    Dim rect As New Rectangle(0, 0, 100, 200)

    ' Create start and sweep angles on ellipse.
    Dim startAngle As Single = 45.0F
    Dim sweepAngle As Single = 270.0F

    ' Draw arc to screen.
    e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle)
End Sub

注解

此方法绘制一个弧线,它是椭圆外围的一部分。 椭圆由矩形的边界定义。 弧线是 startAngle 参数和 startAngle + sweepAngle 参数之间的椭圆的外围部分。

适用于

DrawArc(Pen, RectangleF, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制一个弧线,表示由 RectangleF 结构指定的椭圆部分。

public:
 void DrawArc(System::Drawing::Pen ^ pen, System::Drawing::RectangleF rect, float startAngle, float sweepAngle);
public void DrawArc (System.Drawing.Pen pen, System.Drawing.RectangleF rect, float startAngle, float sweepAngle);
member this.DrawArc : System.Drawing.Pen * System.Drawing.RectangleF * single * single -> unit
Public Sub DrawArc (pen As Pen, rect As RectangleF, startAngle As Single, sweepAngle As Single)

参数

pen
Pen

确定弧的颜色、宽度和样式的 Pen

rect
RectangleF

定义椭圆边界的 RectangleF 结构。

startAngle
Single

从 x 轴到弧线起点的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到弧的终点,以度为单位的角度。

例外

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建黑色笔。

  • 创建一个矩形来绑定椭圆。

  • 定义开始(45 度)和横扫(270 度)角度。

  • 将椭圆弧绘制到屏幕。

结果是部分椭圆缺少 x 轴的 + 和 - 45 度之间的段。

private:
   void DrawArcRectangleF( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create rectangle to bound ellipse.
      RectangleF rect = RectangleF(0.0F,0.0F,100.0F,200.0F);

      // Create start and sweep angles on ellipse.
      float startAngle = 45.0F;
      float sweepAngle = 270.0F;

      // Draw arc to screen.
      e->Graphics->DrawArc( blackPen, rect, startAngle, sweepAngle );
   }
private void DrawArcRectangleF(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen= new Pen(Color.Black, 3);
             
    // Create rectangle to bound ellipse.
    RectangleF rect = new RectangleF(0.0F, 0.0F, 100.0F, 200.0F);
             
    // Create start and sweep angles on ellipse.
    float startAngle =  45.0F;
    float sweepAngle = 270.0F;
             
    // Draw arc to screen.
    e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle);
}
Private Sub DrawArcRectangleF(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create rectangle to bound ellipse.
    Dim rect As New RectangleF(0.0F, 0.0F, 100.0F, 200.0F)

    ' Create start and sweep angles on ellipse.
    Dim startAngle As Single = 45.0F
    Dim sweepAngle As Single = 270.0F

    ' Draw arc to screen.
    e.Graphics.DrawArc(blackPen, rect, startAngle, sweepAngle)
End Sub

注解

此方法绘制一个弧线,它是椭圆外围的一部分。 椭圆由矩形的边界定义。 弧线是 startAngle 参数和 startAngle + sweepAngle 参数之间的椭圆的外围部分。

适用于

DrawArc(Pen, Int32, Int32, Int32, Int32, Int32, Int32)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制一个弧线,表示由一对坐标、宽度和高度指定的椭圆部分。

public:
 void DrawArc(System::Drawing::Pen ^ pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
public void DrawArc (System.Drawing.Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle);
member this.DrawArc : System.Drawing.Pen * int * int * int * int * int * int -> unit
Public Sub DrawArc (pen As Pen, x As Integer, y As Integer, width As Integer, height As Integer, startAngle As Integer, sweepAngle As Integer)

参数

pen
Pen

确定弧的颜色、宽度和样式的 Pen

x
Int32

定义椭圆的矩形左上角的 x 坐标。

y
Int32

定义椭圆的矩形左上角的 y 坐标。

width
Int32

定义椭圆的矩形的宽度。

height
Int32

定义椭圆的矩形的高度。

startAngle
Int32

从 x 轴到弧线起点的顺时针测量角度(以度为单位)。

sweepAngle
Int32

startAngle 参数到弧的终点,以度为单位的角度。

例外

pen null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建黑色笔。

  • 创建矩形的位置和大小以绑定椭圆。

  • 定义开始(45 度)和横扫(270 度)角度。

  • 将椭圆弧绘制到屏幕。

结果是部分椭圆缺少 x 轴的 + 和 - 45 度之间的段。

private:
   void DrawArcInt( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
      // Create coordinates of rectangle to bound ellipse.
      int x = 0;
      int y = 0;
      int width = 100;
      int height = 200;

      // Create start and sweep angles on ellipse.
      int startAngle = 45;
      int sweepAngle = 270;

      // Draw arc to screen.
      e->Graphics->DrawArc( blackPen, x, y, width, height, startAngle, sweepAngle );
   }
private void DrawArcInt(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen= new Pen(Color.Black, 3);
             
    // Create coordinates of rectangle to bound ellipse.
    int x = 0;
    int y = 0;
    int width = 100;
    int height = 200;
             
    // Create start and sweep angles on ellipse.
    int startAngle =  45;
    int sweepAngle = 270;
             
    // Draw arc to screen.
    e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, sweepAngle);
}
Private Sub DrawArcInt(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create coordinates of rectangle to bound ellipse.
    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim width As Integer = 100
    Dim height As Integer = 200

    ' Create start and sweep angles on ellipse.
    Dim startAngle As Integer = 45
    Dim sweepAngle As Integer = 270

    ' Draw arc to screen.
    e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, _
    sweepAngle)
End Sub

注解

此方法绘制一个弧线,它是椭圆外围的一部分。 椭圆由矩形的边界定义。 弧线是 startAngle 参数和 startAngle + sweepAngle 参数之间的椭圆的外围部分。

适用于

DrawArc(Pen, Single, Single, Single, Single, Single, Single)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

绘制一个弧线,表示由一对坐标、宽度和高度指定的椭圆部分。

public:
 void DrawArc(System::Drawing::Pen ^ pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
public void DrawArc (System.Drawing.Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
member this.DrawArc : System.Drawing.Pen * single * single * single * single * single * single -> unit
Public Sub DrawArc (pen As Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)

参数

pen
Pen

确定弧的颜色、宽度和样式的 Pen

x
Single

定义椭圆的矩形左上角的 x 坐标。

y
Single

定义椭圆的矩形左上角的 y 坐标。

width
Single

定义椭圆的矩形的宽度。

height
Single

定义椭圆的矩形的高度。

startAngle
Single

从 x 轴到弧线起点的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到弧的终点,以度为单位的角度。

例外

pen null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建黑色笔。

  • 创建矩形的位置和大小以绑定椭圆。

  • 定义开始(45 度)和横扫(270 度)角度。

  • 将椭圆弧绘制到屏幕。

结果是部分椭圆缺少 x 轴的 + 和 - 45 度之间的段。

private:
   void DrawArcFloat( PaintEventArgs^ e )
   {
      // Create pen.
      Pen^ blackPen = gcnew Pen( Color::Black,3.0f );

      // Create coordinates of rectangle to bound ellipse.
      float x = 0.0F;
      float y = 0.0F;
      float width = 100.0F;
      float height = 200.0F;

      // Create start and sweep angles on ellipse.
      float startAngle = 45.0F;
      float sweepAngle = 270.0F;

      // Draw arc to screen.
      e->Graphics->DrawArc( blackPen, x, y, width, height, startAngle, sweepAngle );
   }
private void DrawArcFloat(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen= new Pen(Color.Black, 3);
             
    // Create coordinates of rectangle to bound ellipse.
    float x = 0.0F;
    float y = 0.0F;
    float width = 100.0F;
    float height = 200.0F;
             
    // Create start and sweep angles on ellipse.
    float startAngle =  45.0F;
    float sweepAngle = 270.0F;
             
    // Draw arc to screen.
    e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, sweepAngle);
}
Private Sub DrawArcFloat(ByVal e As PaintEventArgs)

    ' Create pen.
    Dim blackPen As New Pen(Color.Black, 3)

    ' Create coordinates of rectangle to bound ellipse.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single = 100.0F
    Dim height As Single = 200.0F

    ' Create start and sweep angles on ellipse.
    Dim startAngle As Single = 45.0F
    Dim sweepAngle As Single = 270.0F

    ' Draw arc to screen.
    e.Graphics.DrawArc(blackPen, x, y, width, height, startAngle, _
    sweepAngle)
End Sub

注解

此方法绘制一个弧线,它是椭圆外围的一部分。 椭圆由矩形的边界定义。 弧线是 startAngle 参数和 startAngle + sweepAngle 参数之间的椭圆的外围部分。

适用于