examples/color-manipulation.js
function hcl2rgb(pixel) {
  const h = pixel[0];
  const c = pixel[1];
  const l = pixel[2];

  const a = Math.cos(h) * c;
  const b = Math.sin(h) * c;

  let y = (l + 16) / 116;
  let x = isNaN(a) ? y : y + a / 500;
  let z = isNaN(b) ? y : y - b / 200;

  y = Yn * lab2xyz(y);
  x = Xn * lab2xyz(x);
  z = Zn * lab2xyz(z);

  pixel[0] = xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);
  pixel[1] = xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);
  pixel[2] = xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);

  return pixel;
}
function hcl2rgb(pixel) {
  const h = pixel[0];
  const c = pixel[1];
  const l = pixel[2];

  const a = Math.cos(h) * c;
  const b = Math.sin(h) * c;

  let y = (l + 16) / 116;
  let x = isNaN(a) ? y : y + a / 500;
  let z = isNaN(b) ? y : y - b / 200;

  y = Yn * lab2xyz(y);
  x = Xn * lab2xyz(x);
  z = Zn * lab2xyz(z);

  pixel[0] = xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);
  pixel[1] = xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);
  pixel[2] = xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);

  return pixel;
}
function hcl2rgb ( pixel ) { const h = pixel [ 0 ] ; const c = pixel [ 1 ] ; const l = pixel [ 2 ] ; const a = Math . cos ( h ) * c ; const b = Math . sin ( h ) * c ; let y = ( l + 16 ) / 116 ; let x = isNaN ( a ) ? y : y + a / 500 ; let z = isNaN ( b ) ? y : y - b / 200 ; y = Yn * lab2xyz ( y ) ; x = Xn * lab2xyz ( x ) ; z = Zn * lab2xyz ( z ) ; pixel [ 0 ] = xyz2rgb ( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z ) ; pixel [ 1 ] = xyz2rgb ( - 0.9692660 * x + 1.8760108 * y + 0.0415560 * z ) ; pixel [ 2 ] = xyz2rgb ( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z ) ; return pixel ; }
Convert an HCL pixel into an RGB pixel.
@param {Array<number>} pixel A pixel in HCL space.
@return {Array<number>} A pixel in RGB space.
Convert an HCL pixel into an RGB pixel .