SweepGradientBrush Class
A gradient around a point: the color is constant on the half-lines that start at that point.
public sealed class SweepGradientBrush : GradientBrushRemarks
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
GradientBrushSweepGradientBrush
Constructors
| Name | Description |
|---|---|
| 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.csInitializes a new instance of the SweepGradientBrush class between two angles.
public SweepGradientBrush(PointD center, double startAngle, double endAngle, ReadOnlySpan<GradientStop> stops)Parameters
centerPointD- The point the half-lines start at, in canvas coordinates.
startAngledouble- The angle of offset 0, in degrees from the positive x axis, clockwise on the image.
endAngledouble- The angle of offset 1, in degrees. Must not be less than
startAngle. stopsReadOnlySpan<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
endAngleis less thanstartAngle.
SweepGradientBrush(PointD, ReadOnlySpan<GradientStop>)
SweepGradientBrush.csInitializes 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
centerPointD- The point the half-lines start at, in canvas coordinates.
stopsReadOnlySpan<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
| Name | Description |
|---|---|
| Center | Gets the point the half-lines start at. |
| EndAngle | Gets the angle of offset 1, in degrees. |
| StartAngle | Gets the angle of offset 0, in degrees from the positive x axis, clockwise on the image. |