allc
Version:
A small typescript package for color conversion.
39 lines (38 loc) • 2.25 kB
JavaScript
// This file was automatically generated by `src-comptime/precalculate.ts`.
import { MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_0, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_1, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_2, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_0, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_1, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_2, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_0, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_1, MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_2, } from "../../matrices";
/**
* Calculates the X component of CIE 1931 XYZ from linear NTSC (1953).
*
* @param r The red component of linear NTSC (1953), typically in the range [0, 1].
* @param g The green component of linear NTSC (1953), typically in the range [0, 1].
* @param b The blue component of linear NTSC (1953), typically in the range [0, 1].
*
* @returns The X component of CIE 1931 XYZ.
*/
export const toCIE1931XYZXFromLinearNTSC = (r, g, b) => r * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_0
+ g * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_1
+ b * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_0_2;
/**
* Calculates the Y component of CIE 1931 XYZ from linear NTSC (1953).
*
* @param r The red component of linear NTSC (1953), typically in the range [0, 1].
* @param g The green component of linear NTSC (1953), typically in the range [0, 1].
* @param b The blue component of linear NTSC (1953), typically in the range [0, 1].
*
* @returns The Y component of CIE 1931 XYZ.
*/
export const toCIE1931XYZYFromLinearNTSC = (r, g, b) => r * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_0
+ g * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_1
+ b * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_1_2;
/**
* Calculates the Z component of CIE 1931 XYZ from linear NTSC (1953).
*
* @param r The red component of linear NTSC (1953), typically in the range [0, 1].
* @param g The green component of linear NTSC (1953), typically in the range [0, 1].
* @param b The blue component of linear NTSC (1953), typically in the range [0, 1].
*
* @returns The Z component of CIE 1931 XYZ.
*/
export const toCIE1931XYZZFromLinearNTSC = (r, g, b) => r * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_0
+ g * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_1
+ b * MATRIX_CIE_1931_XYZ_FROM_LINEAR_NTSC_2_2;