Table of Contents

Class PathGradientBrush

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

Provides an implementation of a brush for painting gradients between multiple color positions in 2D coordinates.

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

Constructors

PathGradientBrush(PointF[], Color[])

Initializes a new instance of the PathGradientBrush class.

public PathGradientBrush(PointF[] points, Color[] colors)

Parameters

points PointF[]

Points that constitute a polygon that represents the gradient area.

colors Color[]

Array of colors that correspond to each point in the polygon.

PathGradientBrush(PointF[], Color[], Color)

Initializes a new instance of the PathGradientBrush class.

public PathGradientBrush(PointF[] points, Color[] colors, Color centerColor)

Parameters

points PointF[]

Points that constitute a polygon that represents the gradient area.

colors Color[]

Array of colors that correspond to each point in the polygon.

centerColor Color

Color at the center of the gradient area to which the other colors converge.

Properties

CenterColor

Gets the color at the center of the gradient area.

public Color CenterColor { get; }

Property Value

Color

Colors

Gets the colors that are mapped to the polygon points.

public ReadOnlySpan<Color> Colors { get; }

Property Value

ReadOnlySpan<Color>

HasExplicitCenterColor

Gets a value indicating whether the center color was explicitly supplied.

public bool HasExplicitCenterColor { get; }

Property Value

bool

Points

Gets the polygon points that define the gradient area.

public ReadOnlySpan<PointF> Points { get; }

Property Value

ReadOnlySpan<PointF>

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.