Graphics.FillPath 方法

填充 GraphicsPath 的内部。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Sub FillPath ( _
    brush As Brush, _
    path As GraphicsPath _
)
用法
Dim instance As Graphics
Dim brush As Brush
Dim path As GraphicsPath

instance.FillPath(brush, path)
public void FillPath (
    Brush brush,
    GraphicsPath path
)
public:
void FillPath (
    Brush^ brush, 
    GraphicsPath^ path
)
public void FillPath (
    Brush brush, 
    GraphicsPath path
)
public function FillPath (
    brush : Brush, 
    path : GraphicsPath
)

参数

  • brush
    确定填充特性的 Brush

异常

异常类型 条件

ArgumentNullException

pen 为 空引用(在 Visual Basic 中为 Nothing)。

- 或 -

path 为 空引用(在 Visual Basic 中为 Nothing)。

备注

GraphicsPath 由一系列行和曲线段组成。如果 path 参数表示的路径未闭合,则在最后一个点和第一个点之间添加一条额外的线段来闭合该路径。

示例

下面的代码示例设计为与 Windows 窗体一起使用,它需要 PaintEventArgse,即 Paint 事件处理程序的一个参数。代码执行下列操作:

  • 创建一支纯红色画笔。

  • 创建一个图形路径对象。

  • 向图形路径添加一个椭圆。

  • 填充屏幕上的路径。

Public Sub FillPathEllipse(ByVal 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
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);
}
public:
   void FillPathEllipse( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ redBrush = gcnew SolidBrush( Color::Red );

      // Create graphics path object and add ellipse.
      GraphicsPath^ graphPath = gcnew GraphicsPath;
      graphPath->AddEllipse( 0, 0, 200, 100 );

      // Fill graphics path to screen.
      e->Graphics->FillPath( redBrush, graphPath );
   }
public void FillPathEllipse(PaintEventArgs e) 
{
    // Create solid brush.
    SolidBrush redBrush =  new SolidBrush(Color.get_Red());

    // Create graphics path object and add ellipse.
    GraphicsPath graphPath =  new GraphicsPath();
    graphPath.AddEllipse(0, 0, 200, 100);

    // Fill graphics path to screen.
    e.get_Graphics().FillPath(redBrush, graphPath);
} //FillPathEllipse

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Graphics 类
Graphics 成员
System.Drawing 命名空间