Rediger

Del via


GraphicsPath.AddPolygon Method

Definition

Adds a polygon to this path.

Overloads

AddPolygon(ReadOnlySpan<Point>)

Adds a polygon to this path.

AddPolygon(Point[])

Adds a polygon to this path.

AddPolygon(PointF[])

Adds a polygon to this path.

AddPolygon(ReadOnlySpan<PointF>)

Adds a polygon to this path.

AddPolygon(ReadOnlySpan<Point>)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Adds a polygon to this path.

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))

Parameters

points
ReadOnlySpan<Point>

An array of Point structures that defines the polygon to add.

Applies to

AddPolygon(Point[])

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Adds a polygon to this path.

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

Parameters

points
Point[]

An array of Point structures that defines the polygon to add.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates an array of points that defines a polygon.

  • Creates a path and adds the polygon to the path.

  • Draws the path to the screen.

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

Remarks

The points in the points array specify the vertices of a polygon. If the first point in the array is not the same as the last point, those two points are connected to close the polygon.

Applies to

AddPolygon(PointF[])

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Adds a polygon to this path.

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

Parameters

points
PointF[]

An array of PointF structures that defines the polygon to add.

Examples

For an example, see AddPolygon(Point[]).

Remarks

The points in the points array specify the vertices of a polygon. If the first point in the array is not the same as the last point, those two points are connected to close the polygon.

Applies to

AddPolygon(ReadOnlySpan<PointF>)

Source:
GraphicsPath.cs
Source:
GraphicsPath.cs

Adds a polygon to this path.

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))

Parameters

points
ReadOnlySpan<PointF>

An array of Point structures that defines the polygon to add.

Applies to