$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 brightness1 = HSLColor.fromColor(c1).lightness;
  final brightness2 = HSLColor.fromColor(c2).lightness;
  var avgBrightness = (brightness1 + brightness2) / 2;

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

  final hsl = HSLColor.fromColor(c1);
  return hsl.withLightness(avgBrightness).toColor();
}