共用方式為


如何:繪製一連串的貝茲曲線

您可以使用 Graphics 類別的 DrawBeziers 方法來繪製一連串相連的 Bézier 曲線。

範例

下列範例會繪製由兩個相連的 Bézier 曲線組成的曲線。 第一個 Bézier 曲線的端點是第二個 Bézier 曲線的起點。

下圖顯示相連的曲線以及七個點:

顯示相連的曲線以及七個點的圖形。

Point[] p = {
   new Point(10, 100),   // start point of first spline
   new Point(75, 10),    // first control point of first spline
   new Point(80, 50),    // second control point of first spline

   new Point(100, 150),  // endpoint of first spline and
                         // start point of second spline

   new Point(125, 80),   // first control point of second spline
   new Point(175, 200),  // second control point of second spline
   new Point(200, 80)};  // endpoint of second spline

Pen pen = new Pen(Color.Blue);
e.Graphics.DrawBeziers(pen, p);

' Point(10, 100) = start point of first spline
' Point(75, 10) = first control point of first spline
' Point(80, 50) = second control point of first spline

' Point(100, 150) = endpoint of first spline and start point of second spline

' Point(125, 80) = first control point of second spline
' Point(175, 200) = second control point of second spline
' Point(200, 80)} = endpoint of second spline
Dim p As Point() = { _
       New Point(10, 100), _
       New Point(75, 10), _
       New Point(80, 50), _
       New Point(100, 150), _
       New Point(125, 80), _
       New Point(175, 200), _
       New Point(200, 80)}

Dim pen As New Pen(Color.Blue)
e.Graphics.DrawBeziers(pen, p)

編譯程式碼

上述範例是為了搭配 Windows Forms 使用而設計,且其需要 PaintEventArgse,這是 Paint 事件處理常式的參數。

另請參閱