Calculating "inGamut(space)" #488
-
Aloha! I really want to understand HOW this repo calculates "inGamut". I think I understand that it checks the "Color Object's" "range" or "refRange" property, or converts it to the color-space who's gamut we are trying to find, then checks these values. Is this correct? For instance, I want to know if "OKLCh( _L, _C, _h)" is in the P3 gamut or the Rec.2020 gamut or ... maybe ? ... the UHD gamut? I need to convert to those color-spaces (though the XYZ space), then check if their values are in range? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Easy peasy. Just call > 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 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 happening. |
Beta Was this translation helpful? Give feedback.
Easy peasy. Just call
inGamut
and send the space in that you want to test.Internally, yes, it converts the color space to the specified gamut. It does check the
range
. It doesn't care aboutrefRange
as those are defined only as references for percentages, only if a color has a definedrange
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…