darken property

ColorFilter darken
getter/setter pair

Makes the color darker by the percentage specified in the first argument, or by 10% if no percentage is specified. Percentages should be specified as a float, e.g. an argument of 0.25 will result in a color 25% darker than the original. The darkening conversion is performed by adjusting the y component of the color in XYZ color space.

Implementation

static ColorFilter darken = new ColorFilter((Color inputColor, [List? args]) {
  CielabColor color = inputColor.toCielabColor();
  num percent = 0.1;
  if (args is List && args.length > 0 && args[0] is num) {
    percent = args[0];
  }
  return new CielabColor(color.l * (1 - percent), color.a, color.b);
}, CielabColor);