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
Source:
GraphicsPath.cs

Adds a polygon to this path.

C#
public void AddPolygon(scoped ReadOnlySpan<System.Drawing.Point> points);

Parameters

points
ReadOnlySpan<Point>

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

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 9 (package-provided), 10 (package-provided)
Windows Desktop 9, 10

AddPolygon(Point[])

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

Adds a polygon to this path.

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

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.

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

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

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.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 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

AddPolygon(PointF[])

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

Adds a polygon to this path.

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

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

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.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 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

AddPolygon(ReadOnlySpan<PointF>)

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

Adds a polygon to this path.

C#
public void AddPolygon(scoped ReadOnlySpan<System.Drawing.PointF> points);

Parameters

points
ReadOnlySpan<PointF>

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

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 9 (package-provided), 10 (package-provided)
Windows Desktop 9, 10