Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

PathGradientBrush Class

Encapsulates a Brush object that fills the interior of a GraphicsPath object with a gradient. This class cannot be inherited.

System.Object
  System.MarshalByRefObject
    System.Drawing.Brush
      System.Drawing.Drawing2D.PathGradientBrush

Namespace:  System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)
public sealed class PathGradientBrush : Brush

The PathGradientBrush type exposes the following members.

  NameDescription
Public methodPathGradientBrush(GraphicsPath)Initializes a new instance of the PathGradientBrush class with the specified path.
Public methodPathGradientBrush(Point[])Initializes a new instance of the PathGradientBrush class with the specified points.
Public methodPathGradientBrush(PointF[])Initializes a new instance of the PathGradientBrush class with the specified points.
Public methodPathGradientBrush(Point[], WrapMode)Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode.
Public methodPathGradientBrush(PointF[], WrapMode)Initializes a new instance of the PathGradientBrush class with the specified points and wrap mode.
Top
  NameDescription
Public propertyBlendGets or sets a Blend that specifies positions and factors that define a custom falloff for the gradient.
Public propertyCenterColorGets or sets the color at the center of the path gradient.
Public propertyCenterPointGets or sets the center point of the path gradient.
Public propertyFocusScalesGets or sets the focus point for the gradient falloff.
Public propertyInterpolationColorsGets or sets a ColorBlend that defines a multicolor linear gradient.
Public propertyRectangleGets a bounding rectangle for this PathGradientBrush.
Public propertySurroundColorsGets or sets an array of colors that correspond to the points in the path this PathGradientBrush fills.
Public propertyTransformGets or sets a copy of the Matrix that defines a local geometric transform for this PathGradientBrush.
Public propertyWrapModeGets or sets a WrapMode that indicates the wrap mode for this PathGradientBrush.
Top
  NameDescription
Public methodCloneCreates an exact copy of this PathGradientBrush. (Overrides Brush.Clone().)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by this Brush object. (Inherited from Brush.)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodMultiplyTransform(Matrix)Updates the brush's transformation matrix with the product of brush's transformation matrix multiplied by another matrix.
Public methodMultiplyTransform(Matrix, MatrixOrder)Updates the brush's transformation matrix with the product of the brush's transformation matrix multiplied by another matrix.
Public methodResetTransformResets the Transform property to identity.
Public methodRotateTransform(Single)Rotates the local geometric transform by the specified amount. This method prepends the rotation to the transform.
Public methodRotateTransform(Single, MatrixOrder)Rotates the local geometric transform by the specified amount in the specified order.
Public methodScaleTransform(Single, Single)Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.
Public methodScaleTransform(Single, Single, MatrixOrder)Scales the local geometric transform by the specified amounts in the specified order.
Public methodSetBlendTriangularShape(Single)Creates a gradient with a center color and a linear falloff to one surrounding color.
Public methodSetBlendTriangularShape(Single, Single)Creates a gradient with a center color and a linear falloff to each surrounding color.
Protected methodSetNativeBrushIn a derived class, sets a reference to a GDI+ brush object. (Inherited from Brush.)
Public methodSetSigmaBellShape(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.
Public methodSetSigmaBellShape(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.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodTranslateTransform(Single, Single)Applies the specified translation to the local geometric transform. This method prepends the translation to the transform.
Public methodTranslateTransform(Single, Single, MatrixOrder)Applies the specified translation to the local geometric transform in the specified order.
Top

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.

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);

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.