PathGradientBrush 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
封装 Brush 对象,它通过渐变填充 GraphicsPath 对象的内部。 此类不能被继承。
public ref class PathGradientBrush sealed : System::Drawing::Brushpublic sealed class PathGradientBrush : System.Drawing.Brushtype PathGradientBrush = class
    inherit BrushPublic NotInheritable Class PathGradientBrush
Inherits Brush- 继承
示例
下面的代码示例演示如何创建 PathGradientBrush。 此示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgs e,它是 的参数PaintEventHandler。
public void FillEllipseWithPathGradient(PaintEventArgs e)
{
    // Create a path that consists of a single ellipse.
    GraphicsPath path = new GraphicsPath();
    path.AddEllipse(0, 0, 140, 70);
    // Use the path to construct a brush.
    PathGradientBrush pthGrBrush = new PathGradientBrush(path);
    // Set the color at the center of the path to blue.
    pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255);
    // Set the color along the entire boundary 
    // of the path to aqua.
    Color[] colors = { Color.FromArgb(255, 0, 255, 255) };
    pthGrBrush.SurroundColors = colors;
    e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70);
}
' Create a path that consists of a single ellipse.
Dim path As New GraphicsPath()
path.AddEllipse(0, 0, 140, 70)
' Use the path to construct a brush.
Dim pthGrBrush As New PathGradientBrush(path)
' Set the color at the center of the path to blue.
pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255)
' Set the color along the entire boundary 
' of the path to aqua.
Dim colors As Color() = {Color.FromArgb(255, 0, 255, 255)}
pthGrBrush.SurroundColors = colors
e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70)
注解
颜色渐变是从路径的中心点到路径的外部边界边缘的颜色平滑着色。 混合因素、位置和样式会影响渐变的开始和结束位置,以及渐变变化阴影的速度。
路径渐变画笔不符合 SmoothingMode 用于进行绘制的 Graphics 对象的 属性。 使用 PathGradientBrush 对象填充的区域的呈现方式与 (别名) 相同,而不考虑平滑模式。
注意
在 .NET 6 及更高版本中, System.Drawing.Common 包(包括此类型)仅在 Windows 操作系统上受支持。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 System.Drawing.Common 仅在 Windows 上受支持。
构造函数
| PathGradientBrush(GraphicsPath) | 使用指定的路径初始化 PathGradientBrush 类的新实例。 | 
| PathGradientBrush(Point[]) | 使用指定的点初始化 PathGradientBrush 类的新实例。 | 
| PathGradientBrush(Point[], WrapMode) | 使用指定的点和环绕模式初始化 PathGradientBrush 类的新实例。 | 
| PathGradientBrush(PointF[]) | 使用指定的点初始化 PathGradientBrush 类的新实例。 | 
| PathGradientBrush(PointF[], WrapMode) | 使用指定的点和环绕模式初始化 PathGradientBrush 类的新实例。 | 
属性
| Blend | 获取或设置一个 Blend,它指定定义渐变自定义过渡的位置和因素。 | 
| CenterColor | 获取或设置路径渐变的中心处的颜色。 | 
| CenterPoint | 获取或设置路径渐变的中心点。 | 
| FocusScales | 获取或设置渐变过渡的焦点。 | 
| InterpolationColors | 获取或设置一个定义多色线性渐变的 ColorBlend。 | 
| Rectangle | 获取此 PathGradientBrush 的边框。 | 
| SurroundColors | 获取或设置与此 PathGradientBrush 填充的路径中的点相对应的颜色的数组。 | 
| Transform | 获取或设置一个用于定义此 Matrix 的局部几何变换的 PathGradientBrush 的副本。 | 
| WrapMode | 获取或设置 WrapMode,它指示该 PathGradientBrush 的环绕模式。 |