createShader method
Creates a Shader (i.e. a Gradient) from this object.
Implementation
@override
Shader createShader(Rect bounds) {
final bool isObjectBoundingBox =
unitMode == GradientUnitMode.objectBoundingBox;
Matrix4 m4transform = transform == null
? Matrix4.identity()
: Matrix4.fromFloat64List(transform!);
if (isObjectBoundingBox) {
final Matrix4 scale =
affineMatrix(bounds.width, 0.0, 0.0, bounds.height, 0.0, 0.0);
final Matrix4 translate =
affineMatrix(1.0, 0.0, 0.0, 1.0, bounds.left, bounds.top);
m4transform = translate.multiplied(scale)..multiply(m4transform);
}
final Vector3 v3from = m4transform.transform3(
Vector3(
from.dx,
from.dy,
0.0,
),
);
final Vector3 v3to = m4transform.transform3(
Vector3(
to.dx,
to.dy,
0.0,
),
);
return Gradient.linear(
Offset(v3from.x, v3from.y),
Offset(v3to.x, v3to.y),
colors!,
offsets,
spreadMethod,
);
}