1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Generated by build.rs

/// xyY coordinates of the D65 reference white-point used in sRGB colour space.
#[allow(non_upper_case_globals)]
pub const D65_xyY: [f32; 3] = [312713.0 / 1000000.0, 41127.0 / 125000.0, 1.0];

/// XYZ coordinates of the D65 reference white-point used in sRGB colour space.
pub const D65_XYZ: [f32; 3] = [312713.0 / 329016.0, 1.0, 358271.0 / 329016.0];

/// D65 reference white point’s chromacity expressed as (u′, v′) coordinates.
#[allow(non_upper_case_globals)]
pub const D65_uv: [f32; 2] = [625426.0 / 3161383.0, 1480572.0 / 3161383.0];

/// xyY coordinates of red, green and blue primaries defining the sRGB space.
#[allow(non_upper_case_globals)]
pub const PRIMARIES_xyY: [[f32; 3]; 3] = [
    [16.0 / 25.0, 33.0 / 100.0, 1.0],
    [3.0 / 10.0, 3.0 / 5.0, 1.0],
    [3.0 / 20.0, 3.0 / 50.0, 1.0],
];

/// XYZ coordinates of red, green and blue primaries defining the sRGB space.
pub const PRIMARIES_XYZ: [[f32; 3]; 3] = [
    [4223344.0 / 10240623.0, 2903549.0 / 13654164.0, 263959.0 / 13654164.0],
    [14647555.0 / 40962492.0, 14647555.0 / 20481246.0, 14647555.0 / 122887476.0],
    [14783675.0 / 81924984.0, 2956735.0 / 40962492.0, 233582065.0 / 245774952.0],
];

/// The basis conversion matrix for moving from linear sRGB space to XYZ colour
/// space.
///
/// To perform the conversion it’s typically more convenient to use the
/// xyz_from_linear() function instead of accessing this constant.
///
/// The matrix is built with the assumption that colours are represented as
/// one-column matrices.  With that, converting from sRGB to XYZ is done by the
/// following formula: `XYZ = XYZ_FROM_SRGB_MATRIX ✕ RGB`.
pub const XYZ_FROM_SRGB_MATRIX: [[f32; 3]; 3] = [
    [4223344.0 / 10240623.0, 14647555.0 / 40962492.0, 14783675.0 / 81924984.0],
    [2903549.0 / 13654164.0, 14647555.0 / 20481246.0, 2956735.0 / 40962492.0],
    [263959.0 / 13654164.0, 14647555.0 / 122887476.0, 233582065.0 / 245774952.0],
];

/// The basis conversion matrix for moving from XYZ to linear sRGB colour
/// space.
///
/// To perform the conversion it’s typically more convenient to use the
/// linear_from_xyz() function instead of accessing this constant.
///
/// The matrix is built with the assumption that colours are represented as
/// one-column matrices.  With that, converting from XYZ to sRGB is done by the
/// following formula: `RGB = SRGB_FROM_XYZ_MATRIX ✕ XYZ`.
pub const SRGB_FROM_XYZ_MATRIX: [[f32; 3]; 3] = [
    [4277208.0 / 1319795.0, -2028932.0 / 1319795.0, -658032.0 / 1319795.0],
    [-70985202.0 / 73237775.0, 137391598.0 / 73237775.0, 3043398.0 / 73237775.0],
    [164508.0 / 2956735.0, -603196.0 / 2956735.0, 3125652.0 / 2956735.0],
];