Re: [csswg-drafts] [css-color4] Precision issues when converting colors between Lab and sRGB (#5262)

You might find [this thread](https://github.com/w3c/csswg-drafts/issues/2492) useful. I'm hard-pressed remembering the exact details, but you can look at the conversions in [culori](https://github.com/evercoder/culori). I think the errors in a rgb -> lab -> rgb roundtrip are now negligible, or at least don't produce a different hex code.

You can test with this sample code:

```js
let culori = require('culori');
let hex = culori.formatter('hex');

for (var r = 0; r <= 255; r++) {
    for (var g = 0; g <= 255; g++) {
        for (var b = 0; b <= 255; b++) {
            let c = {
                mode: 'rgb',
                r: r/255,
                g: g/255,
                b: b/255
            };
            let ret = culori.rgb(culori.lab(c));
            if (hex(c) !== hex(ret)) {
                console.log(hex(c), hex(ret));
            }
        }
    }
}
```

-- 
GitHub Notification of comment by danburzo
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5262#issuecomment-651223980 using your GitHub account

Received on Monday, 29 June 2020 16:21:12 UTC