Debian Codegraph @

node/colorjs.io/src/spaces/xyz-abs-d65.js

raw
1 import ColorSpace from "../ColorSpace.js";
2 import XYZ_D65 from "./xyz-d65.js";
3
4 const Yw = 203; // absolute luminance of media white
5
6 export default new ColorSpace({
7 // Absolute CIE XYZ, with a D65 whitepoint,
8 // as used in most HDR colorspaces as a starting point.
9 // SDR spaces are converted per BT.2048
10 // so that diffuse, media white is 203 cd/m²
11 id: "xyz-abs-d65",
12 cssId: "--xyz-abs-d65",
13 name: "Absolute XYZ D65",
14 coords: {
15 x: {
16 refRange: [0, 9504.7],
17 name: "Xa",
18 },
19 y: {
20 refRange: [0, 10000],
21 name: "Ya",
22 },
23 z: {
24 refRange: [0, 10888.3],
25 name: "Za",
26 },
27 },
28
29 base: XYZ_D65,
30 fromBase (XYZ) {
31 // Make XYZ absolute, not relative to media white
32 // Maximum luminance in PQ is 10,000 cd/m²
33 // Relative XYZ has Y=1 for media white
34 return XYZ.map(v => v * Yw);
35 },
36 toBase (AbsXYZ) {
37 // Convert to media-white relative XYZ
38 return AbsXYZ.map(v => v / Yw);
39 },
40 });