lchToHpluv static method

List<double> lchToHpluv(
  1. List<double> tuple
)

HSLuv values are ranging in 0;360, 0;100 and 0;100. @param tuple An array containing the color's LCH values. @return An array containing the resulting color's HSL coordinates in HPLuv (pastel variant) color space.

Implementation

static List<double> lchToHpluv(List<double> tuple) {
  double L = tuple[0];
  double C = tuple[1];
  double H = tuple[2];

  // White and black: disambiguate saturation
  if (L > 99.9999999) {
    return [H, 0, 100];
  }

  if (L < 0.00000001) {
    return [H, 0, 0];
  }

  double max = maxSafeChromaForL(L);
  double S = C / max * 100;

  return [H, S, L];
}