$blend method

  1. @override
Color $blend(
  1. Color c1,
  2. Color c2,
  3. double blendWeight
)
override

Implementation

@override
Color $blend(Color c1, Color c2, double blendWeight) {
  final hsl1 = HSLColor.fromColor(c1);
  final hsl2 = HSLColor.fromColor(c2);

  double blendComponent(double component1, double component2) {
    return (component1 * blendWeight) + (component2 * (1 - blendWeight));
  }

  final blendedHue = blendComponent(hsl1.hue, hsl2.hue);
  final blendedSaturation = blendComponent(hsl1.saturation, hsl2.saturation);
  final blendedLightness = blendComponent(hsl1.lightness, hsl2.lightness);
  final blendedAlpha = blendComponent(c1.a, c2.a);

  return HSLColor.fromAHSL(
    blendedAlpha,
    blendedHue,
    blendedSaturation,
    blendedLightness,
  ).toColor();
}