Debian Codegraph @

node/colorjs.io/src/spaces/acescg.js

raw
1 import RGBColorSpace from "../RGBColorSpace.js";
2 import { WHITES } from "../adapt.js";
3 import "../CATs.js"; // because of the funky whitepoint
4
5 /** @import { Matrix3x3 } from "../types.js" */
6
7 // The ACES whitepoint
8 // see TB-2018-001 Derivation of the ACES White Point CIE Chromaticity Coordinates
9 // also https://github.com/ampas/aces-dev/blob/master/documents/python/TB-2018-001/aces_wp.py
10 // Similar to D60
11 WHITES.ACES = [0.32168 / 0.33767, 1.0, (1.0 - 0.32168 - 0.33767) / 0.33767];
12
13 /**
14 * Matrices used by this color space, also available as `ACEScg.M`
15 * @type {Record<string, Matrix3x3>}
16 */
17 // prettier-ignore
18 export const M = {
19 // convert an array of linear-light ACEScg values to CIE XYZ
20 toXYZ: [
21 [ 0.6624541811085053, 0.13400420645643313, 0.1561876870049078 ],
22 [ 0.27222871678091454, 0.6740817658111484, 0.05368951740793705 ],
23 [ -0.005574649490394108, 0.004060733528982826, 1.0103391003129971 ],
24 ],
25 fromXYZ: [
26 [ 1.6410233796943257, -0.32480329418479, -0.23642469523761225 ],
27 [ -0.6636628587229829, 1.6153315916573379, 0.016756347685530137 ],
28 [ 0.011721894328375376, -0.008284441996237409, 0.9883948585390215 ],
29 ],
30 };
31
32 export default new RGBColorSpace({
33 id: "acescg",
34 cssId: "--acescg",
35 name: "ACEScg",
36
37 // ACEScg – A scene-referred, linear-light encoding of ACES Data
38 // https://docs.acescentral.com/specifications/acescg/
39 // uses the AP1 primaries, see section 4.3.1 Color primaries
40 coords: {
41 r: {
42 range: [0, 65504],
43 name: "Red",
44 },
45 g: {
46 range: [0, 65504],
47 name: "Green",
48 },
49 b: {
50 range: [0, 65504],
51 name: "Blue",
52 },
53 },
54
55 referred: "scene",
56
57 white: WHITES.ACES,
58
59 M,
60 });
61
62 // export default Color;