Export (0) Print
Expand All

Graphics.FillPolygon Method

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

Overload List

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

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Sub FillPolygon(Brush, Point())
[C#] public void FillPolygon(Brush, Point[]);
[C++] public: void FillPolygon(Brush*, Point[]);
[JScript] public function FillPolygon(Brush, Point[]);

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

[Visual Basic] Overloads Public Sub FillPolygon(Brush, PointF())
[C#] public void FillPolygon(Brush, PointF[]);
[C++] public: void FillPolygon(Brush*, PointF[]);
[JScript] public function FillPolygon(Brush, PointF[]);

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

[Visual Basic] Overloads Public Sub FillPolygon(Brush, Point(), FillMode)
[C#] public void FillPolygon(Brush, Point[], FillMode);
[C++] public: void FillPolygon(Brush*, Point[], FillMode);
[JScript] public function FillPolygon(Brush, Point[], FillMode);

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

[Visual Basic] Overloads Public Sub FillPolygon(Brush, PointF(), FillMode)
[C#] public void FillPolygon(Brush, PointF[], FillMode);
[C++] public: void FillPolygon(Brush*, PointF[], FillMode);
[JScript] public function FillPolygon(Brush, PointF[], FillMode);

Example

[Visual Basic, C#] The following 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 FillMode.Winding.
  • Fills the polygonal area on the screen.
[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of FillPolygon. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub FillPolygonPointFFillMode(e As PaintEventArgs)
' Create solid brush.
Dim blueBrush As New SolidBrush(Color.Blue)
' Create points that define polygon.
Dim point1 As New PointF(50F, 50F)
Dim point2 As New PointF(100F, 25F)
Dim point3 As New PointF(200F, 5F)
Dim point4 As New PointF(250F, 50F)
Dim point5 As New PointF(300F, 100F)
Dim point6 As New PointF(350F, 200F)
Dim point7 As New PointF(250F, 250F)
Dim curvePoints As PointF() =  {point1, point2, point3, point4, _
point5, point6, point7}
' Define fill mode.
Dim newFillMode As FillMode = FillMode.Winding
' Fill polygon to screen.
e.Graphics.FillPolygon(blueBrush, curvePoints, newFillMode)
End Sub
        
[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, newFillModex3);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show:
© 2014 Microsoft