Graphics.DrawEllipse 方法

定义

绘制一个由边框(该边框由一对坐标、高度和宽度指定)定义的椭圆。

重载

DrawEllipse(Pen, Int32, Int32, Int32, Int32)

绘制一个由边框定义的椭圆,该边框由矩形的左上角坐标、高度和宽度指定。

DrawEllipse(Pen, Single, Single, Single, Single)

绘制一个由边框(该边框由一对坐标、高度和宽度指定)定义的椭圆。

DrawEllipse(Pen, RectangleF)

绘制边界 RectangleF 定义的椭圆。

DrawEllipse(Pen, Rectangle)

绘制边界 Rectangle 结构指定的椭圆。

DrawEllipse(Pen, Int32, Int32, Int32, Int32)

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

绘制一个由边框定义的椭圆,该边框由矩形的左上角坐标、高度和宽度指定。

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

参数

pen
Pen

Pen,它确定曲线的颜色、宽度和样式。

x
Int32

定义椭圆的边框的左上角的 X 坐标。

y
Int32

定义椭圆的边框的左上角的 Y 坐标。

width
Int32

定义椭圆的边框的宽度。

height
Int32

定义椭圆的边框的高度。

例外

pennull

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建黑色笔。

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

  • 将椭圆绘制到屏幕。

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

      // Create location and size of ellipse.
      int x = 0;
      int y = 0;
      int width = 200;
      int height = 100;

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, x, y, width, height );
   }
private void DrawEllipseInt(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of ellipse.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 100;
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height);
}
Private Sub DrawEllipseInt(ByVal e As PaintEventArgs)

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

    ' Create location and size of ellipse.
    Dim x As Integer = 0
    Dim y As Integer = 0
    Dim width As Integer = 200
    Dim height As Integer = 100

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height)
End Sub

注解

此方法绘制由 、、 ywidthheight 参数描述x的边界矩形定义的椭圆。

适用于

DrawEllipse(Pen, Single, Single, Single, Single)

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

绘制一个由边框(该边框由一对坐标、高度和宽度指定)定义的椭圆。

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

参数

pen
Pen

Pen,它确定曲线的颜色、宽度和样式。

x
Single

定义椭圆的边框的左上角的 X 坐标。

y
Single

定义椭圆的边框的左上角的 Y 坐标。

width
Single

定义椭圆的边框的宽度。

height
Single

定义椭圆的边框的高度。

例外

pennull

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建黑色笔。

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

  • 将椭圆绘制到屏幕。

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

      // Create location and size of ellipse.
      float x = 0.0F;
      float y = 0.0F;
      float width = 200.0F;
      float height = 100.0F;

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, x, y, width, height );
   }
private void DrawEllipseFloat(PaintEventArgs e)
{         
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create location and size of ellipse.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 100.0F;
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height);
}
Private Sub DrawEllipseFloat(ByVal e As PaintEventArgs)

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

    ' Create location and size of ellipse.
    Dim x As Single = 0.0F
    Dim y As Single = 0.0F
    Dim width As Single = 200.0F
    Dim height As Single = 100.0F

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, x, y, width, height)
End Sub

注解

此方法绘制由 、、 ywidthheight 参数描述x的边界矩形定义的椭圆。

适用于

DrawEllipse(Pen, RectangleF)

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

绘制边界 RectangleF 定义的椭圆。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, System::Drawing::RectangleF rect);
public void DrawEllipse (System.Drawing.Pen pen, System.Drawing.RectangleF rect);
member this.DrawEllipse : System.Drawing.Pen * System.Drawing.RectangleF -> unit
Public Sub DrawEllipse (pen As Pen, rect As RectangleF)

参数

pen
Pen

Pen,它确定曲线的颜色、宽度和样式。

rect
RectangleF

RectangleF 结构,它定义椭圆的边界。

例外

pennull

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建黑色笔。

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

  • 将椭圆绘制到屏幕。

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

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

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, rect );
   }
private void DrawEllipseRectangleF(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle for ellipse.
    RectangleF rect = new RectangleF(0.0F, 0.0F, 200.0F, 100.0F);
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect);
}
Private Sub DrawEllipseRectangleF(ByVal e As PaintEventArgs)

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

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

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect)
End Sub

注解

此方法绘制由 参数指定的 rect 边框定义的椭圆。

适用于

DrawEllipse(Pen, Rectangle)

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

绘制边界 Rectangle 结构指定的椭圆。

public:
 void DrawEllipse(System::Drawing::Pen ^ pen, System::Drawing::Rectangle rect);
public void DrawEllipse (System.Drawing.Pen pen, System.Drawing.Rectangle rect);
member this.DrawEllipse : System.Drawing.Pen * System.Drawing.Rectangle -> unit
Public Sub DrawEllipse (pen As Pen, rect As Rectangle)

参数

pen
Pen

Pen,它确定曲线的颜色、宽度和样式。

rect
Rectangle

Rectangle 结构,它定义椭圆的边界。

例外

pennull

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建黑色笔。

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

  • 将椭圆绘制到屏幕。

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

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

      // Draw ellipse to screen.
      e->Graphics->DrawEllipse( blackPen, rect );
   }
private void DrawEllipseRectangle(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create rectangle for ellipse.
    Rectangle rect = new Rectangle(0, 0, 200, 100);
             
    // Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect);
}
Private Sub DrawEllipseRectangle(ByVal e As PaintEventArgs)

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

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

    ' Draw ellipse to screen.
    e.Graphics.DrawEllipse(blackPen, rect)
End Sub

注解

此方法绘制由 参数指定的 rect 边框定义的椭圆。

适用于