Graphics.FillPolygon 方法

定義

填滿由 Point 結構所指定點數位所定義的多邊形內部。

多載

FillPolygon(Brush, ReadOnlySpan<PointF>, FillMode)
FillPolygon(Brush, ReadOnlySpan<Point>, FillMode)
FillPolygon(Brush, PointF[], FillMode)

使用指定的填滿模式,填滿由 PointF 結構所指定之點陣列所定義的多邊形內部。

FillPolygon(Brush, Point[], FillMode)

使用指定的填滿模式,填滿由 Point 結構所指定之點陣列所定義的多邊形內部。

FillPolygon(Brush, ReadOnlySpan<Point>)
FillPolygon(Brush, PointF[])

填滿由 PointF 結構所指定點數位所定義的多邊形內部。

FillPolygon(Brush, Point[])

填滿由 Point 結構所指定點數位所定義的多邊形內部。

FillPolygon(Brush, ReadOnlySpan<PointF>)

FillPolygon(Brush, ReadOnlySpan<PointF>, FillMode)

來源:
Graphics.cs
來源:
Graphics.cs
public void FillPolygon (System.Drawing.Brush brush, ReadOnlySpan<System.Drawing.PointF> points, System.Drawing.Drawing2D.FillMode fillMode);

參數

brush
Brush
fillMode
FillMode

適用於

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

FillPolygon(Brush, ReadOnlySpan<Point>, FillMode)

來源:
Graphics.cs
來源:
Graphics.cs
public void FillPolygon (System.Drawing.Brush brush, ReadOnlySpan<System.Drawing.Point> points, System.Drawing.Drawing2D.FillMode fillMode);

參數

brush
Brush
fillMode
FillMode

適用於

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

FillPolygon(Brush, PointF[], FillMode)

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

使用指定的填滿模式,填滿由 PointF 結構所指定之點陣列所定義的多邊形內部。

public void FillPolygon (System.Drawing.Brush brush, System.Drawing.PointF[] points, System.Drawing.Drawing2D.FillMode fillMode);

參數

brush
Brush

決定填滿特性的 Brush

points
PointF[]

PointF 結構的陣列,代表要填滿之多邊形的頂點。

fillMode
FillMode

決定填滿樣式之 FillMode 列舉的成員。

例外狀況

brush null

-或-

points null

範例

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

  • 建立純藍色筆刷。

  • 建立七個點的陣列,以定義多邊形。

  • 將填滿模式設定為 Winding

  • 填滿螢幕上的多邊形區域。

public void FillPolygonPointFFillMode(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create points that define polygon.
    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};

    // Define fill mode.
    FillMode newFillMode = FillMode.Winding;

    // Fill polygon to screen.
    e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode);
}

備註

陣列中每兩個連續點都會指定多邊形的一側。 此外,如果最後一個點和第一個點不相吻合,則會指定多邊形的結尾。

適用於

.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

FillPolygon(Brush, Point[], FillMode)

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

使用指定的填滿模式,填滿由 Point 結構所指定之點陣列所定義的多邊形內部。

public void FillPolygon (System.Drawing.Brush brush, System.Drawing.Point[] points, System.Drawing.Drawing2D.FillMode fillMode);

參數

brush
Brush

決定填滿特性的 Brush

points
Point[]

Point 結構的陣列,代表要填滿之多邊形的頂點。

fillMode
FillMode

決定填滿樣式之 FillMode 列舉的成員。

例外狀況

brush null

-或-

points null

範例

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

  • 建立純藍色筆刷。

  • 建立七個點的陣列,以定義多邊形。

  • 將填滿模式設定為 Winding

  • 填滿螢幕上的多邊形區域。

public void FillPolygonPointFillMode(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create points that define polygon.
    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};

    // Define fill mode.
    FillMode newFillMode = FillMode.Winding;

    // Draw polygon to screen.
    e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode);
}

備註

陣列中每兩個連續點都會指定多邊形的一側。 此外,如果最後一個點和第一個點不相吻合,則會指定多邊形的結尾。

適用於

.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

FillPolygon(Brush, ReadOnlySpan<Point>)

來源:
Graphics.cs
來源:
Graphics.cs
public void FillPolygon (System.Drawing.Brush brush, scoped ReadOnlySpan<System.Drawing.Point> points);

參數

brush
Brush

適用於

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

FillPolygon(Brush, PointF[])

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

填滿由 PointF 結構所指定點數位所定義的多邊形內部。

public void FillPolygon (System.Drawing.Brush brush, System.Drawing.PointF[] points);
public void FillPolygon (System.Drawing.Brush brush, params System.Drawing.PointF[] points);

參數

brush
Brush

決定填滿特性的 Brush

points
PointF[]

PointF 結構的陣列,代表要填滿之多邊形的頂點。

例外狀況

brush null

-或-

points null

範例

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

  • 建立純藍色筆刷。

  • 建立七個點的陣列,以定義多邊形。

  • 填滿螢幕上的多邊形區域。

public void FillPolygonPointF(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create points that define polygon.
    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};

    // Fill polygon to screen.
    e.Graphics.FillPolygon(blueBrush, curvePoints);
}

備註

陣列中每兩個連續點都會指定多邊形的一側。 此外,如果最後一個點和第一個點不相吻合,則會指定多邊形的結尾。

適用於

.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

FillPolygon(Brush, Point[])

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

填滿由 Point 結構所指定點數位所定義的多邊形內部。

public void FillPolygon (System.Drawing.Brush brush, System.Drawing.Point[] points);

參數

brush
Brush

決定填滿特性的 Brush

points
Point[]

Point 結構的陣列,代表要填滿之多邊形的頂點。

例外狀況

brush null

-或-

points null

範例

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

  • 建立純藍色筆刷。

  • 建立七個點的陣列,以定義多邊形。

  • 填滿螢幕上的多邊形區域。

public void FillPolygonPoint(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create points that define polygon.
    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 polygon to screen.
    e.Graphics.FillPolygon(blueBrush, curvePoints);
}

備註

陣列中每兩個連續點都會指定多邊形的一側。 此外,如果最後一個點和第一個點不相吻合,則會指定多邊形的結尾。

適用於

.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

FillPolygon(Brush, ReadOnlySpan<PointF>)

來源:
Graphics.cs
來源:
Graphics.cs
public void FillPolygon (System.Drawing.Brush brush, scoped ReadOnlySpan<System.Drawing.PointF> points);

參數

brush
Brush

適用於

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