Skip to content

Calculating "inGamut(space)" #488

Discussion options

You must be logged in to vote

Easy peasy. Just call inGamut and send the space in that you want to test.

> let c = new Color('rec2020', [0, 0, 1]).to('oklch')
undefined
> c.coords
[ 0.42344825660521684, 0.3828105916181844, 245.0667522688908 ]
> c.inGamut('rec2020')
true
> c.inGamut('srgb')
false

Internally, yes, it converts the color space to the specified gamut. It does check the range. It doesn't care about refRange as those are defined only as references for percentages, only if a color has a defined range is it bound to a gamut.

Hope that makes sense. Most of the time, you don't need to know any of that, but it is nice to be able to understand what is going on to have a deeper understanding of what is really happe…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@SoftMoonWebWare
Comment options

Answer selected by SoftMoonWebWare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants