colorjs.io
Version:
Let’s get serious about color
29 lines (25 loc) • 981 B
JavaScript
import RGBColorSpace from "../rgbspace.js";
import XYZ_D50 from "./xyz-d50.js";
// convert an array of prophoto-rgb values to CIE XYZ
// using D50 (so no chromatic adaptation needed afterwards)
// matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy
// see https://github.com/w3c/csswg-drafts/issues/7675
const toXYZ_M = [
[ 0.79776664490064230, 0.13518129740053308, 0.03134773412839220 ],
[ 0.28807482881940130, 0.71183523424187300, 0.00008993693872564 ],
[ 0.00000000000000000, 0.00000000000000000, 0.82510460251046020 ],
];
const fromXYZ_M = [
[ 1.34578688164715830, -0.25557208737979464, -0.05110186497554526 ],
[ -0.54463070512490190, 1.50824774284514680, 0.02052744743642139 ],
[ 0.00000000000000000, 0.00000000000000000, 1.21196754563894520 ],
];
export default new RGBColorSpace({
id: "prophoto-linear",
cssId: "--prophoto-rgb-linear",
name: "Linear ProPhoto",
white: "D50",
base: XYZ_D50,
toXYZ_M,
fromXYZ_M,
});