DekGenius.com
[ Team LiB ] Previous Section Next Section

LinearGradientBrushmarshal by reference, disposable

System.Drawing.Drawing2D (system.drawing.dll)sealed class

This brush class can be used to draw both two color and multicolor gradient fills.

For a two-color gradient, you set the LinearColors and the Blend properties. For a multicolor gradient, you instead set a ColorBlend object into the InterpolationColors member. In either case, you can enable GammaCorrection when rendering the gradient.

You can specify the logical Rectangle that defines the gradient, either in the constructor or, thereafter, through the Rectangle property. If the fill extends beyond this rectangle, the WrapMode determines how the areas outside the rectangle will be filled. When constructing the brush, but not thereafter, you can specify the LinearGradientMode or, alternatively, the angle (in degrees) at which the gradient should run across that rectangle.

You can also apply a Transform to the brush. There are the usual helper utilities MultiplyTransform(), ResetTransform(), RotateTransform(), TranslateTransform(), and ScaleTransform() to save you the trouble of the get/modify/set required to modify the Transform itself.

There are two other helper utilities: SetBlendTriangularShape() and SetSigmaBellShape() set up two common gradient shapes for you.

For non-rectangular fills, see PathGradientBrush.

public sealed class LinearGradientBrush : System.Drawing.Brush {
// Public Constructors
   public LinearGradientBrush(System.Drawing.PointF point1, System.Drawing.PointF point2, 
        System.Drawing.Color color1, System.Drawing.Color color2);
   public LinearGradientBrush(System.Drawing.Point point1, System.Drawing.Point point2, 
        System.Drawing.Color color1, System.Drawing.Color color2);
   public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, LinearGradientMode linearGradientMode);
   public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, float angle);
   public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, float angle, bool isAngleScaleable);
   public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, LinearGradientMode linearGradientMode);
   public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, float angle);
   public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, 
        System.Drawing.Color color2, float angle, bool isAngleScaleable);
// Public Instance Properties
   public Blend Blend{set; get; }
   public bool GammaCorrection{set; get; }
   public ColorBlend InterpolationColors{set; get; }
   public Color[ ] LinearColors{set; get; }
   public RectangleF Rectangle{get; }
   public Matrix Transform{set; get; }
   public WrapMode WrapMode{set; get; }
// Public Instance Methods
   public override object Clone();  // overrides System.Drawing.Brush
   public void MultiplyTransform(Matrix matrix);
   public void MultiplyTransform(Matrix matrix, MatrixOrder order);
   public void ResetTransform();
   public void RotateTransform(float angle);
   public void RotateTransform(float angle, MatrixOrder order);
   public void ScaleTransform(float sx, float sy);
   public void ScaleTransform(float sx, float sy, MatrixOrder order);
   public void SetBlendTriangularShape(float focus);
   public void SetBlendTriangularShape(float focus, float scale);
   public void SetSigmaBellShape(float focus);
   public void SetSigmaBellShape(float focus, float scale);
   public void TranslateTransform(float dx, float dy);
   public void TranslateTransform(float dx, float dy, MatrixOrder order);
}

Hierarchy

System.Object System.MarshalByRefObject System.Drawing.Brush(System.ICloneabl, System.IDisposable) LinearGradientBrush

    [ Team LiB ] Previous Section Next Section