Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get wrong color output when input color is LCH #103

Open
saadeghi opened this issue Apr 20, 2023 · 2 comments
Open

I get wrong color output when input color is LCH #103

saadeghi opened this issue Apr 20, 2023 · 2 comments

Comments

@saadeghi
Copy link

When I give an LCH color to the function, I get a different color in the output.
For example this is my color: lch(58.68% 98.6 352.06) (which is a valid P3 color)

And using toLchString I expect the same values:

colord('lch(58.68% 98.6 352.06)').toLchString()

But the result is:

lch(56.75% 87.94 348.82)

Here's a live example: https://svelte.dev/repl/14e79bf716994c98956d6b27ae0065a5?version=3.58.0

@typhonrt
Copy link

I can at least comment and provide some insight. As things go the intermediary format internal to colord is RGBA. Even using the various other format methods everything passes through RGBA internally and won't maintain precision for anything beyond the sRGB color space. There are also rounding / precision aspects elsewhere in the code.

I really like the colord API and structure, but it does lack in precise control.

For precise control colorjs / https://colorjs.io/ is a fair candidate though the API and general structure is less than to be desired.

In an ideal world a solution that combines the API structure of colord w/ the data & format handling of colorjs would be ideal.

@typhonrt
Copy link

@saadeghi; Just for curiosities sake since you mentioned Svelte I am using a slightly modified version of colord (correct a precision aspect) for a high powered Svelte color picker component; (initial dev snapshot video). Also uses container queries and I implemented the fixes / support in Svelte 3.58.0 to make that so.

You can see the code for that here which shows that colord is adequate for a sRGB color space / picker; still required some work arounds. Internally the picker works w/ HSV. Code here:
https://github.com/typhonjs-fvtt-lib/svelte-standard/tree/main/src/component/standard/color/picker-colord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants