src/renderer/viz/colorspaces.js
function XYZToSRGB ({ x, y, z, a }) {
    // Poynton, "Frequently Asked Questions About Color," page 10
    // Wikipedia: http://en.wikipedia.org/wiki/SRGB
    // Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space

    // Convert XYZ to linear RGB
    const r = clamp(3.2406 * x - 1.5372 * y - 0.4986 * z, 0, 1);
    const g = clamp(-0.9689 * x + 1.8758 * y + 0.0415 * z, 0, 1);
    const b = clamp(0.0557 * x - 0.2040 * y + 1.0570 * z, 0, 1);

    return linearRGBToSRGB({ r, g, b, a });
}
function XYZToSRGB ({ x, y, z, a }) {
    // Poynton, "Frequently Asked Questions About Color," page 10
    // Wikipedia: http://en.wikipedia.org/wiki/SRGB
    // Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space

    // Convert XYZ to linear RGB
    const r = clamp(3.2406 * x - 1.5372 * y - 0.4986 * z, 0, 1);
    const g = clamp(-0.9689 * x + 1.8758 * y + 0.0415 * z, 0, 1);
    const b = clamp(0.0557 * x - 0.2040 * y + 1.0570 * z, 0, 1);

    return linearRGBToSRGB({ r, g, b, a });
}
function XYZToSRGB ( { x , y , z , a } ) { // Poynton, "Frequently Asked Questions About Color," page 10 // Wikipedia: http://en.wikipedia.org/wiki/SRGB // Wikipedia: http://en.wikipedia.org/wiki/CIE_1931_color_space // Convert XYZ to linear RGB const r = clamp ( 3.2406 * x - 1.5372 * y - 0.4986 * z , 0 , 1 ) ; const g = clamp ( - 0.9689 * x + 1.8758 * y + 0.0415 * z , 0 , 1 ) ; const b = clamp ( 0.0557 * x - 0.2040 * y + 1.0570 * z , 0 , 1 ) ; return linearRGBToSRGB ( { r , g , b , a } ) ; }
Convert CIE XYZ to sRGB with the D65 white point
Convert CIE XYZ to sRGB with the D65 white point