fade method

Color fade(
  1. Node color,
  2. Dimension amount
)

Set the absolute transparency of a color.

Parameters: color: A color object. amount: A percentage 0-100%. Returns: color Example: fade(hsl(90, 90%, 50%), 10%) Output: rgba(128, 242, 13, 0.1) //hsla(90, 90%, 50%, 0.1)

Implementation

Color fade(Node color, Dimension amount) {
  final hsl = toHSL(color);

  hsl
    ..a = amount.value / 100
    ..a = clamp(hsl.a);

  return hslaColorSpace(color, hsl);

// 3.9.0 20190711
//  fade: function (color, amount) {
//    var hsl = toHSL(color);
//
//    hsl.a = amount.value / 100;
//    hsl.a = clamp(hsl.a);
//    return hsla(color, hsl);
//  },
}