共用方式為


GraphicsPath.AddPolygon 方法

定義

將多邊形新增至此路徑。

多載

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

將多邊形新增至此路徑。

AddPolygon(PointF[])

將多邊形新增至此路徑。

AddPolygon(ReadOnlySpan<PointF>)

AddPolygon(ReadOnlySpan<Point>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
public:
 void AddPolygon(ReadOnlySpan<System::Drawing::Point> points);
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.Point> points);
member this.AddPolygon : ReadOnlySpan<System.Drawing.Point> -> unit
Public Sub AddPolygon (points As ReadOnlySpan(Of Point))

參數

適用於

AddPolygon(Point[])

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

將多邊形新增至此路徑。

public:
 void AddPolygon(cli::array <System::Drawing::Point> ^ points);
public:
 void AddPolygon(... cli::array <System::Drawing::Point> ^ points);
public void AddPolygon (System.Drawing.Point[] points);
public void AddPolygon (params System.Drawing.Point[] points);
member this.AddPolygon : System.Drawing.Point[] -> unit
Public Sub AddPolygon (points As Point())
Public Sub AddPolygon (ParamArray points As Point())

參數

points
Point[]

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

範例

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

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

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

  • 繪製畫面的路徑。

private:
   void AddPolygonExample( PaintEventArgs^ e )
   {
      // Create an array of points.
      array<Point>^ myArray = {Point(23,20),Point(40,10),Point(57,20),Point(50,40),Point(30,40)};

      // Create a GraphicsPath object and add a polygon.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      myPath->AddPolygon( myArray );

      // Draw the path to the screen.
      Pen^ myPen = gcnew Pen( Color::Black,2.0f );
      e->Graphics->DrawPath( myPen, myPath );
   }
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);
}
Public Sub AddPolygonExample(ByVal e As PaintEventArgs)

    ' Create an array of points.
    Dim myArray As Point() = {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.
    Dim myPath As New GraphicsPath
    myPath.AddPolygon(myArray)

    ' Draw the path to the screen.
    Dim myPen As New Pen(Color.Black, 2)
    e.Graphics.DrawPath(myPen, myPath)
End Sub

備註

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

適用於

AddPolygon(PointF[])

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

將多邊形新增至此路徑。

public:
 void AddPolygon(cli::array <System::Drawing::PointF> ^ points);
public:
 void AddPolygon(... cli::array <System::Drawing::PointF> ^ points);
public void AddPolygon (System.Drawing.PointF[] points);
public void AddPolygon (params System.Drawing.PointF[] points);
member this.AddPolygon : System.Drawing.PointF[] -> unit
Public Sub AddPolygon (points As PointF())
Public Sub AddPolygon (ParamArray points As PointF())

參數

points
PointF[]

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

範例

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

備註

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

適用於

AddPolygon(ReadOnlySpan<PointF>)

來源:
GraphicsPath.cs
來源:
GraphicsPath.cs
public:
 void AddPolygon(ReadOnlySpan<System::Drawing::PointF> points);
public void AddPolygon (scoped ReadOnlySpan<System.Drawing.PointF> points);
member this.AddPolygon : ReadOnlySpan<System.Drawing.PointF> -> unit
Public Sub AddPolygon (points As ReadOnlySpan(Of PointF))

參數

適用於