Skip to content

Commit 6407b4e

Browse files
committed
[css-color-4] add porting hint regarding sign-preserving cube root
1 parent e2d6d38 commit 6407b4e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

css-color-4/conversions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ function XYZ_to_OKLab(XYZ) {
410410
];
411411

412412
var LMS = multiplyMatrices(XYZtoLMS, XYZ);
413+
// JavaScript Math.cbrt returns a sign-matched cube root
414+
// beware if porting to other languages
415+
// especially if tempted to use a general power function
413416
return multiplyMatrices(LMStoOKLab, LMS.map(c => Math.cbrt(c)));
414417
// L in range [0,1]. For use in CSS, multiply by 100 and add a percent
415418
}

0 commit comments

Comments
 (0)