Skip to content

Instantly share code, notes, and snippets.

@davidsonfellipe
Last active December 17, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsonfellipe/5670524 to your computer and use it in GitHub Desktop.
Save davidsonfellipe/5670524 to your computer and use it in GitHub Desktop.
function colorCIEXYZtosRGB(XYZ) {
var RGBTEMP = {R:0,
G:0,
B:0};
RGBTEMP.R = 3.2404542 * XYZ.X - 1.5371385 * XYZ.Y - 0.4985314 * XYZ.Z;
RGBTEMP.G =-0.9692660 * XYZ.X + 1.8760108 * XYZ.Y + 0.0415560 * XYZ.Z;
RGBTEMP.B = 0.0556434 * XYZ.X - 0.2040259 * XYZ.Y + 1.0572252 * XYZ.Z;
//converter for 0-255 notation
var cmultiply = 255;
RGBTEMP.R = gamma_sRGB(RGBTEMP.R) * cmultiply;
RGBTEMP.G = gamma_sRGB(RGBTEMP.G) * cmultiply;
RGBTEMP.B = gamma_sRGB(RGBTEMP.B) * cmultiply;
return RGBTEMP;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment