lerpColor function

Color lerpColor(
  1. Color a,
  2. Color b,
  3. double t
)

Linearly interpolate between two colors. Also handles the case when one of the colors is transparent, where Color.lerp fails to handle.

Implementation

Color lerpColor(Color a, Color b, double t) {
  if (a.alpha == 0) {
    a = b.withAlpha(0);
  } else if (b.alpha == 0) {
    b = a.withAlpha(0);
  }
  // lerp color manually
  return Color.fromARGB(
    _lerpColorInt(a.alpha, b.alpha, t),
    _lerpColorInt(a.red, b.red, t),
    _lerpColorInt(a.green, b.green, t),
    _lerpColorInt(a.blue, b.blue, t),
  );
}