Right now, the API defines a ColorSpaceWhitePoint class, with static predefined values ColorSpaceWhitePoint.D50 and ColorSpaceWhitePoint.D65 that authors are supposed to reference in creating ColorSpace objects.
This means that in the case where the white point is something else, code would need to do things like if (c.white.x === ACES.x && c.white.y === ACES.y) to compare with it, not to mention that things like if (c.white === ColorSpaceWhitePoint.D65) do not account for creating ColorSpaceWhitePoint objects with the same x and y values as the predefined ones (which should really be identified as D50/D65).
Also, exposing a whole other interface just for this seems pointlessly heavyweight.
I would propose a different design:
- A private map of white point names to their x/y coords, pre-populated with D50 and D65, possibly a few more too.
- A static method on
ColorSpace to register a custom white point, which does not allow registration of duplicate values
- A static method on
ColorSpace to look up white point chromaticity values by their name
ColorSpaceOptions.white would be a string, referencing a registered whitepoint
This would allow handling white points as plain strings making equality checks easy.
Thoughts @svgeesus @tabatkins ?
Right now, the API defines a
ColorSpaceWhitePointclass, with static predefined valuesColorSpaceWhitePoint.D50andColorSpaceWhitePoint.D65that authors are supposed to reference in creatingColorSpaceobjects.This means that in the case where the white point is something else, code would need to do things like
if (c.white.x === ACES.x && c.white.y === ACES.y)to compare with it, not to mention that things likeif (c.white === ColorSpaceWhitePoint.D65)do not account for creating ColorSpaceWhitePoint objects with the same x and y values as the predefined ones (which should really be identified as D50/D65).Also, exposing a whole other interface just for this seems pointlessly heavyweight.
I would propose a different design:
ColorSpaceto register a custom white point, which does not allow registration of duplicate valuesColorSpaceto look up white point chromaticity values by their nameColorSpaceOptions.whitewould be a string, referencing a registered whitepointThis would allow handling white points as plain strings making equality checks easy.
Thoughts @svgeesus @tabatkins ?