Class LinearGradientBrush
- Namespace
- SixLabors.ImageSharp.Drawing.Processing
- Assembly
- SixLabors.ImageSharp.Drawing.dll
Provides a brush that paints linear gradients within an area. Supports both classic two-point gradients and three-point (rotated) gradients.
public sealed class LinearGradientBrush : GradientBrush, IEquatable<Brush>
- Inheritance
-
LinearGradientBrush
- Implements
- Inherited Members
Constructors
LinearGradientBrush(PointF, PointF, GradientRepetitionMode, params ColorStop[])
Initializes a new instance of the LinearGradientBrush class using a start and end point.
public LinearGradientBrush(PointF p0, PointF p1, GradientRepetitionMode repetitionMode, params ColorStop[] colorStops)
Parameters
p0PointFThe start point of the gradient.
p1PointFThe end point of the gradient.
repetitionModeGradientRepetitionModeDefines how the colors are repeated.
colorStopsColorStop[]The ordered color stops of the gradient.
LinearGradientBrush(PointF, PointF, PointF, GradientRepetitionMode, params ColorStop[])
Initializes a new instance of the LinearGradientBrush class using three points to define a rotated gradient axis.
public LinearGradientBrush(PointF p0, PointF p1, PointF rotationPoint, GradientRepetitionMode repetitionMode, params ColorStop[] colorStops)
Parameters
p0PointFThe first point (start of the gradient).
p1PointFThe second point (gradient vector endpoint).
rotationPointPointFThe rotation reference point. This defines the rotation of the gradient axis.
repetitionModeGradientRepetitionModeDefines how the colors are repeated.
colorStopsColorStop[]The ordered color stops of the gradient.
Properties
EndPoint
Gets the end point of the gradient axis.
public PointF EndPoint { get; }
Property Value
StartPoint
Gets the start point of the gradient axis.
public PointF StartPoint { get; }
Property Value
Methods
CreateRenderer<TPixel>(Configuration, GraphicsOptions, int, RectangleF)
Creates the prepared execution object for this brush.
public override BrushRenderer<TPixel> CreateRenderer<TPixel>(Configuration configuration, GraphicsOptions options, int canvasWidth, RectangleF region) where TPixel : unmanaged, IPixel<TPixel>
Parameters
configurationConfigurationThe configuration instance to use when performing operations.
optionsGraphicsOptionsThe graphic options.
canvasWidthintThe canvas width for the current render pass.
regionRectangleFThe region the brush will be applied to.
Returns
- BrushRenderer<TPixel>
The BrushRenderer<TPixel> for this brush.
Type Parameters
TPixelThe pixel type.
Remarks
The region when being applied to things like shapes would usually be the
bounding box of the shape not necessarily the bounds of the whole image.
Equals(Brush?)
Indicates whether the current object is equal to another object of the same type.
public override bool Equals(Brush? other)
Parameters
otherBrushAn object to compare with this object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Transform(Matrix4x4)
Returns a new brush with its defining geometry transformed by the given matrix.
public override Brush Transform(Matrix4x4 matrix)
Parameters
matrixMatrix4x4The transformation matrix to apply.
Returns
- Brush
A transformed brush, or
thisif the brush has no spatial parameters.