faintWiths method

Color faintWiths(
  1. List<Color> others, [
  2. double factor = 0.9
])

Blends the color with the calculated average of a list of others.

Edge Case: If the list is empty, it defaults to standard faint (white blend).

Implementation

Color faintWiths(List<Color> others, [double factor = 0.9]) {
  if (others.isEmpty) return faint(factor);

  double rAvg = 0, gAvg = 0, bAvg = 0;
  for (var c in others) {
    rAvg += c.r;
    gAvg += c.g;
    bAvg += c.b;
  }

  // Creates an average color from the provided list.
  final Color avgColor = Color.from(
    alpha: 1.0,
    red: rAvg / others.length,
    green: gAvg / others.length,
    blue: bAvg / others.length,
  );

  return faintWith(avgColor, factor);
}