lerp static method
Linearly interpolates between two colors.
t
is the fraction of interpolation from a
to b
; between 0 and 1.
If one color is null, a transparent instance of the other color is used.
Implementation
static Color? lerp(Color? a, Color? b, num t) {
if (a == null && b == null) return null;
if (a == null && b != null) return b.withAlpha(_lerpNum(0, b.alpha, t));
if (b == null && a != null) return a.withAlpha(_lerpNum(a.alpha, 0, t));
return Color.rgba(
_lerpNum(a!.red, b!.red, t).toInt(),
_lerpNum(a.green, b.green, t).toInt(),
_lerpNum(a.blue, b.blue, t).toInt(),
_lerpNum(a.alpha, b.alpha, t));
}