allc
Version:
A small typescript package for color conversion.
23 lines (22 loc) • 1.01 kB
JavaScript
/**
* Calculates the X component of CIE 1931 XYZ from CIE 1931 xyY.
*
* @param x The x component of CIE 1931 xyY, typically in the range [0, 1].
* @param y The y component of CIE 1931 xyY, typically in the range [0, 1].
* @param Y The Y component of CIE 1931 xyY, typically in the range [0, 1].
*
* @returns The X component of CIE 1931 XYZ.
* @see https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xyY_color_space
*/
export const toCIE1931XYZXFromCIE1931xyY = (x, y, Y) => x * Y / y;
/**
* Calculates the Z component of CIE 1931 XYZ from CIE 1931 xyY.
*
* @param x The x component of CIE 1931 xyY, typically in the range [0, 1].
* @param y The y component of CIE 1931 xyY, typically in the range [0, 1].
* @param Y The Y component of CIE 1931 xyY, typically in the range [0, 1].
*
* @returns The Z component of CIE 1931 XYZ.
* @see https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xyY_color_space
*/
export const toCIE1931XYZZFromCIE1931xyY = (x, y, Y) => (1 - x - y) * Y / y;