This documentation is archived and is not being maintained.

Graphics.FillPath Method

Fills the interior of a GraphicsPath object.

[Visual Basic]
Public Sub FillPath( _
   ByVal brush As Brush, _
   ByVal path As GraphicsPath _
)
[C#]
public void FillPath(
 Brush brush,
 GraphicsPath path
);
[C++]
public: void FillPath(
 Brush* brush,
 GraphicsPath* path
);
[JScript]
public function FillPath(
   brush : Brush,
 path : GraphicsPath
);

Parameters

brush
Brush object that determines the characteristics of the fill.
path
GraphicsPath object that represents the path to fill.

Return Value

This method does not return a value.

Remarks

A GraphicsPath object consists of a series of line and curve segments. If the path represented by the path parameter is not closed, an additional segment is added from the last point to the first point to close the path.

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 actions:

  • Creates a solid red brush.
  • Creates a graphics path object.
  • Adds an ellipse to the graphics path.
  • Fills the path on the screen.
[Visual Basic] 
Public Sub FillPathEllipse(e As PaintEventArgs)
' Create solid brush.
Dim redBrush As New SolidBrush(Color.Red)
' Create graphics path object and add ellipse.
Dim graphPath As New GraphicsPath()
graphPath.AddEllipse(0, 0, 200, 100)
' Fill graphics path to screen.
e.Graphics.FillPath(redBrush, graphPath)
End Sub
        
[C#] 
public void FillPathEllipse(PaintEventArgs e)
{
// Create solid brush.
SolidBrush redBrush = new SolidBrush(Color.Red);
// Create graphics path object and add ellipse.
GraphicsPath graphPath = new GraphicsPath();
graphPath.AddEllipse(0, 0, 200, 100);
// Fill graphics path to screen.
e.Graphics.FillPath(redBrush, graphPath);
}
        

[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.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show: