Table of Contents

Class SweepGradientBrush

Namespace
SixLabors.ImageSharp.Drawing.Processing
Assembly
SixLabors.ImageSharp.Drawing.dll

Provides an implementation of a brush for painting sweep (conic) gradients within areas. Angles increase counter-clockwise from +X on the design grid.

public sealed class SweepGradientBrush : GradientBrush, IEquatable<Brush>
Inheritance
SweepGradientBrush
Implements
Inherited Members

Constructors

SweepGradientBrush(PointF, float, float, GradientRepetitionMode, params ColorStop[])

Initializes a new instance of the SweepGradientBrush class.

public SweepGradientBrush(PointF center, float startAngleDegrees, float endAngleDegrees, GradientRepetitionMode repetitionMode, params ColorStop[] colorStops)

Parameters

center PointF

The center point of the sweep gradient in device space.

startAngleDegrees float

The starting angle, in degrees, measured counter-clockwise from +X on the design grid. This value is stored as provided so the sign and magnitude of the sweep remain intact.

endAngleDegrees float

The ending angle, in degrees, measured counter-clockwise from +X on the design grid. If equal to startAngleDegrees, the gradient is treated as a full 360 degree sweep. Otherwise, the signed difference between start and end determines the sweep direction.

repetitionMode GradientRepetitionMode

Defines how the gradient colors are repeated beyond the interval [0..1].

colorStops ColorStop[]

The gradient color stops. Ratios must be in [0..1] and are interpreted along the angular sweep.

Properties

Center

Gets the center point of the sweep gradient.

public PointF Center { get; }

Property Value

PointF

EndAngleDegrees

Gets the ending angle in degrees.

public float EndAngleDegrees { get; }

Property Value

float

StartAngleDegrees

Gets the starting angle in degrees.

public float StartAngleDegrees { get; }

Property Value

float

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

configuration Configuration

The configuration instance to use when performing operations.

options GraphicsOptions

The graphic options.

canvasWidth int

The canvas width for the current render pass.

region RectangleF

The region the brush will be applied to.

Returns

BrushRenderer<TPixel>

The BrushRenderer<TPixel> for this brush.

Type Parameters

TPixel

The 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

other Brush

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

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

matrix Matrix4x4

The transformation matrix to apply.

Returns

Brush

A transformed brush, or this if the brush has no spatial parameters.