colr 0.1.1

A general purpose, extensible color type unifying storage, channel layouts, and color spaces at the type level.
Documentation
//! CIE standard illuminants and reference white points.
//!
//! Chromaticity coordinates per CIE 015:2018 (Colorimetry, 4th ed.).
//! XYZ values are Y=1 normalized tristimulus from ASTM E308.
//! ACES white point per Academy TB-2018-001 and SMPTE ST 2065-1:2021.

/// A CIE standard illuminant defining a reference white point.
pub trait Illuminant: 'static {
    /// CIE 1931 xy chromaticity of the reference white.
    const WHITE_POINT_XY: [f32; 2];
    /// CIE 1931 XYZ reference white normalized to Y = 1.
    const WHITE_POINT_XYZ: [f32; 3];
}

/// CIE standard illuminant D65 (~6504 K).
///
/// Reference white for sRGB (IEC 61966-2-1), Rec. 709, Display P3,
/// and Rec. 2020 (ITU-R BT.2020).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct D65;

impl Illuminant for D65 {
    const WHITE_POINT_XY: [f32; 2] = [0.3127, 0.3290];
    const WHITE_POINT_XYZ: [f32; 3] = [0.95047, 1.00000, 1.08883];
}

/// CIE standard illuminant D60 (~6004 K).
///
/// A true CIE daylight illuminant at 6000 K nominal CCT. Distinct from
/// the ACES white point. See [`AcesWhitePoint`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct D60;

impl Illuminant for D60 {
    const WHITE_POINT_XY: [f32; 2] = [0.32163, 0.33774];
    const WHITE_POINT_XYZ: [f32; 3] = [0.95230, 1.00000, 1.00856];
}

/// CIE standard illuminant D50 (~5003 K).
///
/// Reference white for the ICC profile connection space (ICC.1:2022)
/// and ProPhoto RGB (ROMM RGB, ISO 22028-2).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct D50;

impl Illuminant for D50 {
    const WHITE_POINT_XY: [f32; 2] = [0.3457, 0.3585];
    const WHITE_POINT_XYZ: [f32; 3] = [0.96422, 1.00000, 0.82521];
}

/// DCI white point for theatrical projection (SMPTE EG 432-1).
///
/// Not a CIE D-series illuminant. Used only for theatrical DCI-P3 projection.
/// Consumer Display P3 uses D65 instead.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DciWhite;

impl Illuminant for DciWhite {
    const WHITE_POINT_XY: [f32; 2] = [0.3140, 0.3510];
    const WHITE_POINT_XYZ: [f32; 3] = [0.89459, 1.00000, 0.95442];
}
/// Specified in SMPTE ST 2065-1:2021 and derived in Academy TB-2018-001.
/// Commonly called "D60" but is not a true CIE D-series illuminant.
/// It was chosen to be near 6000 K daylight without implying that ACES
/// is only compatible with scenes shot under D60 illumination. Use
/// [`D60`] for the true CIE D60 illuminant.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AcesWhitePoint;

impl Illuminant for AcesWhitePoint {
    const WHITE_POINT_XY: [f32; 2] = [0.32168, 0.33767];
    const WHITE_POINT_XYZ: [f32; 3] = [0.95265, 1.00000, 1.00883];
}