Graphics.FillPolygon Method

Definition

Fills the interior of a polygon defined by an array of points specified by Point structures.

Overloads

FillPolygon(Brush, ReadOnlySpan<PointF>, FillMode)

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

FillPolygon(Brush, ReadOnlySpan<Point>, FillMode)

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

FillPolygon(Brush, PointF[], FillMode)

Fills the interior of a polygon defined by an array of points specified by PointF structures using the specified fill mode.

FillPolygon(Brush, Point[], FillMode)

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

FillPolygon(Brush, ReadOnlySpan<Point>)

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

FillPolygon(Brush, PointF[])

Fills the interior of a polygon defined by an array of points specified by PointF structures.

FillPolygon(Brush, Point[])

Fills the interior of a polygon defined by an array of points specified by Point structures.

FillPolygon(Brush, ReadOnlySpan<PointF>)

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

FillPolygon(Brush, ReadOnlySpan<PointF>, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

C#
public void FillPolygon(System.Drawing.Brush brush, ReadOnlySpan<System.Drawing.PointF> points, System.Drawing.Drawing2D.FillMode fillMode);

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
ReadOnlySpan<PointF>

Array of Point structures that represent the vertices of the polygon to fill.

fillMode
FillMode

Member of the FillMode enumeration that determines the style of the fill.

Applies to

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

FillPolygon(Brush, ReadOnlySpan<Point>, FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

C#
public void FillPolygon(System.Drawing.Brush brush, ReadOnlySpan<System.Drawing.Point> points, System.Drawing.Drawing2D.FillMode fillMode);

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
ReadOnlySpan<Point>

Array of Point structures that represent the vertices of the polygon to fill.

fillMode
FillMode

Member of the FillMode enumeration that determines the style of the fill.

Applies to

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

FillPolygon(Brush, PointF[], FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by PointF structures using the specified fill mode.

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

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
PointF[]

Array of PointF structures that represent the vertices of the polygon to fill.

fillMode
FillMode

Member of the FillMode enumeration that determines the style of the fill.

Exceptions

brush is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following action:

  • Creates a solid blue brush.

  • Creates an array of seven points to define a polygon.

  • Sets the fill mode to Winding.

  • Fills the polygonal area on the screen.

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

Remarks

Every two consecutive points in the array specify a side of the polygon. In addition, if the last point and the first point do not coincide, they specify the closing side of 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

FillPolygon(Brush, Point[], FillMode)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

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

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
Point[]

Array of Point structures that represent the vertices of the polygon to fill.

fillMode
FillMode

Member of the FillMode enumeration that determines the style of the fill.

Exceptions

brush is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a solid blue brush.

  • Creates an array of seven points to define a polygon.

  • Sets the fill mode to Winding.

  • Fills the polygonal area on the screen.

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

Remarks

Every two consecutive points in the array specify a side of the polygon. In addition, if the last point and the first point do not coincide, they specify the closing side of 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

FillPolygon(Brush, ReadOnlySpan<Point>)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

C#
public void FillPolygon(System.Drawing.Brush brush, scoped ReadOnlySpan<System.Drawing.Point> points);

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
ReadOnlySpan<Point>

Array of Point structures that represent the vertices of the polygon to fill.

Applies to

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

FillPolygon(Brush, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by PointF structures.

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

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
PointF[]

Array of PointF structures that represent the vertices of the polygon to fill.

Exceptions

brush is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a solid blue brush.

  • Creates an array of seven points to define a polygon.

  • Fills the polygonal area on the screen.

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

Remarks

Every two consecutive points in the array specify a side of the polygon. In addition, if the last point and the first point do not coincide, they specify the closing side of 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

FillPolygon(Brush, Point[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures.

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

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
Point[]

Array of Point structures that represent the vertices of the polygon to fill.

Exceptions

brush is null.

-or-

points is null.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a solid blue brush.

  • Creates an array of seven points to define a polygon.

  • Fills the polygonal area on the screen.

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

Remarks

Every two consecutive points in the array specify a side of the polygon. In addition, if the last point and the first point do not coincide, they specify the closing side of 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

FillPolygon(Brush, ReadOnlySpan<PointF>)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

Fills the interior of a polygon defined by an array of points specified by Point structures using the specified fill mode.

C#
public void FillPolygon(System.Drawing.Brush brush, scoped ReadOnlySpan<System.Drawing.PointF> points);

Parameters

brush
Brush

Brush that determines the characteristics of the fill.

points
ReadOnlySpan<PointF>

Array of Point structures that represent the vertices of the polygon to fill.

Applies to

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