B2G/gecko/toolkit/components/places/ColorConversion.js
/**
 * Given the RGB components of a color as integers from 0-255, return the
 * color in the Lab color space.
 *
 * @return An object with lightness, a, b properties holding those components
 *         of the color in the Lab color space.
 */
Given the RGB components of a color as integers from 0-255, return the
color in the Lab color space.

@return An object with lightness, a, b properties holding those components
of the color in the Lab color space.
Given the RGB components of a color as integers from 0 - 255 return the color in the Lab color space . @return An object with lightness a b properties holding those components of the color in the Lab color space .
function rgb2lab(r, g, b) {
  let xyz = rgb2xyz(r, g, b),
        x = xyz.x / 95.047,
        y = xyz.y / 100,
        z = xyz.z / 108.883;
  x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
  y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
  z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
  return {
    lightness: (116 * y) - 16,
    a:  500 * (x - y),
    b:  200 * (y - z)
  };
}
function rgb2lab ( r , g , b ) { let xyz = rgb2xyz ( r , g , b ) , x = xyz . x / 95.047 , y = xyz . y / 100 , z = xyz . z / 108.883 ; x = x > 0.008856 ? Math . pow ( x , 1 / 3 ) : ( 7.787 * x ) + ( 16 / 116 ) ; y = y > 0.008856 ? Math . pow ( y , 1 / 3 ) : ( 7.787 * y ) + ( 16 / 116 ) ; z = z > 0.008856 ? Math . pow ( z , 1 / 3 ) : ( 7.787 * z ) + ( 16 / 116 ) ; return { lightness : ( 116 * y ) - 16 , a : 500 * ( x - y ) , b : 200 * ( y - z ) } ; }
Given the RGB components of a color as integers from 0-255, return the
 color in the Lab color space.
Given the RGB components of a color as integers from 0 - 255 return the color in the Lab color space .