Graphics.DrawBezier 方法

定義

繪製由四個 Point 結構定義的貝茲曲線。

多載

DrawBezier(Pen, Point, Point, Point, Point)

繪製由四個 Point 結構定義的貝茲曲線。

DrawBezier(Pen, PointF, PointF, PointF, PointF)

繪製由四個 PointF 結構定義的貝茲曲線。

DrawBezier(Pen, Single, Single, Single, Single, Single, Single, Single, Single)

繪製貝茲曲線,該曲線是由表示各點的四個座標排序配對所定義。

DrawBezier(Pen, Point, Point, Point, Point)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

繪製由四個 Point 結構定義的貝茲曲線。

public:
 void DrawBezier(System::Drawing::Pen ^ pen, System::Drawing::Point pt1, System::Drawing::Point pt2, System::Drawing::Point pt3, System::Drawing::Point pt4);
public void DrawBezier (System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2, System.Drawing.Point pt3, System.Drawing.Point pt4);
member this.DrawBezier : System.Drawing.Pen * System.Drawing.Point * System.Drawing.Point * System.Drawing.Point * System.Drawing.Point -> unit
Public Sub DrawBezier (pen As Pen, pt1 As Point, pt2 As Point, pt3 As Point, pt4 As Point)

參數

pen
Pen

Pen 結構,決定曲線的色彩、寬度和樣式。

pt1
Point

Point 結構,表示曲線的開始點。

pt2
Point

Point 結構,表示曲線的第一個控制點。

pt3
Point

Point 結構,表示曲線的第二個控制點。

pt4
Point

Point 結構,表示曲線的結束點。

例外狀況

pennull

範例

下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立曲線的開始、結束和兩個控制點。

  • 將 Bézier 曲線繪製到螢幕。

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

      // Create points for curve.
      Point start = Point(100,100);
      Point control1 = Point(200,10);
      Point control2 = Point(350,50);
      Point end = Point(500,100);

      // Draw arc to screen.
      e->Graphics->DrawBezier( blackPen, start, control1, control2, end );
   }
private void DrawBezierPoint(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points for curve.
    Point start = new Point(100, 100);
    Point control1 = new Point(200, 10);
    Point control2 = new Point(350, 50);
    Point end = new Point(500, 100);
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, end);
}
Private Sub DrawBezierPoint(ByVal e As PaintEventArgs)

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

    ' Create points for curve.
    Dim start As New Point(100, 100)
    Dim control1 As New Point(200, 10)
    Dim control2 As New Point(350, 50)
    Dim [end] As New Point(500, 100)

    ' Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, [end])
End Sub

備註

Bézier 曲線是從第一個點繪製到第四個點。 第二和第三個點是決定曲線圖形的控制點。

適用於

DrawBezier(Pen, PointF, PointF, PointF, PointF)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

繪製由四個 PointF 結構定義的貝茲曲線。

public:
 void DrawBezier(System::Drawing::Pen ^ pen, System::Drawing::PointF pt1, System::Drawing::PointF pt2, System::Drawing::PointF pt3, System::Drawing::PointF pt4);
public void DrawBezier (System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2, System.Drawing.PointF pt3, System.Drawing.PointF pt4);
member this.DrawBezier : System.Drawing.Pen * System.Drawing.PointF * System.Drawing.PointF * System.Drawing.PointF * System.Drawing.PointF -> unit
Public Sub DrawBezier (pen As Pen, pt1 As PointF, pt2 As PointF, pt3 As PointF, pt4 As PointF)

參數

pen
Pen

Pen,決定曲線的色彩、寬度和樣式。

pt1
PointF

PointF 結構,表示曲線的開始點。

pt2
PointF

PointF 結構,表示曲線的第一個控制點。

pt3
PointF

PointF 結構,表示曲線的第二個控制點。

pt4
PointF

PointF 結構,表示曲線的結束點。

例外狀況

pennull

範例

下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立曲線的開始、結束和兩個控制點。

  • 將 Bézier 曲線繪製到螢幕。

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

      // Create points for curve.
      PointF start = PointF(100.0F,100.0F);
      PointF control1 = PointF(200.0F,10.0F);
      PointF control2 = PointF(350.0F,50.0F);
      PointF end = PointF(500.0F,100.0F);

      // Draw arc to screen.
      e->Graphics->DrawBezier( blackPen, start, control1, control2, end );
   }
private void DrawBezierPointF(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create points for curve.
    PointF start = new PointF(100.0F, 100.0F);
    PointF control1 = new PointF(200.0F, 10.0F);
    PointF control2 = new PointF(350.0F, 50.0F);
    PointF end = new PointF(500.0F, 100.0F);
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, end);
}
Private Sub DrawBezierPointF(ByVal e As PaintEventArgs)

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

    ' Create points for curve.
    Dim start As New PointF(100.0F, 100.0F)
    Dim control1 As New PointF(200.0F, 10.0F)
    Dim control2 As New PointF(350.0F, 50.0F)
    Dim [end] As New PointF(500.0F, 100.0F)

    ' Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, start, control1, control2, [end])
End Sub

備註

Bézier 曲線是從第一個點繪製到第四個點。 第二和第三個點是決定曲線圖形的控制點。

適用於

DrawBezier(Pen, Single, Single, Single, Single, Single, Single, Single, Single)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

繪製貝茲曲線,該曲線是由表示各點的四個座標排序配對所定義。

public:
 void DrawBezier(System::Drawing::Pen ^ pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
public void DrawBezier (System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
member this.DrawBezier : System.Drawing.Pen * single * single * single * single * single * single * single * single -> unit
Public Sub DrawBezier (pen As Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single)

參數

pen
Pen

Pen,決定曲線的色彩、寬度和樣式。

x1
Single

曲線開始點的 X 軸座標。

y1
Single

曲線開始點的 Y 軸座標。

x2
Single

曲線第一個控制點的 X 座標。

y2
Single

曲線第一個控制點的 Y 座標。

x3
Single

曲線第二個控制點的 X 座標。

y3
Single

曲線第二個控制點的 Y 座標。

x4
Single

曲線結束點的 X 座標。

y4
Single

曲線結束點的 Y 座標。

例外狀況

pennull

範例

下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:

  • 建立黑色畫筆。

  • 建立曲線的開始、結束和兩個控制點座標。

  • 將 Bézier 曲線繪製到螢幕。

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

      // Create coordinates of points for curve.
      float startX = 100.0F;
      float startY = 100.0F;
      float controlX1 = 200.0F;
      float controlY1 = 10.0F;
      float controlX2 = 350.0F;
      float controlY2 = 50.0F;
      float endX = 500.0F;
      float endY = 100.0F;

      // Draw arc to screen.
      e->Graphics->DrawBezier( blackPen, startX, startY, controlX1, controlY1, controlX2, controlY2, endX, endY );
   }
private void DrawBezierFloat(PaintEventArgs e)
{
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Create coordinates of points for curve.
    float startX = 100.0F;
    float startY = 100.0F;
    float controlX1 = 200.0F;
    float controlY1 =  10.0F;
    float controlX2 = 350.0F;
    float controlY2 =  50.0F;
    float endX = 500.0F;
    float endY = 100.0F;
             
    // Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, startX, startY,
        controlX1, controlY1,
        controlX2, controlY2,
        endX, endY);
}

' Begin Example03.
Private Sub DrawBezierFloat(ByVal e As PaintEventArgs)

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

    ' Create coordinates of points for curve.
    Dim startX As Single = 100.0F
    Dim startY As Single = 100.0F
    Dim controlX1 As Single = 200.0F
    Dim controlY1 As Single = 10.0F
    Dim controlX2 As Single = 350.0F
    Dim controlY2 As Single = 50.0F
    Dim endX As Single = 500.0F
    Dim endY As Single = 100.0F

    ' Draw arc to screen.
    e.Graphics.DrawBezier(blackPen, startX, startY, controlX1, _
    controlY1, controlX2, controlY2, endX, endY)
End Sub

備註

Bézier 曲線是從第一個點繪製到第四個點。 第二和第三個點是決定曲線圖形的控制點。

適用於