Table of Contents

Class RadialGradientBrush

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

A radial gradient brush defined by either one circle or two circles. When one circle is provided, the gradient parameter is the distance from the center divided by the radius. When two circles are provided, the gradient parameter is computed along the family of circles interpolating between the start and end circles.

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

Constructors

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

Initializes a new instance of the RadialGradientBrush class using a single circle.

public RadialGradientBrush(PointF center, float radius, GradientRepetitionMode repetitionMode, params ColorStop[] colorStops)

Parameters

center PointF

The center of the circular gradient.

radius float

The radius of the circular gradient.

repetitionMode GradientRepetitionMode

Defines how the colors in the gradient are repeated.

colorStops ColorStop[]

The ordered gradient stops.

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

Initializes a new instance of the RadialGradientBrush class using two circles.

public RadialGradientBrush(PointF startCenter, float startRadius, PointF endCenter, float endRadius, GradientRepetitionMode repetitionMode, params ColorStop[] colorStops)

Parameters

startCenter PointF

The center of the starting circle.

startRadius float

The radius of the starting circle.

endCenter PointF

The center of the ending circle.

endRadius float

The radius of the ending circle.

repetitionMode GradientRepetitionMode

Defines how the colors in the gradient are repeated.

colorStops ColorStop[]

The ordered gradient stops.

Properties

Center0

Gets the center of the starting circle.

public PointF Center0 { get; }

Property Value

PointF

Center1

Gets the center of the ending circle, or null for single-circle form.

public PointF? Center1 { get; }

Property Value

PointF?

IsTwoCircle

Gets a value indicating whether this is a two-circle radial gradient.

public bool IsTwoCircle { get; }

Property Value

bool

Radius0

Gets the radius of the starting circle.

public float Radius0 { get; }

Property Value

float

Radius1

Gets the radius of the ending circle, or null for single-circle form.

public float? Radius1 { 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.