PathGradientBrush
Class
Definition
Encapsulates a Brush object that fills the interior of a GraphicsPath object with a gradient. This class cannot be inherited.
public sealed class PathGradientBrush : System.Drawing.Brush
- Inheritance
Inherited Members
System.Drawing.Brush
System.MarshalByRefObject
System.Object
Examples
The following code example shows how to create a PathGradientBrush. This example is designed for use with Windows Forms, and it requires the PaintEventArgs e, which is a parameter of PaintEventHandler.
// 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)
Remarks
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.
Path gradient brushes do not obey the SmoothingMode property of the Graphics object used to do the drawing. Areas filled using a PathGradientBrush object are rendered the same way (aliased) regardless of the smoothing mode.
Constructors
| PathGradientBrush(GraphicsPath) |
Initializes a new instance of the PathGradientBrush class with the specified path. |
| PathGradientBrush(Point[]) |
Initializes a new instance of the PathGradientBrush class with the specified points. |
| PathGradientBrush(PointF[]) |
Initializes a new instance of the PathGradientBrush class with the specified points. |
| PathGradientBrush(Point[], WrapMode) |
Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode. |
| PathGradientBrush(PointF[], WrapMode) |
Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode. |
Properties
| 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 |
Gets or sets a ColorBlend that defines a multicolor linear gradient. |
| Rectangle |
Gets a bounding rectangle for this PathGradientBrush. |
| SurroundColors |
Gets or sets an array of colors that correspond to the points in the path this PathGradientBrush fills. |
| Transform |
Gets or sets a copy of the Matrix that defines a local geometric transform for this PathGradientBrush. |
| WrapMode |
Gets or sets a WrapMode that indicates the wrap mode for this PathGradientBrush. |
Methods
| Clone() |
Creates an exact copy of this PathGradientBrush. |
| 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() |
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. |
| 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. |
| 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. |