Gradient.sweep constructor
Creates a sweep gradient centered at center that starts at startAngle
and ends at endAngle.
startAngle and endAngle should be provided in radians, with zero
radians being the horizontal line to the right of the center and with
positive angles going clockwise around the center.
If colorStops is provided, colorStops[i] is a number from 0.0 to 1.0
that specifies where colors[i] begins in the gradient. If colorStops is
not provided, then only two stops, at 0.0 and 1.0, are implied
(and colors must therefore only have two entries). Stop values less than
0.0 will be rounded up to 0.0 and stop values greater than 1.0 will be
rounded down to 1.0. Each stop value must be greater than or equal to the
previous stop value. Stop values that do not meet this criteria will be
rounded up to the previous stop value.
The startAngle and endAngle parameters define the angular sector to be
painted. Angles are measured in radians clockwise from the positive x-axis.
Values outside the range [0, 2π] are normalized to this range using modulo
arithmetic. The gradient is only painted in the sector between startAngle
and endAngle. The tileMode determines how the gradient behaves outside
this sector.
The tileMode argument specifies how the gradient should handle areas
outside the angular sector defined by startAngle and endAngle:
The behavior before startAngle and after endAngle is described by the
tileMode argument. For details, see the TileMode enum.
- TileMode.clamp: The edge colors are extended to infinity.
- TileMode.mirror: The gradient is repeated, alternating direction each time.
- TileMode.repeated: The gradient is repeated in the same direction.
- TileMode.decal: Only the colors within the gradient's angular sector are drawn, with transparent black elsewhere.
The colorStops argument must have the same number of values as colors,
if specified. It specifies the position of each color stop between 0.0 and
1.0. If it is null, a uniform distribution is assumed. The stop values must
be in ascending order. A stop value of 0.0 corresponds to startAngle, and
a stop value of 1.0 corresponds to endAngle.

If center, colors, tileMode, startAngle, or endAngle are null,
or if colors or colorStops contain null values, this constructor will
throw a NoSuchMethodError.
If matrix4 is provided, the gradient fill will be transformed by the
specified 4x4 matrix relative to the local coordinate system. matrix4 must
be a column-major matrix packed into a list of 16 values.
Implementation
Gradient.sweep(
Offset center,
List<Color> colors, [
List<double>? colorStops,
TileMode tileMode = TileMode.clamp,
double startAngle = 0.0,
double endAngle = math.pi * 2,
Float64List? matrix4,
]) : assert(_offsetIsValid(center)),
assert(startAngle < endAngle),
assert(matrix4 == null || _matrix4IsValid(matrix4)),
super._() {
_validateColorStops(colors, colorStops);
final Float32List colorsBuffer = _encodeWideColorList(colors);
final Float32List? colorStopsBuffer = colorStops == null
? null
: Float32List.fromList(colorStops);
_constructor();
_initSweep(
center.dx,
center.dy,
colorsBuffer,
colorStopsBuffer,
tileMode.index,
startAngle,
endAngle,
matrix4,
);
}