blend static method

Color blend(
  1. Color color1,
  2. Color color2,
  3. double ratio
)

Blends two colors based on a ratio (0-1, where 0 is all color1, 1 is all color2)

Implementation

static Color blend(Color color1, Color color2, double ratio) {
  assert(ratio >= 0 && ratio <= 1);

  final r = (color1.red + (color2.red - color1.red) * ratio).round();
  final g = (color1.green + (color2.green - color1.green) * ratio).round();
  final b = (color1.blue + (color2.blue - color1.blue) * ratio).round();
  final a = (color1.alpha + (color2.alpha - color1.alpha) * ratio).round();

  return Color.fromARGB(a, r, g, b);
}