GraphicsPath.AddPolygon 方法

定義

將多邊形新增至此路徑。

多載

AddPolygon(ReadOnlySpan<Point>)
AddPolygon(Point[])

將多邊形新增至此路徑。

AddPolygon(PointF[])

將多邊形新增至此路徑。

AddPolygon(ReadOnlySpan<PointF>)

AddPolygon(ReadOnlySpan<Point>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
C#
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.Point> points);

參數

適用於

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

AddPolygon(Point[])

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs

將多邊形新增至此路徑。

C#
public void AddPolygon (System.Drawing.Point[] points);
C#
public void AddPolygon (params System.Drawing.Point[] points);

參數

points
Point[]

Point 結構的陣列,定義要加入的多邊形。

範例

下列程式代碼範例的設計目的是要與 Windows Forms 搭配使用,而且需要 PaintEventArgseOnPaint 事件物件。 程式代碼會執行下列動作:

  • 建立定義多邊形的點陣列。

  • 建立路徑,並將多邊形新增至路徑。

  • 繪製畫面的路徑。

C#
private void AddPolygonExample(PaintEventArgs e)
{
             
    // Create an array of points.
    Point[] myArray =
             {
                 new Point(23, 20),
                 new Point(40, 10),
                 new Point(57, 20),
                 new Point(50, 40),
                 new Point(30, 40)
             };
             
    // Create a GraphicsPath object and add a polygon.
    GraphicsPath myPath = new GraphicsPath();
    myPath.AddPolygon(myArray);
             
    // Draw the path to the screen.
    Pen myPen = new Pen(Color.Black, 2);
    e.Graphics.DrawPath(myPen, myPath);
}

備註

points 陣列中的點會指定多邊形的頂點。 如果陣列中的第一個點與最後一個點不同,這兩個點會連線到關閉多邊形。

適用於

.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

AddPolygon(PointF[])

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
來源:
GraphicsPath.cs

將多邊形新增至此路徑。

C#
public void AddPolygon (System.Drawing.PointF[] points);
C#
public void AddPolygon (params System.Drawing.PointF[] points);

參數

points
PointF[]

PointF 結構的陣列,定義要加入的多邊形。

範例

如需範例,請參閱 AddPolygon(Point[])

備註

points 陣列中的點會指定多邊形的頂點。 如果陣列中的第一個點與最後一個點不同,這兩個點會連線到關閉多邊形。

適用於

.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

AddPolygon(ReadOnlySpan<PointF>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
C#
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.PointF> points);

參數

適用於

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