lerp static method
Linearly interpolate between two HSVColors.
The colors are interpolated by interpolating the alpha, hue,
saturation, and value channels separately, which usually leads to a
more pleasing effect than Color.lerp
(which interpolates the red, green,
and blue channels separately).
If either color is null, this function linearly interpolates from a
transparent instance of the other color. This is usually preferable to
interpolating from Colors.transparent
(const Color(0x00000000)
) since
that will interpolate from a transparent red and cycle through the hues to
match the target color, regardless of what that color's hue is.
Values outside of the valid range for each channel will be clamped.
Implementation
static HSVColor? lerp(HSVColor? a, HSVColor? b, double t) {
if (a == null && b == null) return null;
if (a == null) return b!._scaleAlpha(t);
if (b == null) return a._scaleAlpha(1.0 - t);
return HSVColor.fromAHSV(
lerpDouble(a.alpha, b.alpha, t)!.clamp(0.0, 1.0),
lerpDouble(a.hue, b.hue, t)! % 360.0,
lerpDouble(a.saturation, b.saturation, t)!.clamp(0.0, 1.0),
lerpDouble(a.value, b.value, t)!.clamp(0.0, 1.0),
);
}