Graphics.DrawClosedCurve 方法

定義

繪製由 Point 結構數位定義的封閉基數曲線。

多載

DrawClosedCurve(Pen, ReadOnlySpan<Point>, Single, FillMode)
DrawClosedCurve(Pen, PointF[], Single, FillMode)

使用指定的緊張,繪製由 PointF 結構陣列所定義的封閉基數曲線。

DrawClosedCurve(Pen, Point[], Single, FillMode)

使用指定的緊張,繪製由 Point 結構陣列所定義的封閉基數曲線。

DrawClosedCurve(Pen, ReadOnlySpan<PointF>, Single, FillMode)
DrawClosedCurve(Pen, ReadOnlySpan<Point>)
DrawClosedCurve(Pen, Point[])

繪製由 Point 結構數位定義的封閉基數曲線。

DrawClosedCurve(Pen, ReadOnlySpan<PointF>)
DrawClosedCurve(Pen, PointF[])

繪製由 PointF 結構數位定義的封閉基數曲線。

DrawClosedCurve(Pen, ReadOnlySpan<Point>, Single, FillMode)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawClosedCurve (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.Point> points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

參數

pen
Pen
tension
Single
fillmode
FillMode

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawClosedCurve(Pen, PointF[], Single, FillMode)

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

使用指定的緊張,繪製由 PointF 結構陣列所定義的封閉基數曲線。

C#
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

參數

pen
Pen

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

points
PointF[]

定義曲線之 PointF 結構的數位。

tension
Single

大於或等於 0.0F 的值,指定曲線的緊張度。

fillmode
FillMode

決定曲線填滿方式之 FillMode 列舉的成員。 這是必要參數,但會被忽略。

例外狀況

pen null

-或-

points null

範例

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

  • 建立紅色和綠色的畫筆。

  • 建立七個點來定義曲線。

  • 在七點之間繪製七條紅色直線,以形成多邊形。

  • 建立緊張和填滿模式設定。

  • 透過七點繪製綠色封閉曲線。

方法會使用 1.0 的緊張,並將填滿模式設定為 FillMode.Alternate

C#
private void DrawClosedCurvePointFTension(PaintEventArgs e)
{

    // Create pens.
    Pen redPen = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);

    // Create points that define curve.
    PointF point1 = new PointF(50.0F, 50.0F);
    PointF point2 = new PointF(100.0F, 25.0F);
    PointF point3 = new PointF(200.0F, 5.0F);
    PointF point4 = new PointF(250.0F, 50.0F);
    PointF point5 = new PointF(300.0F, 100.0F);
    PointF point6 = new PointF(350.0F, 200.0F);
    PointF point7 = new PointF(250.0F, 250.0F);
    PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

    // Draw lines between original points to screen.
    e.Graphics.DrawLines(redPen, curvePoints);

    // Create tension and fill mode.
    float tension = 1.0F;
    FillMode aFillMode = FillMode.Alternate;

    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, aFillMode);
}

備註

這個方法會繪製封閉的基數曲線,該曲線會通過數位中的每個點。 如果最後一個點不符合第一個點,則會從最後一個點新增到第一個點以關閉它的額外曲線線段。

點陣陣必須至少包含四個 PointF 結構。

tension 參數會決定曲線的形狀。 如果 tension 參數的值是 0.0F,這個方法會繪製直線線段來連接點。 通常,tension 參數小於或等於1.0F。 超過 1.0F 的值會產生不尋常的結果。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, Point[], Single, FillMode)

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

使用指定的緊張,繪製由 Point 結構陣列所定義的封閉基數曲線。

C#
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.Point[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

參數

pen
Pen

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

points
Point[]

定義曲線之 Point 結構的數位。

tension
Single

大於或等於 0.0F 的值,指定曲線的緊張度。

fillmode
FillMode

決定曲線填滿方式之 FillMode 列舉的成員。 這是必要參數,但會被忽略。

例外狀況

pen null

-或-

points null

範例

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

  • 建立紅色和綠色的畫筆。

  • 建立七個點來定義曲線。

  • 在七點之間繪製七條紅色直線,以形成多邊形。

  • 建立緊張和填滿模式設定。

  • 透過七點繪製綠色封閉曲線。

方法會使用 1.0 的緊張,並將填滿模式設定為 FillMode.Alternate

C#
private void DrawClosedCurvePointTension(PaintEventArgs e)
{

    // Create pens.
    Pen redPen = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);

    // Create points that define curve.
    Point point1 = new Point(50, 50);
    Point point2 = new Point(100, 25);
    Point point3 = new Point(200, 5);
    Point point4 = new Point(250, 50);
    Point point5 = new Point(300, 100);
    Point point6 = new Point(350, 200);
    Point point7 = new Point(250, 250);
    Point[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

    // Draw lines between original points to screen.
    e.Graphics.DrawLines(redPen, curvePoints);

    // Create tension and fill mode.
    float tension = 1.0F;
    FillMode aFillMode = FillMode.Alternate;

    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints, tension, aFillMode);
}

備註

這個方法會繪製封閉的基數曲線,該曲線會通過數位中的每個點。 如果最後一個點不符合第一個點,則會從最後一個點新增到第一個點以關閉它的額外曲線線段。

點陣陣必須至少包含四個 Point 結構。

tension 參數會決定曲線的形狀。 如果 tension 參數的值是 0.0F,這個方法會繪製直線線段來連接點。 通常,tension 參數小於或等於1.0F。 超過 1.0F 的值會產生不尋常的結果。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, ReadOnlySpan<PointF>, Single, FillMode)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawClosedCurve (System.Drawing.Pen pen, ReadOnlySpan<System.Drawing.PointF> points, float tension, System.Drawing.Drawing2D.FillMode fillmode);

參數

pen
Pen
tension
Single
fillmode
FillMode

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawClosedCurve(Pen, ReadOnlySpan<Point>)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawClosedCurve (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.Point> points);

參數

pen
Pen

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawClosedCurve(Pen, Point[])

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

繪製由 Point 結構數位定義的封閉基數曲線。

C#
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.Point[] points);
C#
public void DrawClosedCurve (System.Drawing.Pen pen, params System.Drawing.Point[] points);

參數

pen
Pen

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

points
Point[]

定義曲線之 Point 結構的數位。

例外狀況

pen null

-或-

points null

範例

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

  • 建立紅色和綠色的畫筆。

  • 建立七個點來定義曲線。

  • 在七點之間繪製七條紅色直線,形成封閉的多邊形。

  • 透過七點繪製綠色封閉曲線。

方法會使用預設的緊張度 0.5。

C#
private void DrawClosedCurvePoint(PaintEventArgs e)
{
    // Create pens.
    Pen redPen   = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);
             
    // Create points that define curve.
    Point point1 = new Point(50,  50);
    Point point2 = new Point(100,  25);
    Point point3 = new Point(200,   5);
    Point point4 = new Point(250,  50);
    Point point5 = new Point(300, 100);
    Point point6 = new Point(350, 200);
    Point point7 = new Point(250, 250);
    Point[] curvePoints =
             {
                 point1,
                 point2,
                 point3,
                 point4,
                 point5,
                 point6,
                 point7
             };
             
    // Draw lines between original points to screen.
    e.Graphics.DrawLines(redPen, curvePoints);
             
    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints);
}

備註

這個方法會繪製封閉的基數曲線,該曲線會通過數位中的每個點。 如果最後一個點不符合第一個點,則會從最後一個點新增到第一個點以關閉圖形的額外曲線線段。

點陣陣必須至少包含四個 Point 結構。

此方法使用預設的緊張度 0.5。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawClosedCurve(Pen, ReadOnlySpan<PointF>)

來源:
Graphics.cs
來源:
Graphics.cs
C#
public void DrawClosedCurve (System.Drawing.Pen pen, scoped ReadOnlySpan<System.Drawing.PointF> points);

參數

pen
Pen

適用於

.NET 9 和 Windows Desktop 9
產品 版本
.NET 9
Windows Desktop 9

DrawClosedCurve(Pen, PointF[])

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

繪製由 PointF 結構數位定義的封閉基數曲線。

C#
public void DrawClosedCurve (System.Drawing.Pen pen, System.Drawing.PointF[] points);
C#
public void DrawClosedCurve (System.Drawing.Pen pen, params System.Drawing.PointF[] points);

參數

pen
Pen

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

points
PointF[]

定義曲線之 PointF 結構的數位。

例外狀況

pen null

-或-

points null

範例

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

  • 建立紅色和綠色的畫筆。

  • 建立七個點來定義曲線。

  • 在七點之間繪製七條紅色直線,形成封閉的多邊形。

  • 透過七點繪製綠色封閉曲線。

方法會使用預設的緊張度 0.5。

C#
private void DrawClosedCurvePointF(PaintEventArgs e)
{

    // Create pens.
    Pen redPen = new Pen(Color.Red, 3);
    Pen greenPen = new Pen(Color.Green, 3);

    // Create points that define curve.
    PointF point1 = new PointF(50.0F, 50.0F);
    PointF point2 = new PointF(100.0F, 25.0F);
    PointF point3 = new PointF(200.0F, 5.0F);
    PointF point4 = new PointF(250.0F, 50.0F);
    PointF point5 = new PointF(300.0F, 100.0F);
    PointF point6 = new PointF(350.0F, 200.0F);
    PointF point7 = new PointF(250.0F, 250.0F);
    PointF[] curvePoints = {point1, point2, point3, point4, point5, point6, point7};

    // Draw lines between original points to screen.
    e.Graphics.DrawLines(redPen, curvePoints);

    // Draw closed curve to screen.
    e.Graphics.DrawClosedCurve(greenPen, curvePoints);
}

備註

這個方法會繪製封閉的基數曲線,該曲線會通過數位中的每個點。 如果最後一個點不符合第一個點,則會從最後一個點新增到第一個點以關閉它的額外曲線線段。

點陣陣必須至少包含四個 PointF 結構。

此方法使用預設的緊張度 0.5。

適用於

.NET 9 和其他版本
產品 版本
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9