Skip to content

Commit

Permalink
XYZ: Switched reference white point. Relates to #18
Browse files Browse the repository at this point in the history
Munter committed Mar 17, 2013
1 parent b062e10 commit 0ca4f6f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/color/XYZ.js
Original file line number Diff line number Diff line change
@@ -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
);
},

0 comments on commit 0ca4f6f

Please sign in to comment.