Skip to content

Commit

Permalink
missing files #27
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Feb 28, 2024
1 parent b2379ee commit ec272c9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dist/lib/renderer/color/utils/components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { EnumToken } from '../../../ast/types.js';
import '../../../ast/minify.js';
import '../../../parser/parse.js';
import './constants.js';
import '../../sourcemap/lib/encode.js';

function getComponents(token) {
return token.chi
.filter((t) => ![EnumToken.LiteralTokenType, EnumToken.CommentTokenType, EnumToken.CommaTokenType, EnumToken.WhitespaceTokenType].includes(t.typ));
}

export { getComponents };
28 changes: 28 additions & 0 deletions dist/lib/renderer/color/xyzd65.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { multiplyMatrices } from './utils/matrix.js';
import './utils/constants.js';
import '../../ast/types.js';
import '../../ast/minify.js';
import '../../parser/parse.js';
import { XYZ_to_sRGB } from './xyz.js';
import '../sourcemap/lib/encode.js';

function XYZ_D65_to_sRGB(x, y, z) {
// @ts-ignore
return XYZ_to_sRGB(...XYZ_D65_to_D50(x, y, z));
}
function XYZ_D65_to_D50(x, y, z) {
// Bradford chromatic adaptation from D65 to D50
// The matrix below is the result of three operations:
// - convert from XYZ to retinal cone domain
// - scale components from one reference white to another
// - convert back to XYZ
// see https://github.com/LeaVerou/color.js/pull/354/files
var M = [
[1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
[0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
[-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
];
return multiplyMatrices(M, [x, y, z]);
}

export { XYZ_D65_to_D50, XYZ_D65_to_sRGB };

0 comments on commit ec272c9

Please sign in to comment.