Replies: 3 comments 1 reply
-
Hi @dokozero, thank you for your suggestion. Culori has a bit too many gamut mapping functions because in the beginning they were sRGB oriented. We had This set of sRGB-based functions got upgraded to more generic methods:
The move from first-order function to higher-order function, that is from a function that you can invoke for a color to a function that returns a function, was intentional. This allows us to do the prep work for the destination gamut once, upfront, which makes the actual gamut mapping functions closer in performance to the originals. The difference between const clampToP3 = toGamut('p3', 'oklch', differenceEuclidean('oklch'), 0); It’s improbable that we will add new features to the old functions, but I think we can make the const clampToP3 = toGamut('p3', 'oklch', null); Later edit: Updated to replace |
Beta Was this translation helpful? Give feedback.
-
Fixed in |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick reply and even a new release, wow 🙏 Indeed, I better understand now the timeline history and role of these functions. I will then see to use Thanks again for your work on the lib. |
Beta Was this translation helpful? Give feedback.
-
Hello @danburzo,
I use Culori for the OkColor Figma plugin and it's quite useful, however, regarding gamut clipping by the chroma only, when I saw clampGamut() for the first time, I thought that it has an option to specify the target gamut to clamp.
As it was not the case, I ended up making a local modified version that uses inGamut() instead of displayable(), as I read from doc that it was equivalent to inGamut('rgb'). However, I had to duplicate culori's main js file into my project.
With this update, I'm able to easily clamp to sRGB or P3 gamut. I don't use toGamut() as I need to keep the same hue and lightness.
I saw previous issue regarding this topic and my suggestion would be to add a new optional target gamut param to clampChroma(), default to 'rgb' for retro-compatibility:
For comparison, current code:
I saw your answer from #211, with:
But personally, I think the new param on clampChroma() would be nice.
Thanks for your time.
Beta Was this translation helpful? Give feedback.
All reactions