PathGradientBrush 类

定义

封装 Brush 对象,它通过渐变填充 GraphicsPath 对象的内部。Encapsulates a Brush object that fills the interior of a GraphicsPath object with a gradient. 此类不能被继承。This class cannot be inherited.

public ref class PathGradientBrush sealed : System::Drawing::Brush
public sealed class PathGradientBrush : System.Drawing.Brush
type PathGradientBrush = class
    inherit Brush
Public NotInheritable Class PathGradientBrush
Inherits Brush
继承
PathGradientBrush

示例

下面的代码示例演示如何创建PathGradientBrushThe following code example shows how to create a PathGradientBrush. 此示例旨在与 Windows 窗体一起使用, 并且它需要PaintEventArgs e, 它是的PaintEventHandler参数。This example is designed for use with Windows Forms, and it requires the PaintEventArgs e, which is a parameter of 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)

注解

颜色渐变是从路径中心点到路径外边缘边缘的颜色平滑着色。The color gradient is a smooth shading of colors from the center point of the path to the outside boundary edge of the path. 混合系数、位置和样式会影响渐变的开始和结束位置, 并影响底纹的速度。Blend factors, positions, and style affect where the gradient starts and ends, and how fast it changes shade.

路径渐变画笔不遵循SmoothingMode用于执行绘制操作的Graphics对象的属性。Path gradient brushes do not obey the SmoothingMode property of the Graphics object used to do the drawing. 使用PathGradientBrush对象填充的区域以相同的方式呈现 (带有别名), 而不考虑平滑模式。Areas filled using a PathGradientBrush object are rendered the same way (aliased) regardless of the smoothing mode.

构造函数

PathGradientBrush(GraphicsPath)

使用指定的路径初始化 PathGradientBrush 类的新实例。Initializes a new instance of the PathGradientBrush class with the specified path.

PathGradientBrush(Point[])

使用指定的点初始化 PathGradientBrush 类的新实例。Initializes a new instance of the PathGradientBrush class with the specified points.

PathGradientBrush(Point[], WrapMode)

使用指定的点和环绕模式初始化 PathGradientBrush 类的新实例。Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode.

PathGradientBrush(PointF[])

使用指定的点初始化 PathGradientBrush 类的新实例。Initializes a new instance of the PathGradientBrush class with the specified points.

PathGradientBrush(PointF[], WrapMode)

使用指定的点和环绕模式初始化 PathGradientBrush 类的新实例。Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode.

属性

Blend

获取或设置一个 Blend,它指定定义渐变自定义过渡的位置和因素。Gets or sets a Blend that specifies positions and factors that define a custom falloff for the gradient.

CenterColor

获取或设置路径渐变的中心处的颜色。Gets or sets the color at the center of the path gradient.

CenterPoint

获取或设置路径渐变的中心点。Gets or sets the center point of the path gradient.

FocusScales

获取或设置渐变过渡的焦点。Gets or sets the focus point for the gradient falloff.

InterpolationColors

获取或设置一个定义多色线性渐变的 ColorBlendGets or sets a ColorBlend that defines a multicolor linear gradient.

Rectangle

获取此 PathGradientBrush 的边框。Gets a bounding rectangle for this PathGradientBrush.

SurroundColors

获取或设置与此 PathGradientBrush 填充的路径中的点相对应的颜色的数组。Gets or sets an array of colors that correspond to the points in the path this PathGradientBrush fills.

Transform

获取或设置一个用于定义此 Matrix 的局部几何变换的 PathGradientBrush 的副本。Gets or sets a copy of the Matrix that defines a local geometric transform for this PathGradientBrush.

WrapMode

获取或设置 WrapMode,它指示该 PathGradientBrush 的环绕模式。Gets or sets a WrapMode that indicates the wrap mode for this PathGradientBrush.

方法

Clone()

创建此 PathGradientBrush 的一个精确副本。Creates an exact copy of this PathGradientBrush.

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)
Dispose()

释放由此 Brush 对象使用的所有资源。Releases all resources used by this Brush object.

(继承自 Brush)
Dispose(Boolean)

释放由 Brush 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Brush and optionally releases the managed resources.

(继承自 Brush)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
MultiplyTransform(Matrix)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of brush's transformation matrix multiplied by another matrix.

MultiplyTransform(Matrix, MatrixOrder)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of the brush's transformation matrix multiplied by another matrix.

ResetTransform()

Transform 属性重置为标识。Resets the Transform property to identity.

RotateTransform(Single)

将局部几何转换旋转指定大小。Rotates the local geometric transform by the specified amount. 此方法预先计算对转换的旋转。This method prepends the rotation to the transform.

RotateTransform(Single, MatrixOrder)

将局部几何转换以指定顺序旋转指定量。Rotates the local geometric transform by the specified amount in the specified order.

ScaleTransform(Single, Single)

将局部几何转换缩放指定的量。Scales the local geometric transform by the specified amounts. 此方法预先计算转换的缩放矩阵。This method prepends the scaling matrix to the transform.

ScaleTransform(Single, Single, MatrixOrder)

将局部几何转换以指定顺序缩放指定的量。Scales the local geometric transform by the specified amounts in the specified order.

SetBlendTriangularShape(Single)

创建一个从中心色向周围色线性过渡的渐变过程。Creates a gradient with a center color and a linear falloff to one surrounding color.

SetBlendTriangularShape(Single, Single)

创建一个从中心色向各周围色线性过渡的渐变过程。Creates a gradient with a center color and a linear falloff to each surrounding color.

SetNativeBrush(IntPtr)

在派生类中,设置对 GDI+GDI+ 画笔对象的引用。In a derived class, sets a reference to a GDI+GDI+ brush object.

(继承自 Brush)
SetSigmaBellShape(Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

SetSigmaBellShape(Single, Single)

创建一个从路径中心开始向路径边界更改颜色的渐变画笔。Creates a gradient brush that changes color starting from the center of the path outward to the path's boundary. 从一种颜色向另一种颜色的转换基于一个钟形曲线。The transition from one color to another is based on a bell-shaped curve.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TranslateTransform(Single, Single)

将指定的转换应用于局部几何变换。Applies the specified translation to the local geometric transform. 该方法将预先计算对转换的平移。This method prepends the translation to the transform.

TranslateTransform(Single, Single, MatrixOrder)

按指定的顺序向局部几何变换应用指定的转换。Applies the specified translation to the local geometric transform in the specified order.

适用于

另请参阅