fadein method

Color fadein(
  1. Node color,
  2. Dimension amount,
  3. [Keyword method]
)

Decrease the transparency (or increase the opacity) of a color, making it more opaque. Parameters: color: A color object. amount: A percentage 0-100%. method: Optional, set to relative for the adjustment to be relative to the current value. Returns: color Example: fadein(hsla(90, 90%, 50%, 0.5), 10%) Output: rgba(128, 242, 13, 0.6) // hsla(90, 90%, 50%, 0.6)

Implementation

//
/// Parameters:
///   color: A color object.
///   amount: A percentage 0-100%.
///   method: Optional, set to relative for the adjustment to be relative to the current value.
///   Returns: color
/// Example: fadein(hsla(90, 90%, 50%, 0.5), 10%)
///   Output: rgba(128, 242, 13, 0.6) // hsla(90, 90%, 50%, 0.6)
///
Color fadein(Node color, Dimension amount, [Keyword method]) {
  final hsl = toHSL(color);

  hsl
    ..a += (method?.value == 'relative')
        ? hsl.a * amount.value / 100
        : amount.value / 100
    ..a = clamp(hsl.a);

  return hslaColorSpace(color, hsl);

// 3.9.0 20190711
//  fadein: function (color, amount, method) {
//    var hsl = toHSL(color);
//
//    if (typeof method !== 'undefined' && method.value === 'relative') {
//      hsl.a +=  hsl.a * amount.value / 100;
//    }
//    else {
//      hsl.a += amount.value / 100;
//    }
//    hsl.a = clamp(hsl.a);
//    return hsla(color, hsl);
//  },
}