darkenRgb function

List<num> darkenRgb (
  1. num amount,
  2. List<num> rgb
)

returns a darkened rgb array. amount is a value in the range [0, 1]

Implementation

List<num> darkenRgb(num amount, List<num> rgb) {
  return rgb
      .map((c) => [
            [0, c + (c * -amount)].reduce(math.max),
            255
          ].reduce(math.min).round())
      .toList();
}