@@ -83,21 +83,26 @@ function gam_2020(RGB) {
8383 } ) ;
8484}
8585
86- function lin_sRGB_to_XYZ ( rgb ) {
87- // convert an array of linear-light sRGB values to CIE XYZ
88- // using sRGB's own white, D65 (no chromatic adaptation)
86+ function lin_2020_to_XYZ ( rgb ) {
87+ // convert an array of linear-light rec.2020 values to CIE XYZ
88+ // using D65 (no chromatic adaptation)
8989 // http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
9090 var M = math . matrix ( [
91- [ // calculate per Libdbloom
91+ [ 0.6369580483012914 , 0.14461690358620832 , 0.1688809751641721 ] ,
92+ [ 0.2627002120112671 , 0.6779980715188708 , 0.05930171646986196 ] ,
93+ [ 0.000000000000000 , 0.028072693049087428 , 1.060985057710791 ]
9294 ] ) ;
95+ // 0 is actually calculated as 4.994106574466076e-17
9396
9497 return math . multiply ( M , rgb ) . valueOf ( ) ;
9598}
9699
97- function XYZ_to_lin_sRGB ( XYZ ) {
98- // convert XYZ to linear-light sRGB
100+ function XYZ_to_lin_2020 ( XYZ ) {
101+ // convert XYZ to linear-light rec.2020
99102 var M = math . matrix ( [
100- [ // calculate per Libdbloom
103+ [ 1.7166511879712674 , - 0.35567078377639233 , - 0.25336628137365974 ] ,
104+ [ - 0.6666843518324892 , 1.6164812366349395 , 0.01576854581391113 ] ,
105+ [ 0.017639857445310783 , - 0.042770613257808524 , 0.9421031212354738 ]
101106 ] ) ;
102107
103108 return math . multiply ( M , XYZ ) . valueOf ( ) ;
0 commit comments