This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is just https://bottosson.github.io/posts/gamutclipping/ crudely translated to TS | |
| type Lab = { L: number; a: number; b: number }; | |
| type RGB = { r: number; g: number; b: number }; | |
| type sRGB = { r: number; g: number; b: number }; | |
| function linear_srgb_to_oklab(c: RGB): Lab { | |
| const l = 0.4122214708 * c.r + 0.5363325363 * c.g + 0.0514459929 * c.b; | |
| const m = 0.2119034982 * c.r + 0.6806995451 * c.g + 0.1073969566 * c.b; | |
| const s = 0.0883024619 * c.r + 0.2817188376 * c.g + 0.6299787005 * c.b; |