- From: Natalie Weizenbaum via GitHub <sysbot+gh@w3.org>
- Date: Fri, 02 Sep 2022 01:23:44 +0000
- To: public-css-archive@w3.org
nex3 has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-color-4] Linear transformation matrices are very slightly inaccurate == The [sample code for color conversions](https://www.w3.org/TR/css-color-4/#color-conversion-code) in Color Level 4 lists a number of matrices to use to convert between color values. I've been pre-computing the linear transformations from one colorspace to another for Sass using lossless numeric logic to avoid floating-point rounding errors, and in doing so I noticed some very very slight inaccuracies in the listed matrices. These are all at the level of floating-point rounding errors, so unlikely to be particularly significant in the real world, but I thought it might be desirable to have the example code be as accurate as possible up to the limits of the floating-point representation. Here are the most precise 64-bit floating-point representations of the various transformations I've looked at so far, generated by [this script](https://gist.github.com/nex3/bb38b7204ba22b7e3bc8f4d4a8c1bdba): ```js // srgb to xyz-d65 var M = [ 0.41239079926595950, 0.35758433938387796, 0.18048078840183430, 0.21263900587151036, 0.71516867876775590, 0.07219231536073371, 0.01933081871559185, 0.11919477979462598, 0.95053215224966060 ]; // xyz-d65 to srgb var M = [ 3.24096994190452130, -1.53738317757009350, -0.49861076029300330, -0.96924363628087980, 1.87596750150772060, 0.04155505740717561, 0.05563007969699360, -0.20397695888897657, 1.05697151424287860 ]; // display-p3 to xyz-d65 var M = [ 0.48657094864821626, 0.26566769316909294, 0.19821728523436250, 0.22897456406974884, 0.69173852183650620, 0.07928691409374500, 0.00000000000000000, 0.04511338185890257, 1.04394436890097570 ]; // xyz-d65 to display-p3 var M = [ 2.49349691194142450, -0.93138361791912360, -0.40271078445071684, -0.82948896956157490, 1.76266406031834680, 0.02362468584194359, 0.03584583024378433, -0.07617238926804170, 0.95688452400768730 ]; // a98-rgb to xyz-d65 var M = [ 0.57666904291013080, 0.18555823790654627, 0.18822864623499472, 0.29734497525053616, 0.62736356625546600, 0.07529145849399789, 0.02703136138641237, 0.07068885253582714, 0.99133753683763890 ]; // xyz-d65 to a98-rgb var M = [ 2.04158790381074600, -0.56500697427885960, -0.34473135077832950, -0.96924363628087980, 1.87596750150772060, 0.04155505740717561, 0.01344428063203102, -0.11836239223101823, 1.01517499439120540 ]; // rec2020 to xyz-d65 var M = [ 0.63695804830129130, 0.14461690358620838, 0.16888097516417205, 0.26270021201126703, 0.67799807151887100, 0.05930171646986194, 0.00000000000000000, 0.02807269304908750, 1.06098505771079090 ]; // xyz-d65 to rec2020 var M = [ 1.71665118797126760, -0.35567078377639240, -0.25336628137365980, -0.66668435183248900, 1.61648123663493900, 0.01576854581391113, 0.01763985744531091, -0.04277061325780865, 0.94210312123547400 ]; // prophoto-rgb to xyz-d50 var M = [ 0.79776664490064230, 0.13518129740053308, 0.03134773412839220, 0.28807482881940130, 0.71183523424187300, 0.00008993693872564, 0.00000000000000000, 0.00000000000000000, 0.82510460251046020 ]; // xyz-d50 to prophoto-rgb var M = [ 1.34578688164715830, -0.25557208737979464, -0.05110186497554526, -0.54463070512490190, 1.50824774284514680, 0.02052744743642139, 0.00000000000000000, 0.00000000000000000, 1.21196754563894520 ]; // xyz-d65 to xyz-d50 var M = [ 1.04792979254499660, 0.02294687060160952, -0.05019226628920519, 0.02962780877005567, 0.99043442675388000, -0.01707379906341879, -0.00924304064620452, 0.01505519149029816, 0.75187428142813700 ]; // xyz-d50 to xyz-d65 var M = [ 0.95547342148807520, -0.02309845494876452, 0.06325924320057065, -0.02836970933386358, 1.00999539808130410, 0.02104144119191730, 0.01231401486448199, -0.02050764929889898, 1.33036592624212400 ]; ``` Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7675 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 2 September 2022 01:23:46 UTC