From 0ca4f6fba5b2f02fb917664eeae23897ebea5764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20M=C3=BCller?= Date: Sun, 17 Mar 2013 22:52:55 +0100 Subject: [PATCH] XYZ: Switched reference white point. Relates to #18 --- lib/color/XYZ.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/color/XYZ.js b/lib/color/XYZ.js index ac6e412..87104b1 100644 --- a/lib/color/XYZ.js +++ b/lib/color/XYZ.js @@ -5,7 +5,6 @@ installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], { fromRgb: function () { // http://www.easyrgb.com/index.php?X=MATH&H=02#text2 var convert = function (channel) { - // assume sRGB return channel > 0.04045 ? Math.pow((channel + 0.055) / 1.055, 2.4) : channel / 12.92; @@ -14,10 +13,12 @@ installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], { g = convert(this._green), b = convert(this._blue); + // Reference white point sRGB D65: + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html return new ONECOLOR.XYZ( - r * 0.412453 + g * 0.35758 + b * 0.180423, - r * 0.212671 + g * 0.71516 + b * 0.072169, - r * 0.019334 + g * 0.119193 + b * 0.950227, + r * 0.4124564 + g * 0.3575761 + b * 0.1804375, + r * 0.2126729 + g * 0.7151522 + b * 0.0721750, + r * 0.0193339 + g * 0.1191920 + b * 0.9503041, this._alpha ); }, @@ -33,10 +34,12 @@ installColorSpace('XYZ', ['x', 'y', 'z', 'alpha'], { 12.92 * channel; }; + // Reference white point sRGB D65: + // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html return new ONECOLOR.RGB( - convert(x * 3.240479 + y * -1.53715 + z * -0.498535), - convert(x * -0.969256 + y * 1.875991 + z * 0.041556), - convert(x * 0.055648 + y * -0.204043 + z * 1.057311), + convert(x * 3.2404542 + y * -1.5371385 + z * -0.4985314), + convert(x * -0.9692660 + y * 1.8760108 + z * 0.0415560), + convert(x * 0.0556434 + y * -0.2040259 + z * 1.0572252), this._alpha ); },