@@ -391,13 +391,16 @@ function LCH_to_Lab(LCH) {
391391// OKLab and OKLCH
392392// https://bottosson.github.io/posts/oklab/
393393
394+ // XYZ <-> LMS matrices recalculated for consistent reference white
395+ // see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
396+
394397function XYZ_to_OKLab ( XYZ ) {
395398 // Given XYZ relative to D65, convert to OKLab
396399 var XYZtoLMS = [
397- [ 0.8189330101 , 0.3618667424 , - 0.1288597137 ] ,
398- [ 0.0329845436 , 0.9293118715 , 0.0361456387 ] ,
399- [ 0.0482003018 , 0.2643662691 , 0.6338517070 ]
400- ] ;
400+ [ 0.8190224432164319 , 0.3619062562801221 , - 0.12887378261216414 ] ,
401+ [ 0.0329836671980271 , 0.9292868468965546 , 0.03614466816999844 ] ,
402+ [ 0.048177199566046255 , 0.26423952494422764 , 0.6335478258136937 ]
403+ ] ;
401404 var LMStoOKLab = [
402405 [ 0.2104542553 , 0.7936177850 , - 0.0040720468 ] ,
403406 [ 1.9779984951 , - 2.4285922050 , 0.4505937099 ] ,
@@ -412,10 +415,10 @@ function XYZ_to_OKLab(XYZ) {
412415function OKLab_to_XYZ ( OKLab ) {
413416 // Given OKLab, convert to XYZ relative to D65
414417 var LMStoXYZ = [
415- [ 1.227013851103521026 , - 0.5577999806518222383 , 0.28125614896646780758 ] ,
416- [ - 0.040580178423280593977 , 1.1122568696168301049 , - 0.071676678665601200577 ] ,
417- [ - 0.076381284505706892869 , - 0.42148197841801273055 , 1.5861632204407947575 ]
418- ] ;
418+ [ 1.2268798733741557 , - 0.5578149965554813 , 0.28139105017721583 ] ,
419+ [ - 0.04057576262431372 , 1.1122868293970594 , - 0.07171106666151701 ] ,
420+ [ - 0.07637294974672142 , - 0.4214933239627914 , 1.5869240244272418 ]
421+ ] ;
419422 var OKLabtoLMS = [
420423 [ 0.99999999845051981432 , 0.39633779217376785678 , 0.21580375806075880339 ] ,
421424 [ 1.0000000088817607767 , - 0.1055613423236563494 , - 0.063854174771705903402 ] ,
0 commit comments