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

@return An object with x, y, z properties holding those components of the
color in the XYZ color space.
Given the RGB components of a color as integers from 0 - 255 return the color in the XYZ color space . @return An object with x y z properties holding those components of the color in the XYZ color space .
function rgb2xyz(r, g, b) {
  r /= 255;
  g /= 255;
  b /= 255;
  r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
  g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
  b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
  return {
    x: ((r * 0.4124) + (g * 0.3576) + (b * 0.1805)) * 100,
    y: ((r * 0.2126) + (g * 0.7152) + (b * 0.0722)) * 100,
    z: ((r * 0.0193) + (g * 0.1192) + (b * 0.9505)) * 100
  };
}
function rgb2xyz ( r , g , b ) { r /= 255 ; g /= 255 ; b /= 255 ; r = r > 0.04045 ? Math . pow ( ( ( r + 0.055 ) / 1.055 ) , 2.4 ) : ( r / 12.92 ) ; g = g > 0.04045 ? Math . pow ( ( ( g + 0.055 ) / 1.055 ) , 2.4 ) : ( g / 12.92 ) ; b = b > 0.04045 ? Math . pow ( ( ( b + 0.055 ) / 1.055 ) , 2.4 ) : ( b / 12.92 ) ; return { x : ( ( r * 0.4124 ) + ( g * 0.3576 ) + ( b * 0.1805 ) ) * 100 , y : ( ( r * 0.2126 ) + ( g * 0.7152 ) + ( b * 0.0722 ) ) * 100 , z : ( ( r * 0.0193 ) + ( g * 0.1192 ) + ( b * 0.9505 ) ) * 100 } ; }
Given the RGB components of a color as integers from 0-255, return the
 color in the XYZ color space.
Given the RGB components of a color as integers from 0 - 255 return the color in the XYZ color space .
// assume sRGB
