Debian Codegraph @

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

raw
1 import RGBColorSpace from "../RGBColorSpace.js";
2 import REC2020Linear from "./rec2020-linear.js";
3 // import sRGB from "./srgb.js";
4
5 export default new RGBColorSpace({
6 id: "rec2020",
7 name: "REC.2020",
8 base: REC2020Linear,
9 linearGamut: REC2020Linear,
10 // Reference electro-optical transfer function from Rec. ITU-R BT.1886 Annex 1
11 // with b (black lift) = 0 and a (user gain) = 1
12 // defined over the extended range, not clamped
13 toBase (RGB) {
14 return RGB.map(function (val) {
15 let sign = val < 0 ? -1 : 1;
16 let abs = val * sign;
17 return sign * Math.pow(abs, 2.4);
18 });
19 },
20 fromBase (RGB) {
21 return RGB.map(function (val) {
22 let sign = val < 0 ? -1 : 1;
23 let abs = val * sign;
24 return sign * Math.pow(abs, 1 / 2.4);
25 });
26 },
27 });