Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions css-color/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2889,24 +2889,24 @@ function lin_sRGB_to_XYZ(rgb) {
// convert an array of linear-light sRGB values to CIE XYZ
// using sRGB's own white, D65 (no chromatic adaptation)
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
var M = math.matrix([
var M = Math.matrix([
[0.4124564, 0.3575761, 0.1804375],
[0.2126729, 0.7151522, 0.0721750],
[0.0193339, 0.1191920, 0.9503041]
]);

return math.multiply(M, rgb).valueOf();
return Math.multiply(M, rgb).valueOf();
}

function XYZ_to_lin_sRGB(XYZ) {
// convert XYZ to linear-light sRGB
var M = math.matrix([
var M = Math.matrix([
[ 3.2404542, -1.5371385, -0.4985314],
[-0.9692660, 1.8760108, 0.0415560],
[ 0.0556434, -0.2040259, 1.0572252]
]);

return math.multiply(M, XYZ).valueOf();
return Math.multiply(M, XYZ).valueOf();
}

// image-p3-related functions
Expand Down Expand Up @@ -2942,25 +2942,25 @@ function lin_P3_to_XYZ(rgb) {
// convert an array of linear-light P3 values to CIE XYZ
// using D65 (no chromatic adaptation)
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
var M = math.matrix([
var M = Math.matrix([
[0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
[0.2289745640697488, 0.6917385218365064, 0.079286914093745],
[0.0000000000000000, 0.04511338185890264, 1.043944368900976]
]);
// 0 was computed as -3.972075516933488e-17

return math.multiply(M, rgb).valueOf();
return Math.multiply(M, rgb).valueOf();
}

function XYZ_to_lin_P3(XYZ) {
// convert XYZ to linear-light P3
var M = math.matrix([
var M = Math.matrix([
[ 2.493496911941425, -0.9313836179191239, -0.40271078445071684],
[-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],
[ 0.03584583024378447, -0.07617238926804182, 0.9568845240076872]
]);

return math.multiply(M, XYZ).valueOf();
return Math.multiply(M, XYZ).valueOf();
}

//Rec. 2020-related functions
Expand All @@ -2986,25 +2986,25 @@ function lin_2020_to_XYZ(rgb) {
// convert an array of linear-light Rec. 2020 values to CIE XYZ
// using D65 (no chromatic adaptation)
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
var M = math.matrix([
var M = Math.matrix([
[0.6369580483012914, 0.14461690358620832, 0.1688809751641721],
[0.2627002120112671, 0.6779980715188708, 0.05930171646986196],
[0.000000000000000, 0.028072693049087428, 1.060985057710791]
]);
// 0 is actually calculated as 4.994106574466076e-17

return math.multiply(M, rgb).valueOf();
return Math.multiply(M, rgb).valueOf();
}

function XYZ_to_lin_2020(XYZ) {
// convert XYZ to linear-light Rec. 2020
var M = math.matrix([
var M = Math.matrix([
[1.7166511879712674, -0.35567078377639233, -0.25336628137365974],
[-0.6666843518324892, 1.6164812366349395, 0.01576854581391113],
[0.017639857445310783, -0.042770613257808524, 0.9421031212354738]
]);

return math.multiply(M, XYZ).valueOf();
return Math.multiply(M, XYZ).valueOf();
}

// Chromatic adaptation
Expand All @@ -3016,24 +3016,24 @@ function D65_to_D50(XYZ) {
// - scale components from one reference white to another
// - convert back to XYZ
// http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
var M = math.matrix([
var M = Math.matrix([
[ 1.0478112, 0.0228866, -0.0501270],
[ 0.0295424, 0.9904844, -0.0170491],
[-0.0092345, 0.0150436, 0.7521316]
]);

return math.multiply(M, XYZ).valueOf();
return Math.multiply(M, XYZ).valueOf();
}

function D50_to_D65(XYZ) {
// Bradford chromatic adaptation from D50 to D65
var M = math.matrix([
var M = Math.matrix([
[ 0.9555766, -0.0230393, 0.0631636],
[-0.0282895, 1.0099416, 0.0210077],
[ 0.0122982, -0.0204830, 1.3299098]
]);

return math.multiply(M, XYZ).valueOf();
return Math.multiply(M, XYZ).valueOf();
}

// Lab and LCH
Expand Down