hsluvToLch static method

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

HSLuv values are ranging in 0;360, 0;100 and 0;100. @param tuple An array containing the color's H,S,L values in HSLuv color space. @return An array containing the resulting color's LCH coordinates.

Implementation

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

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

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

  double max = maxChromaForLH(L, H);
  double C = max / 100 * S;

  return [L, C, H];
}