Graphics.FillPie 方法

定义

填充由一对坐标、宽度、高度和两条径向线指定的椭圆定义的饼图部分的内部。

重载

FillPie(Brush, Rectangle, Single, Single)

填充由 RectangleF 结构和两条径向线指定的椭圆定义的饼图部分的内部。

FillPie(Brush, RectangleF, Single, Single)

填充椭圆和两条径向线定义的饼图部分的内部。

FillPie(Brush, Int32, Int32, Int32, Int32, Int32, Int32)

填充由一对坐标、宽度、高度和两条径向线指定的椭圆定义的饼图部分的内部。

FillPie(Brush, Single, Single, Single, Single, Single, Single)

填充由一对坐标、宽度、高度和两条径向线指定的椭圆定义的饼图部分的内部。

FillPie(Brush, Rectangle, Single, Single)

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

填充由 RectangleF 结构和两条径向线指定的椭圆定义的饼图部分的内部。

C#
public void FillPie(System.Drawing.Brush brush, System.Drawing.Rectangle rect, float startAngle, float sweepAngle);

参数

brush
Brush

确定填充特征的 Brush

rect
Rectangle

Rectangle 结构,该结构表示定义饼图部分所在的椭圆的边界矩形。

startAngle
Single

从 x 轴到饼图部分第一侧的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到饼图部分第二侧的顺时针度量角度。

例外

brush null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建纯红色画笔。

  • 创建一个矩形,该矩形绑定椭圆。

  • 定义起始角度(相对于 x 轴)和扫描角度(均以顺时针方向)。

  • 填充屏幕上椭圆的饼形区域。

C#
public void FillPieRectangle(PaintEventArgs e)
{
             
    // Create solid brush.
    SolidBrush redBrush = new SolidBrush(Color.Red);
             
    // Create rectangle for ellipse.
    Rectangle rect = new Rectangle(0, 0, 200, 100);
             
    // Create start and sweep angles.
    float startAngle =  0.0F;
    float sweepAngle = 45.0F;
             
    // Fill pie to screen.
    e.Graphics.FillPie(redBrush, rect, startAngle, sweepAngle);
}

注解

此方法填充由椭圆弧线定义的饼图部分的内部,以及与弧的端点相交的两条径向线。椭圆由边界矩形定义。 饼图部分由 startAnglesweepAngle 参数定义的两条径向线以及这些径向线与椭圆的交集之间的弧线组成。

如果 sweepAngle 参数大于 360 度或小于 -360 度,则它被视为 360 度或 -360 度。

适用于

.NET 10 (package-provided) 和其他版本
产品 版本
.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

FillPie(Brush, RectangleF, Single, Single)

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

填充椭圆和两条径向线定义的饼图部分的内部。

C#
public void FillPie(System.Drawing.Brush brush, System.Drawing.RectangleF rect, float startAngle, float sweepAngle);

参数

brush
Brush

确定填充特征的画笔。

rect
RectangleF

定义饼图部分所在的椭圆的边界矩形。

startAngle
Single

从 x 轴到饼图部分第一侧的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到饼图部分第二侧的顺时针度量角度。

适用于

.NET 10 (package-provided) 和其他版本
产品 版本
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
Windows Desktop 7, 8, 9, 10

FillPie(Brush, Int32, Int32, Int32, Int32, Int32, Int32)

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

填充由一对坐标、宽度、高度和两条径向线指定的椭圆定义的饼图部分的内部。

C#
public void FillPie(System.Drawing.Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle);

参数

brush
Brush

确定填充特征的 Brush

x
Int32

边界矩形左上角的 x 坐标,用于定义饼图部分所在的椭圆。

y
Int32

边界矩形左上角的 y 坐标,用于定义饼图部分所在的椭圆。

width
Int32

边界矩形的宽度,该矩形定义饼图部分所在的省略号。

height
Int32

定义饼图部分所在的椭圆的边界矩形的高度。

startAngle
Int32

从 x 轴到饼图部分第一侧的顺时针测量角度(以度为单位)。

sweepAngle
Int32

startAngle 参数到饼图部分第二侧的顺时针度量角度。

例外

brush null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建纯红色画笔。

  • 创建一个矩形的位置和大小,该矩形绑定椭圆。

  • 定义起始角度(相对于 x 轴)和扫描角度(均以顺时针方向)。

  • 填充屏幕上椭圆的饼形区域。

C#
public void FillPieInt(PaintEventArgs e)
{
             
    // Create solid brush.
    SolidBrush redBrush = new SolidBrush(Color.Red);
             
    // Create location and size of ellipse.
    int x = 0;
    int y = 0;
    int width = 200;
    int height = 100;
             
    // Create start and sweep angles.
    int startAngle =  0;
    int sweepAngle = 45;
             
    // Fill pie to screen.
    e.Graphics.FillPie(redBrush, x, y, width, height, startAngle, sweepAngle);
}

注解

此方法填充由椭圆弧线定义的饼图部分的内部,以及与弧的端点相交的两条径向线。椭圆由边界矩形定义。 饼图部分由 startAnglesweepAngle 参数定义的两条径向线以及这些径向线与椭圆的交集之间的弧线组成。

如果 sweepAngle 参数大于 360 度或小于 -360 度,则它被视为 360 度或 -360 度。

适用于

.NET 10 (package-provided) 和其他版本
产品 版本
.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

FillPie(Brush, Single, Single, Single, Single, Single, Single)

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

填充由一对坐标、宽度、高度和两条径向线指定的椭圆定义的饼图部分的内部。

C#
public void FillPie(System.Drawing.Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle);

参数

brush
Brush

确定填充特征的 Brush

x
Single

边界矩形左上角的 x 坐标,用于定义饼图部分所在的椭圆。

y
Single

边界矩形左上角的 y 坐标,用于定义饼图部分所在的椭圆。

width
Single

边界矩形的宽度,该矩形定义饼图部分所在的省略号。

height
Single

定义饼图部分所在的椭圆的边界矩形的高度。

startAngle
Single

从 x 轴到饼图部分第一侧的顺时针测量角度(以度为单位)。

sweepAngle
Single

startAngle 参数到饼图部分第二侧的顺时针度量角度。

例外

brush null

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建纯红色画笔。

  • 创建一个矩形的位置和大小,该矩形绑定椭圆。

  • 定义起始角度(相对于 x 轴)和扫描角度(均以顺时针方向)。

  • 填充屏幕上椭圆的饼形区域。

C#
public void FillPieFloat(PaintEventArgs e)
{
             
    // Create solid brush.
    SolidBrush redBrush = new SolidBrush(Color.Red);
             
    // Create location and size of ellipse.
    float x = 0.0F;
    float y = 0.0F;
    float width = 200.0F;
    float height = 100.0F;
             
    // Create start and sweep angles.
    float startAngle =  0.0F;
    float sweepAngle = 45.0F;
             
    // Fill pie to screen.
    e.Graphics.FillPie(redBrush, x, y, width, height, startAngle, sweepAngle);
}

注解

此方法填充由椭圆弧线定义的饼图部分的内部,以及与弧的端点相交的两条径向线。椭圆由边界矩形定义。 饼图部分由 startAnglesweepAngle 参数定义的两条径向线以及这些径向线与椭圆的交集之间的弧线组成。

如果 sweepAngle 参数大于 360 度或小于 -360 度,则它被视为 360 度或 -360 度。

适用于

.NET 10 (package-provided) 和其他版本
产品 版本
.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