UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

32 lines (31 loc) 1.11 kB
"use strict"; require("../../utils/type.cjs"); const unpack = require("../../utils/unpack.cjs"); const multiplyMatrices = require("../../utils/multiply-matrices.cjs"); const lab2rgb = require("../lab/lab2rgb.cjs"); const oklab2rgb = (...args) => { args = unpack(args, "lab"); const [L, a, b, ...rest] = args; const [X, Y, Z] = OKLab_to_XYZ([L, a, b]); const [r, g, b_] = lab2rgb.xyz2rgb(X, Y, Z); return [r, g, b_, ...rest.length > 0 && rest[0] < 1 ? [rest[0]] : []]; }; function OKLab_to_XYZ(OKLab) { var LMStoXYZ = [ [1.2268798758459243, -0.5578149944602171, 0.2813910456659647], [-0.0405757452148008, 1.112286803280317, -0.0717110580655164], [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816] ]; var OKLabtoLMS = [ [1, 0.3963377773761749, 0.2158037573099136], [1, -0.1055613458156586, -0.0638541728258133], [1, -0.0894841775298119, -1.2914855480194092] ]; var LMSnl = multiplyMatrices(OKLabtoLMS, OKLab); return multiplyMatrices( LMStoXYZ, LMSnl.map((c) => c ** 3) ); } module.exports = oklab2rgb; //# sourceMappingURL=oklab2rgb.cjs.map