SweepGradientBrush Class

A gradient around a point: the color is constant on the half-lines that start at that point.

public sealed class SweepGradientBrush : GradientBrush

Remarks

The parameter of a position is the angle of the half-line from SweepGradientBrush.Center through it, measured clockwise on the image from SweepGradientBrush.StartAngle, divided by the angle from SweepGradientBrush.StartAngle to SweepGradientBrush.EndAngle: 0 on the half-line at SweepGradientBrush.StartAngle, 1 on the one at SweepGradientBrush.EndAngle. With the default angles, the gradient goes once around the center, from its right. Where the angle is beyond SweepGradientBrush.EndAngle, GradientBrush.SpreadMode gives the colors. When both angles are the same, the whole canvas has the color of the last stop.

The colors change abruptly on the half-line at SweepGradientBrush.StartAngle unless the gradient ends on the color it starts with: like every gradient, it is evaluated at the center of each pixel, and that edge is not antialiased. The angle of a position does not come from the platform: the pixels are the same everywhere.

Inheritance
GradientBrush SweepGradientBrush

Constructors

NameDescription
SweepGradientBrush(PointD, double, double, ReadOnlySpan<GradientStop>)Initializes a new instance of the SweepGradientBrush class between two angles.
SweepGradientBrush(PointD, ReadOnlySpan<GradientStop>)Initializes a new instance of the SweepGradientBrush class that goes once around its center, starting on its right.

SweepGradientBrush overloads

SweepGradientBrush(PointD, double, double, ReadOnlySpan<GradientStop>)

SweepGradientBrush.cs

Initializes a new instance of the SweepGradientBrush class between two angles.

public SweepGradientBrush(PointD center, double startAngle, double endAngle, ReadOnlySpan<GradientStop> stops)
Parameters
center PointD
The point the half-lines start at, in canvas coordinates.
startAngle double
The angle of offset 0, in degrees from the positive x axis, clockwise on the image.
endAngle double
The angle of offset 1, in degrees. Must not be less than startAngle.
stops ReadOnlySpan<GradientStop>
The stops, in increasing order of offset. They are copied.
Exceptions
ArgumentException
There is no stop, the offsets decrease, or a coordinate or an angle is not a finite number.
ArgumentOutOfRangeException
The magnitude of a coordinate exceeds 16777216, or endAngle is less than startAngle.

SweepGradientBrush(PointD, ReadOnlySpan<GradientStop>)

SweepGradientBrush.cs

Initializes a new instance of the SweepGradientBrush class that goes once around its center, starting on its right.

public SweepGradientBrush(PointD center, ReadOnlySpan<GradientStop> stops)
Parameters
center PointD
The point the half-lines start at, in canvas coordinates.
stops ReadOnlySpan<GradientStop>
The stops, in increasing order of offset. They are copied.
Exceptions
ArgumentException
There is no stop, the offsets decrease, or a coordinate is not a finite number.
ArgumentOutOfRangeException
The magnitude of a coordinate exceeds 16777216.

Properties

NameDescription
CenterGets the point the half-lines start at.
EndAngleGets the angle of offset 1, in degrees.
StartAngleGets the angle of offset 0, in degrees from the positive x axis, clockwise on the image.

Gets the point the half-lines start at.

public PointD Center { get; }

Property value

PointD

Gets the angle of offset 1, in degrees.

public double EndAngle { get; }

Property value

double

Gets the angle of offset 0, in degrees from the positive x axis, clockwise on the image.

public double StartAngle { get; }

Property value

double