Skip to content

Commit

Permalink
Update LMS matrices
Browse files Browse the repository at this point in the history
This recomputes all existing LMS-related matrices based on the
improved XYZD65/LMS matrices in
w3c/csswg-drafts#6642#issuecomment-1490068959.

See sass/sass-spec#2024
  • Loading branch information
nex3 committed Oct 2, 2024
1 parent 5acae8a commit 4852b97
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 48 deletions.
15 changes: 9 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

* Changes to how `selector.unify()` and `@extend` combine selectors:

* The relative order of pseudo-classes (like `:hover`) and pseudo-elements
(like `::before`) within each original selector is now preserved when
they're combined.
* The relative order of pseudo-classes (like `:hover`) and pseudo-elements
(like `::before`) within each original selector is now preserved when
they're combined.

* Pseudo selectors are now consistently placed at the end of the combined
selector, regardless of which selector they came from. Previously, this
reordering only applied to pseudo-selectors in the second selector.
* Pseudo selectors are now consistently placed at the end of the combined
selector, regardless of which selector they came from. Previously, this
reordering only applied to pseudo-selectors in the second selector.

* Tweak the color transformation matrices for OKLab and OKLCH to match the
newer, more accurate values in the CSS spec.

### JS API

Expand Down
84 changes: 42 additions & 42 deletions lib/src/value/color/conversions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ final xyzD65ToLinearSrgb = Float64List.fromList([

// The transformation matrix for converting linear-light srgb colors to lms.
final linearSrgbToLms = Float64List.fromList([
00.41222147080000016, 00.53633253629999990, 00.05144599290000001, //
00.21190349820000007, 00.68069954509999990, 00.10739695660000000,
00.08830246190000005, 00.28171883759999994, 00.62997870050000000,
00.41222147138885257, 00.53633253868572990, 00.05144598992541749, //
00.21190349632606145, 00.68069955034882620, 00.10739695332511232,
00.08830246016417313, 00.28171883780354560, 00.62997870203228130,
]);

// The transformation matrix for converting lms colors to linear-light srgb.
final lmsToLinearSrgb = Float64List.fromList([
04.07674166134799300, -3.30771159040819240, 00.23096992872942781, //
-1.26843800409217660, 02.60975740066337240, -0.34131939631021974,
-0.00419608654183720, -0.70341861445944950, 01.70761470093094480,
04.07674161829676400, -3.30771154414822680, 00.23096992585146275, //
-1.26843797009867250, 02.60975735258027400, -0.34131938248160143,
-0.00419608405595702, -0.70341860768769470, 01.70761469174365170,
]);

// The transformation matrix for converting linear-light srgb colors to
Expand Down Expand Up @@ -192,17 +192,17 @@ final xyzD65ToLinearDisplayP3 = Float64List.fromList([
// The transformation matrix for converting linear-light display-p3 colors to
// lms.
final linearDisplayP3ToLms = Float64List.fromList([
00.48137985442585490, 00.46211836973903553, 00.05650177583510960, //
00.22883194490233110, 00.65321681282840370, 00.11795124216926511,
00.08394575573016760, 00.22416526885956980, 00.69188897541026260,
00.48137985510524084, 00.46211837232655495, 00.05650177256820415, //
00.22883194245042954, 00.65321681897702810, 00.11795123857254243,
00.08394575356523270, 00.22416526934164066, 00.69188897709312670,
]);

// The transformation matrix for converting lms colors to linear-light
// display-p3.
final lmsToLinearDisplayP3 = Float64List.fromList([
03.12776898667772140, -2.25713579553953770, 00.12936680863610234, //
-1.09100904738343900, 02.41333175827934370, -0.32232271065457110,
-0.02601081320950207, -0.50804132569306730, 01.53405213885176520,
03.12776895730486260, -2.25713576602905400, 00.12936680872419120, //
-1.09100901594737330, 02.41333171332788780, -0.32232269738051444,
-0.02601080922044420, -0.50804132221810080, 01.53405213143854500,
]);

// The transformation matrix for converting linear-light display-p3 colors to
Expand Down Expand Up @@ -269,16 +269,16 @@ final xyzD65ToLinearA98Rgb = Float64List.fromList([

// The transformation matrix for converting linear-light a98-rgb colors to lms.
final linearA98RgbToLms = Float64List.fromList([
00.57643226147714040, 00.36991322114441194, 00.05365451737844765, //
00.29631647387335260, 00.59167612662650690, 00.11200739940014041,
00.12347825480374285, 00.21949869580674647, 00.65702304938951070,
00.57643226230056550, 00.36991322342326505, 00.05365451427616932, //
00.29631647125291970, 00.59167613276241520, 00.11200739598466511,
00.12347825237643931, 00.21949869663598945, 00.65702305098757130,
]);

// The transformation matrix for converting lms colors to linear-light a98-rgb.
final lmsToLinearA98Rgb = Float64List.fromList([
02.55403684790806950, -1.62197620262602140, 00.06793935455575403, //
-1.26843800409217660, 02.60975740066337240, -0.34131939631021974,
-0.05623474718052319, -0.56704183411879500, 01.62327658124261400,
02.55403682680491200, -1.62197618324197860, 00.06793935643706676, //
-1.26843797009867250, 02.60975735258027400, -0.34131938248160143,
-0.05623474339772783, -0.56704182960497270, 01.62327657300270060,
]);

// The transformation matrix for converting linear-light a98-rgb colors to
Expand Down Expand Up @@ -329,16 +329,16 @@ final xyzD65ToLinearRec2020 = Float64List.fromList([

// The transformation matrix for converting linear-light rec2020 colors to lms.
final linearRec2020ToLms = Float64List.fromList([
00.61675578719908560, 00.36019839939276255, 00.02304581340815186, //
00.26513306398328140, 00.63583936407771060, 00.09902757183900800,
00.10010263423281572, 00.20390651940192997, 00.69599084636525430,
00.61675578793371700, 00.36019840204870220, 00.02304581001758089, //
00.26513306027732110, 00.63583937145469350, 00.09902756826798550,
00.10010263129732697, 00.20390652049845495, 00.69599084820421810,
]);

// The transformation matrix for converting lms colors to linear-light rec2020.
final lmsToLinearRec2020 = Float64List.fromList([
02.13990673569556170, -1.24638950878469060, 00.10648277296448995, //
-0.88473586245815630, 02.16323098210838260, -0.27849511943390290,
-0.04857375801465988, -0.45450314291725170, 01.50307690088646130,
02.13990671998620800, -1.24638949530065100, 00.10648277531444307, //
-0.88473583414623400, 02.16323094116741240, -0.27849510702117836,
-0.04857375350210826, -0.45450314032618530, 01.50307689382829350,
]);

// The transformation matrix for converting linear-light rec2020 colors to
Expand Down Expand Up @@ -375,16 +375,16 @@ final xyzD50ToLinearRec2020 = Float64List.fromList([

// The transformation matrix for converting xyz colors to lms.
final xyzD65ToLms = Float64List.fromList([
00.81902244321643190, 00.36190625628012210, -0.12887378261216414, //
00.03298366719802710, 00.92928684689655460, 00.03614466816999844,
00.04817719956604625, 00.26423952494422764, 00.63354782581369370,
00.81902244264705500, 00.36190626045712860, -0.12887378595068213, //
00.03298365585507450, 00.92928686029214570, 00.03614466586101669,
00.04817719382823899, 00.26423952768215370, 00.63354782830723170,
]);

// The transformation matrix for converting lms colors to xyz.
final lmsToXyzD65 = Float64List.fromList([
01.22687987337415570, -0.55781499655548140, 00.28139105017721590, //
-0.04057576262431372, 01.11228682939705960, -0.07171106666151703,
-0.07637294974672143, -0.42149332396279143, 01.58692402442724180,
01.22687986822442300, -0.55781499344988840, 00.28139105227713695, //
-0.04057574728813354, 01.11228680533507540, -0.07171105804694196,
-0.07637294416417968, -0.42149332236303200, 01.58692401728709000,
]);

// The transformation matrix for converting xyz colors to linear-light
Expand Down Expand Up @@ -420,31 +420,31 @@ final xyzD50ToXyzD65 = Float64List.fromList([
// The transformation matrix for converting lms colors to linear-light
// prophoto-rgb.
final lmsToLinearProphotoRgb = Float64List.fromList([
01.73835514985815240, -0.98795095237343430, 00.24959580241648663, //
-0.70704942624914860, 01.93437008438177620, -0.22732065793919040,
-0.08407883426424761, -0.35754059702097796, 01.44161943124947150,
01.73835513864467300, -0.98795094281205530, 00.24959580416738236, //
-0.70704940072157860, 01.93437004712371500, -0.22732064640213650,
-0.08407882883965313, -0.35754059603703590, 01.44161942487668900,
]);

// The transformation matrix for converting linear-light prophoto-rgb colors to
// lms.
final linearProphotoRgbToLms = Float64List.fromList([
00.71544846349294310, 00.35279154798172740, -0.06824001147467047, //
00.27441165509049420, 00.66779764080811480, 00.05779070400139092,
00.10978443849083751, 00.18619828746596980, 00.70401727404319270,
00.71544846417043570, 00.35279155094776693, -0.06824001511820267, //
00.27441165010515200, 00.66779764913879360, 00.05779070075605438,
00.10978443489981345, 00.18619828874488772, 00.70401727635529890,
]);

// The transformation matrix for converting lms colors to xyz-d50.
final lmsToXyzD50 = Float64List.fromList([
01.28858621583908840, -0.53787174651736210, 00.21358120705405403, //
-0.00253389352489796, 01.09231682453266550, -0.08978293089853581,
-0.06937383312514489, -0.29500839218634667, 01.18948682779245090,
01.28858621051424720, -0.53787174389536140, 00.21358120981068188, //
-0.00253387858330763, 01.09231680076554620, -0.08978292218223852,
-0.06937382864928701, -0.29500839137449160, 01.18948682253423880,
]);

// The transformation matrix for converting xyz-d50 colors to lms.
final xyzD50ToLms = Float64List.fromList([
00.77070004712402500, 00.34924839871072740, -0.11202352004249890, //
00.00559650559780223, 00.93707232493333150, 00.06972569131301698,
00.04633715253432816, 00.25277530868525870, 00.85145807371608350,
00.77070004642038950, 00.34924840301110160, -0.11202352443207758, //
00.00559649435145064, 00.93707233877217320, 00.06972568780554228,
00.04633714700503712, 00.25277531153194930, 00.85145807672804210,
]);

// The transformation matrix for converting linear-light prophoto-rgb colors to
Expand Down

0 comments on commit 4852b97

Please sign in to comment.