$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 saturation1 = HSLColor.fromColor(c1).saturation;
  final saturation2 = HSLColor.fromColor(c2).saturation;
  var avgSaturation = (saturation1 + saturation2) / 2;

  // Adjust saturation based on blendWeight
  if (blendWeight > 0.5) {
    avgSaturation += (blendWeight - 0.5) * 2;
  } else {
    avgSaturation -= (0.5 - blendWeight) * 2;
  }
  avgSaturation = avgSaturation.clamp(0.0, 1.0);

  final hsl = HSLColor.fromColor(c1);
  return hsl.withSaturation(avgSaturation).toColor();
}