@@ -2296,25 +2296,44 @@ class Gradient extends Shader {
2296
2296
/// If `matrix4` is provided, the gradient fill will be transformed by the
2297
2297
/// specified 4x4 matrix relative to the local coordinate system. `matrix4` must
2298
2298
/// be a column-major matrix packed into a list of 16 values.
2299
+ ///
2300
+ /// If `focal` is provided and not equal to `center` or `focalRadius` is
2301
+ /// provided and not equal to 0.0, the generated shader will be a two point
2302
+ /// conical radial gradient, with `focal` being the center of the focal
2303
+ /// circle and `focalRadius` being the radius of that circle. If `focal` is
2304
+ /// provided and not equal to `center` , at least one of the two offsets must
2305
+ /// not be equal to [Offset.zero] .
2299
2306
Gradient .radial (
2300
2307
Offset center,
2301
2308
double radius,
2302
2309
List <Color > colors, [
2303
2310
List <double > colorStops,
2304
2311
TileMode tileMode = TileMode .clamp,
2305
- Float64List matrix4
2312
+ Float64List matrix4,
2313
+ Offset focal,
2314
+ double focalRadius
2306
2315
]) : assert (_offsetIsValid (center)),
2307
2316
assert (colors != null ),
2308
2317
assert (tileMode != null ),
2309
2318
assert (matrix4 == null || _matrix4IsValid (matrix4)),
2310
2319
super ._() {
2320
+ focal ?? = center;
2321
+ focalRadius ?? = 0.0 ;
2311
2322
_validateColorStops (colors, colorStops);
2312
2323
final Int32List colorsBuffer = _encodeColorList (colors);
2313
2324
final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List .fromList (colorStops);
2314
- _constructor ();
2315
- _initRadial (center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2325
+
2326
+ if (center == focal && focalRadius != 0.0 ) {
2327
+ _constructor ();
2328
+ _initRadial (center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2329
+ } else {
2330
+ assert (center != Offset .zero || focal != Offset .zero); // will result in nullptr in Skia side
2331
+ _constructor ();
2332
+ _initConical (focal.dx, focal.dy, focalRadius, center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2333
+ }
2316
2334
}
2317
2335
void _initRadial (double centerX, double centerY, double radius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initRadial' ;
2336
+ void _initConical (double startX, double startY, double startRadius, double endX, double endY, double endRadius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initTwoPointConical' ;
2318
2337
2319
2338
/// Creates a sweep gradient centered at `center` that starts at `startAngle`
2320
2339
/// and ends at `endAngle` .
0 commit comments