Debian Codegraph @

node/colorjs.io/src/spaces/srgb-linear.js

raw
1 import RGBColorSpace from "../RGBColorSpace.js";
2
3 /** @import { Matrix3x3 } from "../types.js" */
4
5 // This is the linear-light version of sRGB
6 // as used for example in SVG filters
7 // or in Canvas
8
9 /**
10 * Matrices used by this color space, also available as `sRGB_Linear.M`
11 * @type {Record<string, Matrix3x3>}
12 */
13 // prettier-ignore
14 export const M = {
15 // calculated directly from the RGB and white chromaticities; when rounded to
16 // 8 decimal places, agrees completely with the official matrix
17 // see https://github.com/w3c/csswg-drafts/issues/5922
18 toXYZ: [
19 [ 0.41239079926595934, 0.357584339383878, 0.1804807884018343 ],
20 [ 0.21263900587151027, 0.715168678767756, 0.07219231536073371 ],
21 [ 0.01933081871559182, 0.11919477979462598, 0.9505321522496607 ],
22 ],
23 // the inverse of the above; again agrees with the official definition
24 // when rounded to 8 decimal places
25 fromXYZ: [
26 [ 3.2409699419045226, -1.537383177570094, -0.4986107602930034 ],
27 [ -0.9692436362808796, 1.8759675015077202, 0.04155505740717559 ],
28 [ 0.05563007969699366, -0.20397695888897652, 1.0569715142428786 ],
29 ],
30 };
31
32 export default new RGBColorSpace({
33 id: "srgb-linear",
34 name: "Linear sRGB",
35 white: "D65",
36 M,
37 });