luvToLch static method

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

@param tuple An array containing the color's L,U,V values. @return An array containing the resulting color's LCH coordinates.

Implementation

static List<double> luvToLch(List<double> tuple) {
  double L = tuple[0];
  double U = tuple[1];
  double V = tuple[2];

  double C = math.sqrt(U * U + V * V);
  double H;

  // Greys: disambiguate hue
  if (C < 0.00000001) {
    H = 0;
  } else {
    double hRad = math.atan2(V, U);
    H = (hRad * 180.0) / math.pi;

    if (H < 0) {
      H = 360 + H;
    }
  }

  return [L, C, H];
}