colorjs.io
Version:
Let’s get serious about color
34 lines (30 loc) • 1.04 kB
JavaScript
import RGBColorSpace from "../RGBColorSpace.js";
/** @import { Matrix3x3 } from "../types.js" */
/**
* Matrices used by this color space, also available as `REC_2020_Linear.M`.
* Uses D65 (no chromatic adaptation).
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
* @type {Record<string, Matrix3x3>}
*/
// prettier-ignore
export const M = {
// 0 is actually calculated as 4.994106574466076e-17
toXYZ: [
[ 0.6369580483012914, 0.14461690358620832, 0.1688809751641721 ],
[ 0.2627002120112671, 0.6779980715188708, 0.05930171646986196 ],
[ 0.000000000000000, 0.028072693049087428, 1.060985057710791 ],
],
// from ITU-R BT.2124-0 Annex 2 p.3
fromXYZ: [
[ 1.716651187971268, -0.355670783776392, -0.253366281373660 ],
[ -0.666684351832489, 1.616481236634939, 0.0157685458139111 ],
[ 0.017639857445311, -0.042770613257809, 0.942103121235474 ],
],
};
export default new RGBColorSpace({
id: "rec2020-linear",
cssId: "--rec2020-linear",
name: "Linear REC.2020",
white: "D65",
M,
});