@inkeep/cxkit-theme 0.0.0-dev-20250221234142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/color-utils.cjs +1 -0
- package/dist/color-utils.d.cts +1 -0
- package/dist/color-utils.d.ts +1 -0
- package/dist/color-utils.js +20 -0
- package/dist/colors.cjs +1 -0
- package/dist/colors.d.cts +100 -0
- package/dist/colors.d.ts +100 -0
- package/dist/colors.js +137 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +120 -0
- package/dist/index.d.ts +120 -0
- package/dist/index.js +57 -0
- package/dist/node_modules/.pnpm/colorjs.io@0.5.2/node_modules/colorjs.io/dist/color.cjs +1 -0
- package/dist/node_modules/.pnpm/colorjs.io@0.5.2/node_modules/colorjs.io/dist/color.js +2839 -0
- package/dist/utils/create-css-variables.cjs +1 -0
- package/dist/utils/create-css-variables.d.cts +2 -0
- package/dist/utils/create-css-variables.d.ts +2 -0
- package/dist/utils/create-css-variables.js +23 -0
- package/dist/utils/generate-theme-variables.cjs +1 -0
- package/dist/utils/generate-theme-variables.d.cts +3 -0
- package/dist/utils/generate-theme-variables.d.ts +3 -0
- package/dist/utils/generate-theme-variables.js +33 -0
- package/package.json +55 -0
|
@@ -0,0 +1,2839 @@
|
|
|
1
|
+
function C(t, e) {
|
|
2
|
+
let r = t.length;
|
|
3
|
+
Array.isArray(t[0]) || (t = [t]), Array.isArray(e[0]) || (e = e.map((i) => [i]));
|
|
4
|
+
let n = e[0].length, a = e[0].map((i, o) => e.map((l) => l[o])), s = t.map((i) => a.map((o) => {
|
|
5
|
+
let l = 0;
|
|
6
|
+
if (!Array.isArray(i)) {
|
|
7
|
+
for (let f of o)
|
|
8
|
+
l += i * f;
|
|
9
|
+
return l;
|
|
10
|
+
}
|
|
11
|
+
for (let f = 0; f < i.length; f++)
|
|
12
|
+
l += i[f] * (o[f] || 0);
|
|
13
|
+
return l;
|
|
14
|
+
}));
|
|
15
|
+
return r === 1 && (s = s[0]), n === 1 ? s.map((i) => i[0]) : s;
|
|
16
|
+
}
|
|
17
|
+
function ce(t) {
|
|
18
|
+
return Y(t) === "string";
|
|
19
|
+
}
|
|
20
|
+
function Y(t) {
|
|
21
|
+
return (Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1] || "").toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
function Se(t, { precision: e, unit: r }) {
|
|
24
|
+
return D(t) ? "none" : l0(t, e) + (r ?? "");
|
|
25
|
+
}
|
|
26
|
+
function D(t) {
|
|
27
|
+
return Number.isNaN(t) || t instanceof Number && t?.none;
|
|
28
|
+
}
|
|
29
|
+
function S(t) {
|
|
30
|
+
return D(t) ? 0 : t;
|
|
31
|
+
}
|
|
32
|
+
function l0(t, e) {
|
|
33
|
+
if (t === 0)
|
|
34
|
+
return 0;
|
|
35
|
+
let r = ~~t, n = 0;
|
|
36
|
+
r && e && (n = ~~Math.log10(Math.abs(r)) + 1);
|
|
37
|
+
const a = 10 ** (e - n);
|
|
38
|
+
return Math.floor(t * a + 0.5) / a;
|
|
39
|
+
}
|
|
40
|
+
const Q0 = {
|
|
41
|
+
deg: 1,
|
|
42
|
+
grad: 0.9,
|
|
43
|
+
rad: 180 / Math.PI,
|
|
44
|
+
turn: 360
|
|
45
|
+
};
|
|
46
|
+
function c0(t) {
|
|
47
|
+
if (!t)
|
|
48
|
+
return;
|
|
49
|
+
t = t.trim();
|
|
50
|
+
const e = /^([a-z]+)\((.+?)\)$/i, r = /^-?[\d.]+$/, n = /%|deg|g?rad|turn$/, a = /\/?\s*(none|[-\w.]+(?:%|deg|g?rad|turn)?)/g;
|
|
51
|
+
let s = t.match(e);
|
|
52
|
+
if (s) {
|
|
53
|
+
let i = [];
|
|
54
|
+
return s[2].replace(a, (o, l) => {
|
|
55
|
+
let f = l.match(n), u = l;
|
|
56
|
+
if (f) {
|
|
57
|
+
let c = f[0], h = u.slice(0, -c.length);
|
|
58
|
+
c === "%" ? (u = new Number(h / 100), u.type = "<percentage>") : (u = new Number(h * Q0[c]), u.type = "<angle>", u.unit = c);
|
|
59
|
+
} else r.test(u) ? (u = new Number(u), u.type = "<number>") : u === "none" && (u = new Number(NaN), u.none = !0);
|
|
60
|
+
o.startsWith("/") && (u = u instanceof Number ? u : new Number(u), u.alpha = !0), typeof u == "object" && u instanceof Number && (u.raw = l), i.push(u);
|
|
61
|
+
}), {
|
|
62
|
+
name: s[1].toLowerCase(),
|
|
63
|
+
rawName: s[1],
|
|
64
|
+
rawArgs: s[2],
|
|
65
|
+
// An argument could be (as of css-color-4):
|
|
66
|
+
// a number, percentage, degrees (hue), ident (in color())
|
|
67
|
+
args: i
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function u0(t) {
|
|
72
|
+
return t[t.length - 1];
|
|
73
|
+
}
|
|
74
|
+
function ie(t, e, r) {
|
|
75
|
+
return isNaN(t) ? e : isNaN(e) ? t : t + (e - t) * r;
|
|
76
|
+
}
|
|
77
|
+
function f0(t, e, r) {
|
|
78
|
+
return (r - t) / (e - t);
|
|
79
|
+
}
|
|
80
|
+
function Ue(t, e, r) {
|
|
81
|
+
return ie(e[0], e[1], f0(t[0], t[1], r));
|
|
82
|
+
}
|
|
83
|
+
function h0(t) {
|
|
84
|
+
return t.map((e) => e.split("|").map((r) => {
|
|
85
|
+
r = r.trim();
|
|
86
|
+
let n = r.match(/^(<[a-z]+>)\[(-?[.\d]+),\s*(-?[.\d]+)\]?$/);
|
|
87
|
+
if (n) {
|
|
88
|
+
let a = new String(n[1]);
|
|
89
|
+
return a.range = [+n[2], +n[3]], a;
|
|
90
|
+
}
|
|
91
|
+
return r;
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
function d0(t, e, r) {
|
|
95
|
+
return Math.max(Math.min(r, e), t);
|
|
96
|
+
}
|
|
97
|
+
function Be(t, e) {
|
|
98
|
+
return Math.sign(t) === Math.sign(e) ? t : -t;
|
|
99
|
+
}
|
|
100
|
+
function A(t, e) {
|
|
101
|
+
return Be(Math.abs(t) ** e, t);
|
|
102
|
+
}
|
|
103
|
+
function Ke(t, e) {
|
|
104
|
+
return e === 0 ? 0 : t / e;
|
|
105
|
+
}
|
|
106
|
+
function m0(t, e, r = 0, n = t.length) {
|
|
107
|
+
for (; r < n; ) {
|
|
108
|
+
const a = r + n >> 1;
|
|
109
|
+
t[a] < e ? r = a + 1 : n = a;
|
|
110
|
+
}
|
|
111
|
+
return r;
|
|
112
|
+
}
|
|
113
|
+
var U0 = /* @__PURE__ */ Object.freeze({
|
|
114
|
+
__proto__: null,
|
|
115
|
+
bisectLeft: m0,
|
|
116
|
+
clamp: d0,
|
|
117
|
+
copySign: Be,
|
|
118
|
+
interpolate: ie,
|
|
119
|
+
interpolateInv: f0,
|
|
120
|
+
isNone: D,
|
|
121
|
+
isString: ce,
|
|
122
|
+
last: u0,
|
|
123
|
+
mapRange: Ue,
|
|
124
|
+
multiplyMatrices: C,
|
|
125
|
+
parseCoordGrammar: h0,
|
|
126
|
+
parseFunction: c0,
|
|
127
|
+
serializeNumber: Se,
|
|
128
|
+
skipNone: S,
|
|
129
|
+
spow: A,
|
|
130
|
+
toPrecision: l0,
|
|
131
|
+
type: Y,
|
|
132
|
+
zdiv: Ke
|
|
133
|
+
});
|
|
134
|
+
class K0 {
|
|
135
|
+
add(e, r, n) {
|
|
136
|
+
if (typeof arguments[0] != "string") {
|
|
137
|
+
for (var e in arguments[0])
|
|
138
|
+
this.add(e, arguments[0][e], arguments[1]);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
(Array.isArray(e) ? e : [e]).forEach(function(a) {
|
|
142
|
+
this[a] = this[a] || [], r && this[a][n ? "unshift" : "push"](r);
|
|
143
|
+
}, this);
|
|
144
|
+
}
|
|
145
|
+
run(e, r) {
|
|
146
|
+
this[e] = this[e] || [], this[e].forEach(function(n) {
|
|
147
|
+
n.call(r && r.context ? r.context : r, r);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const X = new K0();
|
|
152
|
+
var E = {
|
|
153
|
+
gamut_mapping: "css",
|
|
154
|
+
precision: 5,
|
|
155
|
+
deltaE: "76",
|
|
156
|
+
// Default deltaE method
|
|
157
|
+
verbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== "test",
|
|
158
|
+
warn: function(e) {
|
|
159
|
+
this.verbose && globalThis?.console?.warn?.(e);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const B = {
|
|
163
|
+
// for compatibility, the four-digit chromaticity-derived ones everyone else uses
|
|
164
|
+
D50: [0.3457 / 0.3585, 1, (1 - 0.3457 - 0.3585) / 0.3585],
|
|
165
|
+
D65: [0.3127 / 0.329, 1, (1 - 0.3127 - 0.329) / 0.329]
|
|
166
|
+
};
|
|
167
|
+
function je(t) {
|
|
168
|
+
return Array.isArray(t) ? t : B[t];
|
|
169
|
+
}
|
|
170
|
+
function Re(t, e, r, n = {}) {
|
|
171
|
+
if (t = je(t), e = je(e), !t || !e)
|
|
172
|
+
throw new TypeError(`Missing white point to convert ${t ? "" : "from"}${!t && !e ? "/" : ""}${e ? "" : "to"}`);
|
|
173
|
+
if (t === e)
|
|
174
|
+
return r;
|
|
175
|
+
let a = { W1: t, W2: e, XYZ: r, options: n };
|
|
176
|
+
if (X.run("chromatic-adaptation-start", a), a.M || (a.W1 === B.D65 && a.W2 === B.D50 ? a.M = [
|
|
177
|
+
[1.0479297925449969, 0.022946870601609652, -0.05019226628920524],
|
|
178
|
+
[0.02962780877005599, 0.9904344267538799, -0.017073799063418826],
|
|
179
|
+
[-0.009243040646204504, 0.015055191490298152, 0.7518742814281371]
|
|
180
|
+
] : a.W1 === B.D50 && a.W2 === B.D65 && (a.M = [
|
|
181
|
+
[0.955473421488075, -0.02309845494876471, 0.06325924320057072],
|
|
182
|
+
[-0.0283697093338637, 1.0099953980813041, 0.021041441191917323],
|
|
183
|
+
[0.012314014864481998, -0.020507649298898964, 1.330365926242124]
|
|
184
|
+
])), X.run("chromatic-adaptation-end", a), a.M)
|
|
185
|
+
return C(a.M, a.XYZ);
|
|
186
|
+
throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.");
|
|
187
|
+
}
|
|
188
|
+
const V0 = /* @__PURE__ */ new Set(["<number>", "<percentage>", "<angle>"]);
|
|
189
|
+
function ft(t, e, r, n) {
|
|
190
|
+
return Object.entries(t.coords).map(([s, i], o) => {
|
|
191
|
+
let l = e.coordGrammar[o], f = n[o], u = f?.type, c;
|
|
192
|
+
if (f.none ? c = l.find((m) => V0.has(m)) : c = l.find((m) => m == u), !c) {
|
|
193
|
+
let m = i.name || s;
|
|
194
|
+
throw new TypeError(`${u ?? f.raw} not allowed for ${m} in ${r}()`);
|
|
195
|
+
}
|
|
196
|
+
let h = c.range;
|
|
197
|
+
u === "<percentage>" && (h ||= [0, 1]);
|
|
198
|
+
let p = i.range || i.refRange;
|
|
199
|
+
return h && p && (n[o] = Ue(h, p, n[o])), c;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function g0(t, { meta: e } = {}) {
|
|
203
|
+
let r = { str: String(t)?.trim() };
|
|
204
|
+
if (X.run("parse-start", r), r.color)
|
|
205
|
+
return r.color;
|
|
206
|
+
if (r.parsed = c0(r.str), r.parsed) {
|
|
207
|
+
let n = r.parsed.name;
|
|
208
|
+
if (n === "color") {
|
|
209
|
+
let a = r.parsed.args.shift(), s = a.startsWith("--") ? a.substring(2) : `--${a}`, i = [a, s], o = r.parsed.rawArgs.indexOf("/") > 0 ? r.parsed.args.pop() : 1;
|
|
210
|
+
for (let u of d.all) {
|
|
211
|
+
let c = u.getFormat("color");
|
|
212
|
+
if (c && (i.includes(c.id) || c.ids?.filter((h) => i.includes(h)).length)) {
|
|
213
|
+
const h = Object.keys(u.coords).map((m, b) => r.parsed.args[b] || 0);
|
|
214
|
+
let p;
|
|
215
|
+
return c.coordGrammar && (p = ft(u, c, "color", h)), e && Object.assign(e, { formatId: "color", types: p }), c.id.startsWith("--") && !a.startsWith("--") && E.warn(`${u.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${c.id}) instead of color(${a}).`), a.startsWith("--") && !c.id.startsWith("--") && E.warn(`${u.name} is a standard space and supported in the CSS spec. Use color(${c.id}) instead of prefixed color(${a}).`), { spaceId: u.id, coords: h, alpha: o };
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
let l = "", f = a in d.registry ? a : s;
|
|
219
|
+
if (f in d.registry) {
|
|
220
|
+
let u = d.registry[f].formats?.color?.id;
|
|
221
|
+
u && (l = `Did you mean color(${u})?`);
|
|
222
|
+
}
|
|
223
|
+
throw new TypeError(`Cannot parse color(${a}). ` + (l || "Missing a plugin?"));
|
|
224
|
+
} else
|
|
225
|
+
for (let a of d.all) {
|
|
226
|
+
let s = a.getFormat(n);
|
|
227
|
+
if (s && s.type === "function") {
|
|
228
|
+
let i = 1;
|
|
229
|
+
(s.lastAlpha || u0(r.parsed.args).alpha) && (i = r.parsed.args.pop());
|
|
230
|
+
let o = r.parsed.args, l;
|
|
231
|
+
return s.coordGrammar && (l = ft(a, s, n, o)), e && Object.assign(e, { formatId: s.name, types: l }), {
|
|
232
|
+
spaceId: a.id,
|
|
233
|
+
coords: o,
|
|
234
|
+
alpha: i
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} else
|
|
239
|
+
for (let n of d.all)
|
|
240
|
+
for (let a in n.formats) {
|
|
241
|
+
let s = n.formats[a];
|
|
242
|
+
if (s.type !== "custom" || s.test && !s.test(r.str))
|
|
243
|
+
continue;
|
|
244
|
+
let i = s.parse(r.str);
|
|
245
|
+
if (i)
|
|
246
|
+
return i.alpha ??= 1, e && (e.formatId = a), i;
|
|
247
|
+
}
|
|
248
|
+
throw new TypeError(`Could not parse ${t} as a color. Missing a plugin?`);
|
|
249
|
+
}
|
|
250
|
+
function g(t) {
|
|
251
|
+
if (Array.isArray(t))
|
|
252
|
+
return t.map(g);
|
|
253
|
+
if (!t)
|
|
254
|
+
throw new TypeError("Empty color reference");
|
|
255
|
+
ce(t) && (t = g0(t));
|
|
256
|
+
let e = t.space || t.spaceId;
|
|
257
|
+
return e instanceof d || (t.space = d.get(e)), t.alpha === void 0 && (t.alpha = 1), t;
|
|
258
|
+
}
|
|
259
|
+
const er = 75e-6;
|
|
260
|
+
class d {
|
|
261
|
+
constructor(e) {
|
|
262
|
+
this.id = e.id, this.name = e.name, this.base = e.base ? d.get(e.base) : null, this.aliases = e.aliases, this.base && (this.fromBase = e.fromBase, this.toBase = e.toBase);
|
|
263
|
+
let r = e.coords ?? this.base.coords;
|
|
264
|
+
for (let a in r)
|
|
265
|
+
"name" in r[a] || (r[a].name = a);
|
|
266
|
+
this.coords = r;
|
|
267
|
+
let n = e.white ?? this.base.white ?? "D65";
|
|
268
|
+
this.white = je(n), this.formats = e.formats ?? {};
|
|
269
|
+
for (let a in this.formats) {
|
|
270
|
+
let s = this.formats[a];
|
|
271
|
+
s.type ||= "function", s.name ||= a;
|
|
272
|
+
}
|
|
273
|
+
this.formats.color?.id || (this.formats.color = {
|
|
274
|
+
...this.formats.color ?? {},
|
|
275
|
+
id: e.cssId || this.id
|
|
276
|
+
}), e.gamutSpace ? this.gamutSpace = e.gamutSpace === "self" ? this : d.get(e.gamutSpace) : this.isPolar ? this.gamutSpace = this.base : this.gamutSpace = this, this.gamutSpace.isUnbounded && (this.inGamut = (a, s) => !0), this.referred = e.referred, Object.defineProperty(this, "path", {
|
|
277
|
+
value: tr(this).reverse(),
|
|
278
|
+
writable: !1,
|
|
279
|
+
enumerable: !0,
|
|
280
|
+
configurable: !0
|
|
281
|
+
}), X.run("colorspace-init-end", this);
|
|
282
|
+
}
|
|
283
|
+
inGamut(e, { epsilon: r = er } = {}) {
|
|
284
|
+
if (!this.equals(this.gamutSpace))
|
|
285
|
+
return e = this.to(this.gamutSpace, e), this.gamutSpace.inGamut(e, { epsilon: r });
|
|
286
|
+
let n = Object.values(this.coords);
|
|
287
|
+
return e.every((a, s) => {
|
|
288
|
+
let i = n[s];
|
|
289
|
+
if (i.type !== "angle" && i.range) {
|
|
290
|
+
if (Number.isNaN(a))
|
|
291
|
+
return !0;
|
|
292
|
+
let [o, l] = i.range;
|
|
293
|
+
return (o === void 0 || a >= o - r) && (l === void 0 || a <= l + r);
|
|
294
|
+
}
|
|
295
|
+
return !0;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
get isUnbounded() {
|
|
299
|
+
return Object.values(this.coords).every((e) => !("range" in e));
|
|
300
|
+
}
|
|
301
|
+
get cssId() {
|
|
302
|
+
return this.formats?.color?.id || this.id;
|
|
303
|
+
}
|
|
304
|
+
get isPolar() {
|
|
305
|
+
for (let e in this.coords)
|
|
306
|
+
if (this.coords[e].type === "angle")
|
|
307
|
+
return !0;
|
|
308
|
+
return !1;
|
|
309
|
+
}
|
|
310
|
+
getFormat(e) {
|
|
311
|
+
if (typeof e == "object")
|
|
312
|
+
return e = ht(e, this), e;
|
|
313
|
+
let r;
|
|
314
|
+
return e === "default" ? r = Object.values(this.formats)[0] : r = this.formats[e], r ? (r = ht(r, this), r) : null;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Check if this color space is the same as another color space reference.
|
|
318
|
+
* Allows proxying color space objects and comparing color spaces with ids.
|
|
319
|
+
* @param {string | ColorSpace} space ColorSpace object or id to compare to
|
|
320
|
+
* @returns {boolean}
|
|
321
|
+
*/
|
|
322
|
+
equals(e) {
|
|
323
|
+
return e ? this === e || this.id === e || this.id === e.id : !1;
|
|
324
|
+
}
|
|
325
|
+
to(e, r) {
|
|
326
|
+
if (arguments.length === 1) {
|
|
327
|
+
const o = g(e);
|
|
328
|
+
[e, r] = [o.space, o.coords];
|
|
329
|
+
}
|
|
330
|
+
if (e = d.get(e), this.equals(e))
|
|
331
|
+
return r;
|
|
332
|
+
r = r.map((o) => Number.isNaN(o) ? 0 : o);
|
|
333
|
+
let n = this.path, a = e.path, s, i;
|
|
334
|
+
for (let o = 0; o < n.length && n[o].equals(a[o]); o++)
|
|
335
|
+
s = n[o], i = o;
|
|
336
|
+
if (!s)
|
|
337
|
+
throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);
|
|
338
|
+
for (let o = n.length - 1; o > i; o--)
|
|
339
|
+
r = n[o].toBase(r);
|
|
340
|
+
for (let o = i + 1; o < a.length; o++)
|
|
341
|
+
r = a[o].fromBase(r);
|
|
342
|
+
return r;
|
|
343
|
+
}
|
|
344
|
+
from(e, r) {
|
|
345
|
+
if (arguments.length === 1) {
|
|
346
|
+
const n = g(e);
|
|
347
|
+
[e, r] = [n.space, n.coords];
|
|
348
|
+
}
|
|
349
|
+
return e = d.get(e), e.to(this, r);
|
|
350
|
+
}
|
|
351
|
+
toString() {
|
|
352
|
+
return `${this.name} (${this.id})`;
|
|
353
|
+
}
|
|
354
|
+
getMinCoords() {
|
|
355
|
+
let e = [];
|
|
356
|
+
for (let r in this.coords) {
|
|
357
|
+
let n = this.coords[r], a = n.range || n.refRange;
|
|
358
|
+
e.push(a?.min ?? 0);
|
|
359
|
+
}
|
|
360
|
+
return e;
|
|
361
|
+
}
|
|
362
|
+
static registry = {};
|
|
363
|
+
// Returns array of unique color spaces
|
|
364
|
+
static get all() {
|
|
365
|
+
return [...new Set(Object.values(d.registry))];
|
|
366
|
+
}
|
|
367
|
+
static register(e, r) {
|
|
368
|
+
if (arguments.length === 1 && (r = arguments[0], e = r.id), r = this.get(r), this.registry[e] && this.registry[e] !== r)
|
|
369
|
+
throw new Error(`Duplicate color space registration: '${e}'`);
|
|
370
|
+
if (this.registry[e] = r, arguments.length === 1 && r.aliases)
|
|
371
|
+
for (let n of r.aliases)
|
|
372
|
+
this.register(n, r);
|
|
373
|
+
return r;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Lookup ColorSpace object by name
|
|
377
|
+
* @param {ColorSpace | string} name
|
|
378
|
+
*/
|
|
379
|
+
static get(e, ...r) {
|
|
380
|
+
if (!e || e instanceof d)
|
|
381
|
+
return e;
|
|
382
|
+
if (Y(e) === "string") {
|
|
383
|
+
let a = d.registry[e.toLowerCase()];
|
|
384
|
+
if (!a)
|
|
385
|
+
throw new TypeError(`No color space found with id = "${e}"`);
|
|
386
|
+
return a;
|
|
387
|
+
}
|
|
388
|
+
if (r.length)
|
|
389
|
+
return d.get(...r);
|
|
390
|
+
throw new TypeError(`${e} is not a valid color space`);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get metadata about a coordinate of a color space
|
|
394
|
+
*
|
|
395
|
+
* @static
|
|
396
|
+
* @param {Array | string} ref
|
|
397
|
+
* @param {ColorSpace | string} [workingSpace]
|
|
398
|
+
* @return {Object}
|
|
399
|
+
*/
|
|
400
|
+
static resolveCoord(e, r) {
|
|
401
|
+
let n = Y(e), a, s;
|
|
402
|
+
if (n === "string" ? e.includes(".") ? [a, s] = e.split(".") : [a, s] = [, e] : Array.isArray(e) ? [a, s] = e : (a = e.space, s = e.coordId), a = d.get(a), a || (a = r), !a)
|
|
403
|
+
throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);
|
|
404
|
+
if (n = Y(s), n === "number" || n === "string" && s >= 0) {
|
|
405
|
+
let l = Object.entries(a.coords)[s];
|
|
406
|
+
if (l)
|
|
407
|
+
return { space: a, id: l[0], index: s, ...l[1] };
|
|
408
|
+
}
|
|
409
|
+
a = d.get(a);
|
|
410
|
+
let i = s.toLowerCase(), o = 0;
|
|
411
|
+
for (let l in a.coords) {
|
|
412
|
+
let f = a.coords[l];
|
|
413
|
+
if (l.toLowerCase() === i || f.name?.toLowerCase() === i)
|
|
414
|
+
return { space: a, id: l, index: o, ...f };
|
|
415
|
+
o++;
|
|
416
|
+
}
|
|
417
|
+
throw new TypeError(`No "${s}" coordinate found in ${a.name}. Its coordinates are: ${Object.keys(a.coords).join(", ")}`);
|
|
418
|
+
}
|
|
419
|
+
static DEFAULT_FORMAT = {
|
|
420
|
+
type: "functions",
|
|
421
|
+
name: "color"
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function tr(t) {
|
|
425
|
+
let e = [t];
|
|
426
|
+
for (let r = t; r = r.base; )
|
|
427
|
+
e.push(r);
|
|
428
|
+
return e;
|
|
429
|
+
}
|
|
430
|
+
function ht(t, { coords: e } = {}) {
|
|
431
|
+
if (t.coords && !t.coordGrammar) {
|
|
432
|
+
t.type ||= "function", t.name ||= "color", t.coordGrammar = h0(t.coords);
|
|
433
|
+
let r = Object.entries(e).map(([n, a], s) => {
|
|
434
|
+
let i = t.coordGrammar[s][0], o = a.range || a.refRange, l = i.range, f = "";
|
|
435
|
+
return i == "<percentage>" ? (l = [0, 100], f = "%") : i == "<angle>" && (f = "deg"), { fromRange: o, toRange: l, suffix: f };
|
|
436
|
+
});
|
|
437
|
+
t.serializeCoords = (n, a) => n.map((s, i) => {
|
|
438
|
+
let { fromRange: o, toRange: l, suffix: f } = r[i];
|
|
439
|
+
return o && l && (s = Ue(o, l, s)), s = Se(s, { precision: a, unit: f }), s;
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
return t;
|
|
443
|
+
}
|
|
444
|
+
var N = new d({
|
|
445
|
+
id: "xyz-d65",
|
|
446
|
+
name: "XYZ D65",
|
|
447
|
+
coords: {
|
|
448
|
+
x: { name: "X" },
|
|
449
|
+
y: { name: "Y" },
|
|
450
|
+
z: { name: "Z" }
|
|
451
|
+
},
|
|
452
|
+
white: "D65",
|
|
453
|
+
formats: {
|
|
454
|
+
color: {
|
|
455
|
+
ids: ["xyz-d65", "xyz"]
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
aliases: ["xyz"]
|
|
459
|
+
});
|
|
460
|
+
class I extends d {
|
|
461
|
+
/**
|
|
462
|
+
* Creates a new RGB ColorSpace.
|
|
463
|
+
* If coords are not specified, they will use the default RGB coords.
|
|
464
|
+
* Instead of `fromBase()` and `toBase()` functions,
|
|
465
|
+
* you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.
|
|
466
|
+
* @param {*} options - Same options as {@link ColorSpace} plus:
|
|
467
|
+
* @param {number[][]} options.toXYZ_M - Matrix to convert to XYZ
|
|
468
|
+
* @param {number[][]} options.fromXYZ_M - Matrix to convert from XYZ
|
|
469
|
+
*/
|
|
470
|
+
constructor(e) {
|
|
471
|
+
e.coords || (e.coords = {
|
|
472
|
+
r: {
|
|
473
|
+
range: [0, 1],
|
|
474
|
+
name: "Red"
|
|
475
|
+
},
|
|
476
|
+
g: {
|
|
477
|
+
range: [0, 1],
|
|
478
|
+
name: "Green"
|
|
479
|
+
},
|
|
480
|
+
b: {
|
|
481
|
+
range: [0, 1],
|
|
482
|
+
name: "Blue"
|
|
483
|
+
}
|
|
484
|
+
}), e.base || (e.base = N), e.toXYZ_M && e.fromXYZ_M && (e.toBase ??= (r) => {
|
|
485
|
+
let n = C(e.toXYZ_M, r);
|
|
486
|
+
return this.white !== this.base.white && (n = Re(this.white, this.base.white, n)), n;
|
|
487
|
+
}, e.fromBase ??= (r) => (r = Re(this.base.white, this.white, r), C(e.fromXYZ_M, r))), e.referred ??= "display", super(e);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function ue(t, e) {
|
|
491
|
+
return t = g(t), !e || t.space.equals(e) ? t.coords.slice() : (e = d.get(e), e.from(t));
|
|
492
|
+
}
|
|
493
|
+
function $(t, e) {
|
|
494
|
+
t = g(t);
|
|
495
|
+
let { space: r, index: n } = d.resolveCoord(e, t.space);
|
|
496
|
+
return ue(t, r)[n];
|
|
497
|
+
}
|
|
498
|
+
function Ve(t, e, r) {
|
|
499
|
+
return t = g(t), e = d.get(e), t.coords = e.to(t.space, r), t;
|
|
500
|
+
}
|
|
501
|
+
Ve.returns = "color";
|
|
502
|
+
function T(t, e, r) {
|
|
503
|
+
if (t = g(t), arguments.length === 2 && Y(arguments[1]) === "object") {
|
|
504
|
+
let n = arguments[1];
|
|
505
|
+
for (let a in n)
|
|
506
|
+
T(t, a, n[a]);
|
|
507
|
+
} else {
|
|
508
|
+
typeof r == "function" && (r = r($(t, e)));
|
|
509
|
+
let { space: n, index: a } = d.resolveCoord(e, t.space), s = ue(t, n);
|
|
510
|
+
s[a] = r, Ve(t, n, s);
|
|
511
|
+
}
|
|
512
|
+
return t;
|
|
513
|
+
}
|
|
514
|
+
T.returns = "color";
|
|
515
|
+
var et = new d({
|
|
516
|
+
id: "xyz-d50",
|
|
517
|
+
name: "XYZ D50",
|
|
518
|
+
white: "D50",
|
|
519
|
+
base: N,
|
|
520
|
+
fromBase: (t) => Re(N.white, "D50", t),
|
|
521
|
+
toBase: (t) => Re("D50", N.white, t)
|
|
522
|
+
});
|
|
523
|
+
const rr = 216 / 24389, dt = 24 / 116, ge = 24389 / 27;
|
|
524
|
+
let Ee = B.D50;
|
|
525
|
+
var P = new d({
|
|
526
|
+
id: "lab",
|
|
527
|
+
name: "Lab",
|
|
528
|
+
coords: {
|
|
529
|
+
l: {
|
|
530
|
+
refRange: [0, 100],
|
|
531
|
+
name: "Lightness"
|
|
532
|
+
},
|
|
533
|
+
a: {
|
|
534
|
+
refRange: [-125, 125]
|
|
535
|
+
},
|
|
536
|
+
b: {
|
|
537
|
+
refRange: [-125, 125]
|
|
538
|
+
}
|
|
539
|
+
},
|
|
540
|
+
// Assuming XYZ is relative to D50, convert to CIE Lab
|
|
541
|
+
// from CIE standard, which now defines these as a rational fraction
|
|
542
|
+
white: Ee,
|
|
543
|
+
base: et,
|
|
544
|
+
// Convert D50-adapted XYX to Lab
|
|
545
|
+
// CIE 15.3:2004 section 8.2.1.1
|
|
546
|
+
fromBase(t) {
|
|
547
|
+
let r = t.map((n, a) => n / Ee[a]).map((n) => n > rr ? Math.cbrt(n) : (ge * n + 16) / 116);
|
|
548
|
+
return [
|
|
549
|
+
116 * r[1] - 16,
|
|
550
|
+
// L
|
|
551
|
+
500 * (r[0] - r[1]),
|
|
552
|
+
// a
|
|
553
|
+
200 * (r[1] - r[2])
|
|
554
|
+
// b
|
|
555
|
+
];
|
|
556
|
+
},
|
|
557
|
+
// Convert Lab to D50-adapted XYZ
|
|
558
|
+
// Same result as CIE 15.3:2004 Appendix D although the derivation is different
|
|
559
|
+
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
560
|
+
toBase(t) {
|
|
561
|
+
let e = [];
|
|
562
|
+
return e[1] = (t[0] + 16) / 116, e[0] = t[1] / 500 + e[1], e[2] = e[1] - t[2] / 200, [
|
|
563
|
+
e[0] > dt ? Math.pow(e[0], 3) : (116 * e[0] - 16) / ge,
|
|
564
|
+
t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / ge,
|
|
565
|
+
e[2] > dt ? Math.pow(e[2], 3) : (116 * e[2] - 16) / ge
|
|
566
|
+
].map((n, a) => n * Ee[a]);
|
|
567
|
+
},
|
|
568
|
+
formats: {
|
|
569
|
+
lab: {
|
|
570
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
function k(t) {
|
|
575
|
+
return (t % 360 + 360) % 360;
|
|
576
|
+
}
|
|
577
|
+
function nr(t, e) {
|
|
578
|
+
if (t === "raw")
|
|
579
|
+
return e;
|
|
580
|
+
let [r, n] = e.map(k), a = n - r;
|
|
581
|
+
return t === "increasing" ? a < 0 && (n += 360) : t === "decreasing" ? a > 0 && (r += 360) : t === "longer" ? -180 < a && a < 180 && (a > 0 ? r += 360 : n += 360) : t === "shorter" && (a > 180 ? r += 360 : a < -180 && (n += 360)), [r, n];
|
|
582
|
+
}
|
|
583
|
+
var oe = new d({
|
|
584
|
+
id: "lch",
|
|
585
|
+
name: "LCH",
|
|
586
|
+
coords: {
|
|
587
|
+
l: {
|
|
588
|
+
refRange: [0, 100],
|
|
589
|
+
name: "Lightness"
|
|
590
|
+
},
|
|
591
|
+
c: {
|
|
592
|
+
refRange: [0, 150],
|
|
593
|
+
name: "Chroma"
|
|
594
|
+
},
|
|
595
|
+
h: {
|
|
596
|
+
refRange: [0, 360],
|
|
597
|
+
type: "angle",
|
|
598
|
+
name: "Hue"
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
base: P,
|
|
602
|
+
fromBase(t) {
|
|
603
|
+
let [e, r, n] = t, a;
|
|
604
|
+
const s = 0.02;
|
|
605
|
+
return Math.abs(r) < s && Math.abs(n) < s ? a = NaN : a = Math.atan2(n, r) * 180 / Math.PI, [
|
|
606
|
+
e,
|
|
607
|
+
// L is still L
|
|
608
|
+
Math.sqrt(r ** 2 + n ** 2),
|
|
609
|
+
// Chroma
|
|
610
|
+
k(a)
|
|
611
|
+
// Hue, in degrees [0 to 360)
|
|
612
|
+
];
|
|
613
|
+
},
|
|
614
|
+
toBase(t) {
|
|
615
|
+
let [e, r, n] = t;
|
|
616
|
+
return r < 0 && (r = 0), isNaN(n) && (n = 0), [
|
|
617
|
+
e,
|
|
618
|
+
// L is still L
|
|
619
|
+
r * Math.cos(n * Math.PI / 180),
|
|
620
|
+
// a
|
|
621
|
+
r * Math.sin(n * Math.PI / 180)
|
|
622
|
+
// b
|
|
623
|
+
];
|
|
624
|
+
},
|
|
625
|
+
formats: {
|
|
626
|
+
lch: {
|
|
627
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>", "<number> | <angle>"]
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
const mt = 25 ** 7, xe = Math.PI, gt = 180 / xe, J = xe / 180;
|
|
632
|
+
function pt(t) {
|
|
633
|
+
const e = t * t;
|
|
634
|
+
return e * e * e * t;
|
|
635
|
+
}
|
|
636
|
+
function p0(t, e, { kL: r = 1, kC: n = 1, kH: a = 1 } = {}) {
|
|
637
|
+
[t, e] = g([t, e]);
|
|
638
|
+
let [s, i, o] = P.from(t), l = oe.from(P, [s, i, o])[1], [f, u, c] = P.from(e), h = oe.from(P, [f, u, c])[1];
|
|
639
|
+
l < 0 && (l = 0), h < 0 && (h = 0);
|
|
640
|
+
let p = (l + h) / 2, m = pt(p), b = 0.5 * (1 - Math.sqrt(m / (m + mt))), M = (1 + b) * i, R = (1 + b) * u, L = Math.sqrt(M ** 2 + o ** 2), _ = Math.sqrt(R ** 2 + c ** 2), z = M === 0 && o === 0 ? 0 : Math.atan2(o, M), O = R === 0 && c === 0 ? 0 : Math.atan2(c, R);
|
|
641
|
+
z < 0 && (z += 2 * xe), O < 0 && (O += 2 * xe), z *= gt, O *= gt;
|
|
642
|
+
let he = f - s, de = _ - L, v = O - z, te = z + O, st = Math.abs(v), re;
|
|
643
|
+
L * _ === 0 ? re = 0 : st <= 180 ? re = v : v > 180 ? re = v - 360 : v < -180 ? re = v + 360 : E.warn("the unthinkable has happened");
|
|
644
|
+
let it = 2 * Math.sqrt(_ * L) * Math.sin(re * J / 2), Z0 = (s + f) / 2, Pe = (L + _) / 2, ot = pt(Pe), H;
|
|
645
|
+
L * _ === 0 ? H = te : st <= 180 ? H = te / 2 : te < 360 ? H = (te + 360) / 2 : H = (te - 360) / 2;
|
|
646
|
+
let lt = (Z0 - 50) ** 2, G0 = 1 + 0.015 * lt / Math.sqrt(20 + lt), ct = 1 + 0.045 * Pe, ne = 1;
|
|
647
|
+
ne -= 0.17 * Math.cos((H - 30) * J), ne += 0.24 * Math.cos(2 * H * J), ne += 0.32 * Math.cos((3 * H + 6) * J), ne -= 0.2 * Math.cos((4 * H - 63) * J);
|
|
648
|
+
let ut = 1 + 0.015 * Pe * ne, J0 = 30 * Math.exp(-1 * ((H - 275) / 25) ** 2), F0 = 2 * Math.sqrt(ot / (ot + mt)), W0 = -1 * Math.sin(2 * J0 * J) * F0, me = (he / (r * G0)) ** 2;
|
|
649
|
+
return me += (de / (n * ct)) ** 2, me += (it / (a * ut)) ** 2, me += W0 * (de / (n * ct)) * (it / (a * ut)), Math.sqrt(me);
|
|
650
|
+
}
|
|
651
|
+
const ar = [
|
|
652
|
+
[0.819022437996703, 0.3619062600528904, -0.1288737815209879],
|
|
653
|
+
[0.0329836539323885, 0.9292868615863434, 0.0361446663506424],
|
|
654
|
+
[0.0481771893596242, 0.2642395317527308, 0.6335478284694309]
|
|
655
|
+
], sr = [
|
|
656
|
+
[1.2268798758459243, -0.5578149944602171, 0.2813910456659647],
|
|
657
|
+
[-0.0405757452148008, 1.112286803280317, -0.0717110580655164],
|
|
658
|
+
[-0.0763729366746601, -0.4214933324022432, 1.5869240198367816]
|
|
659
|
+
], ir = [
|
|
660
|
+
[0.210454268309314, 0.7936177747023054, -0.0040720430116193],
|
|
661
|
+
[1.9779985324311684, -2.42859224204858, 0.450593709617411],
|
|
662
|
+
[0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
|
|
663
|
+
], or = [
|
|
664
|
+
[1, 0.3963377773761749, 0.2158037573099136],
|
|
665
|
+
[1, -0.1055613458156586, -0.0638541728258133],
|
|
666
|
+
[1, -0.0894841775298119, -1.2914855480194092]
|
|
667
|
+
];
|
|
668
|
+
var U = new d({
|
|
669
|
+
id: "oklab",
|
|
670
|
+
name: "Oklab",
|
|
671
|
+
coords: {
|
|
672
|
+
l: {
|
|
673
|
+
refRange: [0, 1],
|
|
674
|
+
name: "Lightness"
|
|
675
|
+
},
|
|
676
|
+
a: {
|
|
677
|
+
refRange: [-0.4, 0.4]
|
|
678
|
+
},
|
|
679
|
+
b: {
|
|
680
|
+
refRange: [-0.4, 0.4]
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
// Note that XYZ is relative to D65
|
|
684
|
+
white: "D65",
|
|
685
|
+
base: N,
|
|
686
|
+
fromBase(t) {
|
|
687
|
+
let r = C(ar, t).map((n) => Math.cbrt(n));
|
|
688
|
+
return C(ir, r);
|
|
689
|
+
},
|
|
690
|
+
toBase(t) {
|
|
691
|
+
let r = C(or, t).map((n) => n ** 3);
|
|
692
|
+
return C(sr, r);
|
|
693
|
+
},
|
|
694
|
+
formats: {
|
|
695
|
+
oklab: {
|
|
696
|
+
coords: ["<percentage> | <number>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
});
|
|
700
|
+
function qe(t, e) {
|
|
701
|
+
[t, e] = g([t, e]);
|
|
702
|
+
let [r, n, a] = U.from(t), [s, i, o] = U.from(e), l = r - s, f = n - i, u = a - o;
|
|
703
|
+
return Math.sqrt(l ** 2 + f ** 2 + u ** 2);
|
|
704
|
+
}
|
|
705
|
+
const lr = 75e-6;
|
|
706
|
+
function G(t, e, { epsilon: r = lr } = {}) {
|
|
707
|
+
t = g(t), e || (e = t.space), e = d.get(e);
|
|
708
|
+
let n = t.coords;
|
|
709
|
+
return e !== t.space && (n = e.from(t)), e.inGamut(n, { epsilon: r });
|
|
710
|
+
}
|
|
711
|
+
function K(t) {
|
|
712
|
+
return {
|
|
713
|
+
space: t.space,
|
|
714
|
+
coords: t.coords.slice(),
|
|
715
|
+
alpha: t.alpha
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
function b0(t, e, r = "lab") {
|
|
719
|
+
r = d.get(r);
|
|
720
|
+
let n = r.from(t), a = r.from(e);
|
|
721
|
+
return Math.sqrt(n.reduce((s, i, o) => {
|
|
722
|
+
let l = a[o];
|
|
723
|
+
return isNaN(i) || isNaN(l) ? s : s + (l - i) ** 2;
|
|
724
|
+
}, 0));
|
|
725
|
+
}
|
|
726
|
+
function cr(t, e) {
|
|
727
|
+
return b0(t, e, "lab");
|
|
728
|
+
}
|
|
729
|
+
const ur = Math.PI, bt = ur / 180;
|
|
730
|
+
function fr(t, e, { l: r = 2, c: n = 1 } = {}) {
|
|
731
|
+
[t, e] = g([t, e]);
|
|
732
|
+
let [a, s, i] = P.from(t), [, o, l] = oe.from(P, [a, s, i]), [f, u, c] = P.from(e), h = oe.from(P, [f, u, c])[1];
|
|
733
|
+
o < 0 && (o = 0), h < 0 && (h = 0);
|
|
734
|
+
let p = a - f, m = o - h, b = s - u, M = i - c, R = b ** 2 + M ** 2 - m ** 2, L = 0.511;
|
|
735
|
+
a >= 16 && (L = 0.040975 * a / (1 + 0.01765 * a));
|
|
736
|
+
let _ = 0.0638 * o / (1 + 0.0131 * o) + 0.638, z;
|
|
737
|
+
Number.isNaN(l) && (l = 0), l >= 164 && l <= 345 ? z = 0.56 + Math.abs(0.2 * Math.cos((l + 168) * bt)) : z = 0.36 + Math.abs(0.4 * Math.cos((l + 35) * bt));
|
|
738
|
+
let O = Math.pow(o, 4), he = Math.sqrt(O / (O + 1900)), de = _ * (he * z + 1 - he), v = (p / (r * L)) ** 2;
|
|
739
|
+
return v += (m / (n * _)) ** 2, v += R / de ** 2, Math.sqrt(v);
|
|
740
|
+
}
|
|
741
|
+
const Mt = 203;
|
|
742
|
+
var tt = new d({
|
|
743
|
+
// Absolute CIE XYZ, with a D65 whitepoint,
|
|
744
|
+
// as used in most HDR colorspaces as a starting point.
|
|
745
|
+
// SDR spaces are converted per BT.2048
|
|
746
|
+
// so that diffuse, media white is 203 cd/m²
|
|
747
|
+
id: "xyz-abs-d65",
|
|
748
|
+
cssId: "--xyz-abs-d65",
|
|
749
|
+
name: "Absolute XYZ D65",
|
|
750
|
+
coords: {
|
|
751
|
+
x: {
|
|
752
|
+
refRange: [0, 9504.7],
|
|
753
|
+
name: "Xa"
|
|
754
|
+
},
|
|
755
|
+
y: {
|
|
756
|
+
refRange: [0, 1e4],
|
|
757
|
+
name: "Ya"
|
|
758
|
+
},
|
|
759
|
+
z: {
|
|
760
|
+
refRange: [0, 10888.3],
|
|
761
|
+
name: "Za"
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
base: N,
|
|
765
|
+
fromBase(t) {
|
|
766
|
+
return t.map((e) => Math.max(e * Mt, 0));
|
|
767
|
+
},
|
|
768
|
+
toBase(t) {
|
|
769
|
+
return t.map((e) => Math.max(e / Mt, 0));
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
const pe = 1.15, be = 0.66, wt = 2610 / 2 ** 14, hr = 2 ** 14 / 2610, yt = 3424 / 2 ** 12, Ct = 2413 / 2 ** 7, Lt = 2392 / 2 ** 7, dr = 1.7 * 2523 / 2 ** 5, _t = 2 ** 5 / (1.7 * 2523), Me = -0.56, ve = 16295499532821565e-27, mr = [
|
|
773
|
+
[0.41478972, 0.579999, 0.014648],
|
|
774
|
+
[-0.20151, 1.120649, 0.0531008],
|
|
775
|
+
[-0.0166008, 0.2648, 0.6684799]
|
|
776
|
+
], gr = [
|
|
777
|
+
[1.9242264357876067, -1.0047923125953657, 0.037651404030618],
|
|
778
|
+
[0.35031676209499907, 0.7264811939316552, -0.06538442294808501],
|
|
779
|
+
[-0.09098281098284752, -0.3127282905230739, 1.5227665613052603]
|
|
780
|
+
], pr = [
|
|
781
|
+
[0.5, 0.5, 0],
|
|
782
|
+
[3.524, -4.066708, 0.542708],
|
|
783
|
+
[0.199076, 1.096799, -1.295875]
|
|
784
|
+
], br = [
|
|
785
|
+
[1, 0.1386050432715393, 0.05804731615611886],
|
|
786
|
+
[0.9999999999999999, -0.1386050432715393, -0.05804731615611886],
|
|
787
|
+
[0.9999999999999998, -0.09601924202631895, -0.8118918960560388]
|
|
788
|
+
];
|
|
789
|
+
var M0 = new d({
|
|
790
|
+
id: "jzazbz",
|
|
791
|
+
name: "Jzazbz",
|
|
792
|
+
coords: {
|
|
793
|
+
jz: {
|
|
794
|
+
refRange: [0, 1],
|
|
795
|
+
name: "Jz"
|
|
796
|
+
},
|
|
797
|
+
az: {
|
|
798
|
+
refRange: [-0.5, 0.5]
|
|
799
|
+
},
|
|
800
|
+
bz: {
|
|
801
|
+
refRange: [-0.5, 0.5]
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
base: tt,
|
|
805
|
+
fromBase(t) {
|
|
806
|
+
let [e, r, n] = t, a = pe * e - (pe - 1) * n, s = be * r - (be - 1) * e, o = C(mr, [a, s, n]).map(function(h) {
|
|
807
|
+
let p = yt + Ct * (h / 1e4) ** wt, m = 1 + Lt * (h / 1e4) ** wt;
|
|
808
|
+
return (p / m) ** dr;
|
|
809
|
+
}), [l, f, u] = C(pr, o);
|
|
810
|
+
return [(1 + Me) * l / (1 + Me * l) - ve, f, u];
|
|
811
|
+
},
|
|
812
|
+
toBase(t) {
|
|
813
|
+
let [e, r, n] = t, a = (e + ve) / (1 + Me - Me * (e + ve)), i = C(br, [a, r, n]).map(function(h) {
|
|
814
|
+
let p = yt - h ** _t, m = Lt * h ** _t - Ct;
|
|
815
|
+
return 1e4 * (p / m) ** hr;
|
|
816
|
+
}), [o, l, f] = C(gr, i), u = (o + (pe - 1) * f) / pe, c = (l + (be - 1) * u) / be;
|
|
817
|
+
return [u, c, f];
|
|
818
|
+
},
|
|
819
|
+
formats: {
|
|
820
|
+
// https://drafts.csswg.org/css-color-hdr/#Jzazbz
|
|
821
|
+
color: {
|
|
822
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}), Ze = new d({
|
|
826
|
+
id: "jzczhz",
|
|
827
|
+
name: "JzCzHz",
|
|
828
|
+
coords: {
|
|
829
|
+
jz: {
|
|
830
|
+
refRange: [0, 1],
|
|
831
|
+
name: "Jz"
|
|
832
|
+
},
|
|
833
|
+
cz: {
|
|
834
|
+
refRange: [0, 1],
|
|
835
|
+
name: "Chroma"
|
|
836
|
+
},
|
|
837
|
+
hz: {
|
|
838
|
+
refRange: [0, 360],
|
|
839
|
+
type: "angle",
|
|
840
|
+
name: "Hue"
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
base: M0,
|
|
844
|
+
fromBase(t) {
|
|
845
|
+
let [e, r, n] = t, a;
|
|
846
|
+
const s = 2e-4;
|
|
847
|
+
return Math.abs(r) < s && Math.abs(n) < s ? a = NaN : a = Math.atan2(n, r) * 180 / Math.PI, [
|
|
848
|
+
e,
|
|
849
|
+
// Jz is still Jz
|
|
850
|
+
Math.sqrt(r ** 2 + n ** 2),
|
|
851
|
+
// Chroma
|
|
852
|
+
k(a)
|
|
853
|
+
// Hue, in degrees [0 to 360)
|
|
854
|
+
];
|
|
855
|
+
},
|
|
856
|
+
toBase(t) {
|
|
857
|
+
return [
|
|
858
|
+
t[0],
|
|
859
|
+
// Jz is still Jz
|
|
860
|
+
t[1] * Math.cos(t[2] * Math.PI / 180),
|
|
861
|
+
// az
|
|
862
|
+
t[1] * Math.sin(t[2] * Math.PI / 180)
|
|
863
|
+
// bz
|
|
864
|
+
];
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
function Mr(t, e) {
|
|
868
|
+
[t, e] = g([t, e]);
|
|
869
|
+
let [r, n, a] = Ze.from(t), [s, i, o] = Ze.from(e), l = r - s, f = n - i;
|
|
870
|
+
Number.isNaN(a) && Number.isNaN(o) ? (a = 0, o = 0) : Number.isNaN(a) ? a = o : Number.isNaN(o) && (o = a);
|
|
871
|
+
let u = a - o, c = 2 * Math.sqrt(n * i) * Math.sin(u / 2 * (Math.PI / 180));
|
|
872
|
+
return Math.sqrt(l ** 2 + f ** 2 + c ** 2);
|
|
873
|
+
}
|
|
874
|
+
const w0 = 3424 / 4096, y0 = 2413 / 128, C0 = 2392 / 128, St = 2610 / 16384, wr = 2523 / 32, yr = 16384 / 2610, Rt = 32 / 2523, Cr = [
|
|
875
|
+
[0.3592832590121217, 0.6976051147779502, -0.035891593232029],
|
|
876
|
+
[-0.1920808463704993, 1.100476797037432, 0.0753748658519118],
|
|
877
|
+
[0.0070797844607479, 0.0748396662186362, 0.8433265453898765]
|
|
878
|
+
], Lr = [
|
|
879
|
+
[2048 / 4096, 2048 / 4096, 0],
|
|
880
|
+
[6610 / 4096, -13613 / 4096, 7003 / 4096],
|
|
881
|
+
[17933 / 4096, -17390 / 4096, -543 / 4096]
|
|
882
|
+
], _r = [
|
|
883
|
+
[0.9999999999999998, 0.0086090370379328, 0.111029625003026],
|
|
884
|
+
[0.9999999999999998, -0.0086090370379328, -0.1110296250030259],
|
|
885
|
+
[0.9999999999999998, 0.5600313357106791, -0.3206271749873188]
|
|
886
|
+
], Sr = [
|
|
887
|
+
[2.0701522183894223, -1.3263473389671563, 0.2066510476294053],
|
|
888
|
+
[0.3647385209748072, 0.6805660249472273, -0.0453045459220347],
|
|
889
|
+
[-0.0497472075358123, -0.0492609666966131, 1.1880659249923042]
|
|
890
|
+
];
|
|
891
|
+
var Ge = new d({
|
|
892
|
+
id: "ictcp",
|
|
893
|
+
name: "ICTCP",
|
|
894
|
+
// From BT.2100-2 page 7:
|
|
895
|
+
// During production, signal values are expected to exceed the
|
|
896
|
+
// range E′ = [0.0 : 1.0]. This provides processing headroom and avoids
|
|
897
|
+
// signal degradation during cascaded processing. Such values of E′,
|
|
898
|
+
// below 0.0 or exceeding 1.0, should not be clipped during production
|
|
899
|
+
// and exchange.
|
|
900
|
+
// Values below 0.0 should not be clipped in reference displays (even
|
|
901
|
+
// though they represent “negative” light) to allow the black level of
|
|
902
|
+
// the signal (LB) to be properly set using test signals known as “PLUGE”
|
|
903
|
+
coords: {
|
|
904
|
+
i: {
|
|
905
|
+
refRange: [0, 1],
|
|
906
|
+
// Constant luminance,
|
|
907
|
+
name: "I"
|
|
908
|
+
},
|
|
909
|
+
ct: {
|
|
910
|
+
refRange: [-0.5, 0.5],
|
|
911
|
+
// Full BT.2020 gamut in range [-0.5, 0.5]
|
|
912
|
+
name: "CT"
|
|
913
|
+
},
|
|
914
|
+
cp: {
|
|
915
|
+
refRange: [-0.5, 0.5],
|
|
916
|
+
name: "CP"
|
|
917
|
+
}
|
|
918
|
+
},
|
|
919
|
+
base: tt,
|
|
920
|
+
fromBase(t) {
|
|
921
|
+
let e = C(Cr, t);
|
|
922
|
+
return Rr(e);
|
|
923
|
+
},
|
|
924
|
+
toBase(t) {
|
|
925
|
+
let e = xr(t);
|
|
926
|
+
return C(Sr, e);
|
|
927
|
+
}
|
|
928
|
+
});
|
|
929
|
+
function Rr(t) {
|
|
930
|
+
let e = t.map(function(r) {
|
|
931
|
+
let n = w0 + y0 * (r / 1e4) ** St, a = 1 + C0 * (r / 1e4) ** St;
|
|
932
|
+
return (n / a) ** wr;
|
|
933
|
+
});
|
|
934
|
+
return C(Lr, e);
|
|
935
|
+
}
|
|
936
|
+
function xr(t) {
|
|
937
|
+
return C(_r, t).map(function(n) {
|
|
938
|
+
let a = Math.max(n ** Rt - w0, 0), s = y0 - C0 * n ** Rt;
|
|
939
|
+
return 1e4 * (a / s) ** yr;
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
function Nr(t, e) {
|
|
943
|
+
[t, e] = g([t, e]);
|
|
944
|
+
let [r, n, a] = Ge.from(t), [s, i, o] = Ge.from(e);
|
|
945
|
+
return 720 * Math.sqrt((r - s) ** 2 + 0.25 * (n - i) ** 2 + (a - o) ** 2);
|
|
946
|
+
}
|
|
947
|
+
const Br = B.D65, L0 = 0.42, xt = 1 / L0, Ae = 2 * Math.PI, _0 = [
|
|
948
|
+
[0.401288, 0.650173, -0.051461],
|
|
949
|
+
[-0.250268, 1.204414, 0.045854],
|
|
950
|
+
[-2079e-6, 0.048952, 0.953127]
|
|
951
|
+
], Ir = [
|
|
952
|
+
[1.8620678550872327, -1.0112546305316843, 0.14918677544445175],
|
|
953
|
+
[0.38752654323613717, 0.6214474419314753, -0.008973985167612518],
|
|
954
|
+
[-0.015841498849333856, -0.03412293802851557, 1.0499644368778496]
|
|
955
|
+
], zr = [
|
|
956
|
+
[460, 451, 288],
|
|
957
|
+
[460, -891, -261],
|
|
958
|
+
[460, -220, -6300]
|
|
959
|
+
], $r = {
|
|
960
|
+
dark: [0.8, 0.525, 0.8],
|
|
961
|
+
dim: [0.9, 0.59, 0.9],
|
|
962
|
+
average: [1, 0.69, 1]
|
|
963
|
+
}, Z = {
|
|
964
|
+
// Red, Yellow, Green, Blue, Red
|
|
965
|
+
h: [20.14, 90, 164.25, 237.53, 380.14],
|
|
966
|
+
e: [0.8, 0.7, 1, 1.2, 0.8],
|
|
967
|
+
H: [0, 100, 200, 300, 400]
|
|
968
|
+
}, Pr = 180 / Math.PI, Nt = Math.PI / 180;
|
|
969
|
+
function S0(t, e) {
|
|
970
|
+
return t.map((n) => {
|
|
971
|
+
const a = A(e * Math.abs(n) * 0.01, L0);
|
|
972
|
+
return 400 * Be(a, n) / (a + 27.13);
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
function Er(t, e) {
|
|
976
|
+
const r = 100 / e * 27.13 ** xt;
|
|
977
|
+
return t.map((n) => {
|
|
978
|
+
const a = Math.abs(n);
|
|
979
|
+
return Be(r * A(a / (400 - a), xt), n);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
function vr(t) {
|
|
983
|
+
let e = k(t);
|
|
984
|
+
e <= Z.h[0] && (e += 360);
|
|
985
|
+
const r = m0(Z.h, e) - 1, [n, a] = Z.h.slice(r, r + 2), [s, i] = Z.e.slice(r, r + 2), o = Z.H[r], l = (e - n) / s;
|
|
986
|
+
return o + 100 * l / (l + (a - e) / i);
|
|
987
|
+
}
|
|
988
|
+
function Ar(t) {
|
|
989
|
+
let e = (t % 400 + 400) % 400;
|
|
990
|
+
const r = Math.floor(0.01 * e);
|
|
991
|
+
e = e % 100;
|
|
992
|
+
const [n, a] = Z.h.slice(r, r + 2), [s, i] = Z.e.slice(r, r + 2);
|
|
993
|
+
return k(
|
|
994
|
+
(e * (i * n - s * a) - 100 * n * i) / (e * (i - s) - 100 * i)
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
function R0(t, e, r, n, a) {
|
|
998
|
+
const s = {};
|
|
999
|
+
s.discounting = a, s.refWhite = t, s.surround = n;
|
|
1000
|
+
const i = t.map((b) => b * 100);
|
|
1001
|
+
s.la = e, s.yb = r;
|
|
1002
|
+
const o = i[1], l = C(_0, i);
|
|
1003
|
+
n = $r[s.surround];
|
|
1004
|
+
const f = n[0];
|
|
1005
|
+
s.c = n[1], s.nc = n[2];
|
|
1006
|
+
const c = (1 / (5 * s.la + 1)) ** 4;
|
|
1007
|
+
s.fl = c * s.la + 0.1 * (1 - c) * (1 - c) * Math.cbrt(5 * s.la), s.flRoot = s.fl ** 0.25, s.n = s.yb / o, s.z = 1.48 + Math.sqrt(s.n), s.nbb = 0.725 * s.n ** -0.2, s.ncb = s.nbb;
|
|
1008
|
+
const h = Math.max(
|
|
1009
|
+
Math.min(f * (1 - 1 / 3.6 * Math.exp((-s.la - 42) / 92)), 1),
|
|
1010
|
+
0
|
|
1011
|
+
);
|
|
1012
|
+
s.dRgb = l.map((b) => ie(1, o / b, h)), s.dRgbInv = s.dRgb.map((b) => 1 / b);
|
|
1013
|
+
const p = l.map((b, M) => b * s.dRgb[M]), m = S0(p, s.fl);
|
|
1014
|
+
return s.aW = s.nbb * (2 * m[0] + m[1] + 0.05 * m[2]), s;
|
|
1015
|
+
}
|
|
1016
|
+
const Bt = R0(
|
|
1017
|
+
Br,
|
|
1018
|
+
64 / Math.PI * 0.2,
|
|
1019
|
+
20,
|
|
1020
|
+
"average",
|
|
1021
|
+
!1
|
|
1022
|
+
);
|
|
1023
|
+
function Je(t, e) {
|
|
1024
|
+
if (!(t.J !== void 0 ^ t.Q !== void 0))
|
|
1025
|
+
throw new Error("Conversion requires one and only one: 'J' or 'Q'");
|
|
1026
|
+
if (!(t.C !== void 0 ^ t.M !== void 0 ^ t.s !== void 0))
|
|
1027
|
+
throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");
|
|
1028
|
+
if (!(t.h !== void 0 ^ t.H !== void 0))
|
|
1029
|
+
throw new Error("Conversion requires one and only one: 'h' or 'H'");
|
|
1030
|
+
if (t.J === 0 || t.Q === 0)
|
|
1031
|
+
return [0, 0, 0];
|
|
1032
|
+
let r = 0;
|
|
1033
|
+
t.h !== void 0 ? r = k(t.h) * Nt : r = Ar(t.H) * Nt;
|
|
1034
|
+
const n = Math.cos(r), a = Math.sin(r);
|
|
1035
|
+
let s = 0;
|
|
1036
|
+
t.J !== void 0 ? s = A(t.J, 1 / 2) * 0.1 : t.Q !== void 0 && (s = 0.25 * e.c * t.Q / ((e.aW + 4) * e.flRoot));
|
|
1037
|
+
let i = 0;
|
|
1038
|
+
t.C !== void 0 ? i = t.C / s : t.M !== void 0 ? i = t.M / e.flRoot / s : t.s !== void 0 && (i = 4e-4 * t.s ** 2 * (e.aW + 4) / e.c);
|
|
1039
|
+
const o = A(
|
|
1040
|
+
i * Math.pow(1.64 - Math.pow(0.29, e.n), -0.73),
|
|
1041
|
+
10 / 9
|
|
1042
|
+
), l = 0.25 * (Math.cos(r + 2) + 3.8), f = e.aW * A(s, 2 / e.c / e.z), u = 5e4 / 13 * e.nc * e.ncb * l, c = f / e.nbb, h = 23 * (c + 0.305) * Ke(o, 23 * u + o * (11 * n + 108 * a)), p = h * n, m = h * a, b = Er(
|
|
1043
|
+
C(zr, [c, p, m]).map((M) => M * 1 / 1403),
|
|
1044
|
+
e.fl
|
|
1045
|
+
);
|
|
1046
|
+
return C(
|
|
1047
|
+
Ir,
|
|
1048
|
+
b.map((M, R) => M * e.dRgbInv[R])
|
|
1049
|
+
).map((M) => M / 100);
|
|
1050
|
+
}
|
|
1051
|
+
function x0(t, e) {
|
|
1052
|
+
const r = t.map((_) => _ * 100), n = S0(
|
|
1053
|
+
C(_0, r).map((_, z) => _ * e.dRgb[z]),
|
|
1054
|
+
e.fl
|
|
1055
|
+
), a = n[0] + (-12 * n[1] + n[2]) / 11, s = (n[0] + n[1] - 2 * n[2]) / 9, i = (Math.atan2(s, a) % Ae + Ae) % Ae, o = 0.25 * (Math.cos(i + 2) + 3.8), l = 5e4 / 13 * e.nc * e.ncb * Ke(
|
|
1056
|
+
o * Math.sqrt(a ** 2 + s ** 2),
|
|
1057
|
+
n[0] + n[1] + 1.05 * n[2] + 0.305
|
|
1058
|
+
), f = A(l, 0.9) * Math.pow(1.64 - Math.pow(0.29, e.n), 0.73), u = e.nbb * (2 * n[0] + n[1] + 0.05 * n[2]), c = A(u / e.aW, 0.5 * e.c * e.z), h = 100 * A(c, 2), p = 4 / e.c * c * (e.aW + 4) * e.flRoot, m = f * c, b = m * e.flRoot, M = k(i * Pr), R = vr(M), L = 50 * A(e.c * f / (e.aW + 4), 1 / 2);
|
|
1059
|
+
return { J: h, C: m, h: M, s: L, Q: p, M: b, H: R };
|
|
1060
|
+
}
|
|
1061
|
+
var kr = new d({
|
|
1062
|
+
id: "cam16-jmh",
|
|
1063
|
+
cssId: "--cam16-jmh",
|
|
1064
|
+
name: "CAM16-JMh",
|
|
1065
|
+
coords: {
|
|
1066
|
+
j: {
|
|
1067
|
+
refRange: [0, 100],
|
|
1068
|
+
name: "J"
|
|
1069
|
+
},
|
|
1070
|
+
m: {
|
|
1071
|
+
refRange: [0, 105],
|
|
1072
|
+
name: "Colorfulness"
|
|
1073
|
+
},
|
|
1074
|
+
h: {
|
|
1075
|
+
refRange: [0, 360],
|
|
1076
|
+
type: "angle",
|
|
1077
|
+
name: "Hue"
|
|
1078
|
+
}
|
|
1079
|
+
},
|
|
1080
|
+
base: N,
|
|
1081
|
+
fromBase(t) {
|
|
1082
|
+
const e = x0(t, Bt);
|
|
1083
|
+
return [e.J, e.M, e.h];
|
|
1084
|
+
},
|
|
1085
|
+
toBase(t) {
|
|
1086
|
+
return Je(
|
|
1087
|
+
{ J: t[0], M: t[1], h: t[2] },
|
|
1088
|
+
Bt
|
|
1089
|
+
);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
const Hr = B.D65, Tr = 216 / 24389, N0 = 24389 / 27;
|
|
1093
|
+
function Or(t) {
|
|
1094
|
+
return 116 * (t > Tr ? Math.cbrt(t) : (N0 * t + 16) / 116) - 16;
|
|
1095
|
+
}
|
|
1096
|
+
function Fe(t) {
|
|
1097
|
+
return t > 8 ? Math.pow((t + 16) / 116, 3) : t / N0;
|
|
1098
|
+
}
|
|
1099
|
+
function Yr(t, e) {
|
|
1100
|
+
let [r, n, a] = t, s = [], i = 0;
|
|
1101
|
+
if (a === 0)
|
|
1102
|
+
return [0, 0, 0];
|
|
1103
|
+
let o = Fe(a);
|
|
1104
|
+
a > 0 ? i = 0.00379058511492914 * a ** 2 + 0.608983189401032 * a + 0.9155088574762233 : i = 9514440756550361e-21 * a ** 2 + 0.08693057439788597 * a - 21.928975842194614;
|
|
1105
|
+
const l = 2e-12, f = 15;
|
|
1106
|
+
let u = 0, c = 1 / 0;
|
|
1107
|
+
for (; u <= f; ) {
|
|
1108
|
+
s = Je({ J: i, C: n, h: r }, e);
|
|
1109
|
+
const h = Math.abs(s[1] - o);
|
|
1110
|
+
if (h < c) {
|
|
1111
|
+
if (h <= l)
|
|
1112
|
+
return s;
|
|
1113
|
+
c = h;
|
|
1114
|
+
}
|
|
1115
|
+
i = i - (s[1] - o) * i / (2 * s[1]), u += 1;
|
|
1116
|
+
}
|
|
1117
|
+
return Je({ J: i, C: n, h: r }, e);
|
|
1118
|
+
}
|
|
1119
|
+
function Dr(t, e) {
|
|
1120
|
+
const r = Or(t[1]);
|
|
1121
|
+
if (r === 0)
|
|
1122
|
+
return [0, 0, 0];
|
|
1123
|
+
const n = x0(t, rt);
|
|
1124
|
+
return [k(n.h), n.C, r];
|
|
1125
|
+
}
|
|
1126
|
+
const rt = R0(
|
|
1127
|
+
Hr,
|
|
1128
|
+
200 / Math.PI * Fe(50),
|
|
1129
|
+
Fe(50) * 100,
|
|
1130
|
+
"average",
|
|
1131
|
+
!1
|
|
1132
|
+
);
|
|
1133
|
+
var le = new d({
|
|
1134
|
+
id: "hct",
|
|
1135
|
+
name: "HCT",
|
|
1136
|
+
coords: {
|
|
1137
|
+
h: {
|
|
1138
|
+
refRange: [0, 360],
|
|
1139
|
+
type: "angle",
|
|
1140
|
+
name: "Hue"
|
|
1141
|
+
},
|
|
1142
|
+
c: {
|
|
1143
|
+
refRange: [0, 145],
|
|
1144
|
+
name: "Colorfulness"
|
|
1145
|
+
},
|
|
1146
|
+
t: {
|
|
1147
|
+
refRange: [0, 100],
|
|
1148
|
+
name: "Tone"
|
|
1149
|
+
}
|
|
1150
|
+
},
|
|
1151
|
+
base: N,
|
|
1152
|
+
fromBase(t) {
|
|
1153
|
+
return Dr(t);
|
|
1154
|
+
},
|
|
1155
|
+
toBase(t) {
|
|
1156
|
+
return Yr(t, rt);
|
|
1157
|
+
},
|
|
1158
|
+
formats: {
|
|
1159
|
+
color: {
|
|
1160
|
+
id: "--hct",
|
|
1161
|
+
coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
const Xr = Math.PI / 180, It = [1, 7e-3, 0.0228];
|
|
1166
|
+
function zt(t) {
|
|
1167
|
+
t[1] < 0 && (t = le.fromBase(le.toBase(t)));
|
|
1168
|
+
const e = Math.log(Math.max(1 + It[2] * t[1] * rt.flRoot, 1)) / It[2], r = t[0] * Xr, n = e * Math.cos(r), a = e * Math.sin(r);
|
|
1169
|
+
return [t[2], n, a];
|
|
1170
|
+
}
|
|
1171
|
+
function jr(t, e) {
|
|
1172
|
+
[t, e] = g([t, e]);
|
|
1173
|
+
let [r, n, a] = zt(le.from(t)), [s, i, o] = zt(le.from(e));
|
|
1174
|
+
return Math.sqrt((r - s) ** 2 + (n - i) ** 2 + (a - o) ** 2);
|
|
1175
|
+
}
|
|
1176
|
+
var V = {
|
|
1177
|
+
deltaE76: cr,
|
|
1178
|
+
deltaECMC: fr,
|
|
1179
|
+
deltaE2000: p0,
|
|
1180
|
+
deltaEJz: Mr,
|
|
1181
|
+
deltaEITP: Nr,
|
|
1182
|
+
deltaEOK: qe,
|
|
1183
|
+
deltaEHCT: jr
|
|
1184
|
+
};
|
|
1185
|
+
function qr(t) {
|
|
1186
|
+
const e = t ? Math.floor(Math.log10(Math.abs(t))) : 0;
|
|
1187
|
+
return Math.max(parseFloat(`1e${e - 2}`), 1e-6);
|
|
1188
|
+
}
|
|
1189
|
+
const $t = {
|
|
1190
|
+
hct: {
|
|
1191
|
+
method: "hct.c",
|
|
1192
|
+
jnd: 2,
|
|
1193
|
+
deltaEMethod: "hct",
|
|
1194
|
+
blackWhiteClamp: {}
|
|
1195
|
+
},
|
|
1196
|
+
"hct-tonal": {
|
|
1197
|
+
method: "hct.c",
|
|
1198
|
+
jnd: 0,
|
|
1199
|
+
deltaEMethod: "hct",
|
|
1200
|
+
blackWhiteClamp: { channel: "hct.t", min: 0, max: 100 }
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
function j(t, {
|
|
1204
|
+
method: e = E.gamut_mapping,
|
|
1205
|
+
space: r = void 0,
|
|
1206
|
+
deltaEMethod: n = "",
|
|
1207
|
+
jnd: a = 2,
|
|
1208
|
+
blackWhiteClamp: s = {}
|
|
1209
|
+
} = {}) {
|
|
1210
|
+
if (t = g(t), ce(arguments[1]) ? r = arguments[1] : r || (r = t.space), r = d.get(r), G(t, r, { epsilon: 0 }))
|
|
1211
|
+
return t;
|
|
1212
|
+
let i;
|
|
1213
|
+
if (e === "css")
|
|
1214
|
+
i = Zr(t, { space: r });
|
|
1215
|
+
else {
|
|
1216
|
+
if (e !== "clip" && !G(t, r)) {
|
|
1217
|
+
Object.prototype.hasOwnProperty.call($t, e) && ({ method: e, jnd: a, deltaEMethod: n, blackWhiteClamp: s } = $t[e]);
|
|
1218
|
+
let o = p0;
|
|
1219
|
+
if (n !== "") {
|
|
1220
|
+
for (let f in V)
|
|
1221
|
+
if ("deltae" + n.toLowerCase() === f.toLowerCase()) {
|
|
1222
|
+
o = V[f];
|
|
1223
|
+
break;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
let l = j(y(t, r), { method: "clip", space: r });
|
|
1227
|
+
if (o(t, l) > a) {
|
|
1228
|
+
if (Object.keys(s).length === 3) {
|
|
1229
|
+
let L = d.resolveCoord(s.channel), _ = $(y(t, L.space), L.id);
|
|
1230
|
+
if (D(_) && (_ = 0), _ >= s.max)
|
|
1231
|
+
return y({ space: "xyz-d65", coords: B.D65 }, t.space);
|
|
1232
|
+
if (_ <= s.min)
|
|
1233
|
+
return y({ space: "xyz-d65", coords: [0, 0, 0] }, t.space);
|
|
1234
|
+
}
|
|
1235
|
+
let f = d.resolveCoord(e), u = f.space, c = f.id, h = y(t, u);
|
|
1236
|
+
h.coords.forEach((L, _) => {
|
|
1237
|
+
D(L) && (h.coords[_] = 0);
|
|
1238
|
+
});
|
|
1239
|
+
let m = (f.range || f.refRange)[0], b = qr(a), M = m, R = $(h, c);
|
|
1240
|
+
for (; R - M > b; ) {
|
|
1241
|
+
let L = K(h);
|
|
1242
|
+
L = j(L, { space: r, method: "clip" }), o(h, L) - a < b ? M = $(h, c) : R = $(h, c), T(h, c, (M + R) / 2);
|
|
1243
|
+
}
|
|
1244
|
+
i = y(h, r);
|
|
1245
|
+
} else
|
|
1246
|
+
i = l;
|
|
1247
|
+
} else
|
|
1248
|
+
i = y(t, r);
|
|
1249
|
+
if (e === "clip" || !G(i, r, { epsilon: 0 })) {
|
|
1250
|
+
let o = Object.values(r.coords).map((l) => l.range || []);
|
|
1251
|
+
i.coords = i.coords.map((l, f) => {
|
|
1252
|
+
let [u, c] = o[f];
|
|
1253
|
+
return u !== void 0 && (l = Math.max(u, l)), c !== void 0 && (l = Math.min(l, c)), l;
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return r !== t.space && (i = y(i, t.space)), t.coords = i.coords, t;
|
|
1258
|
+
}
|
|
1259
|
+
j.returns = "color";
|
|
1260
|
+
const Pt = {
|
|
1261
|
+
WHITE: { space: U, coords: [1, 0, 0] },
|
|
1262
|
+
BLACK: { space: U, coords: [0, 0, 0] }
|
|
1263
|
+
};
|
|
1264
|
+
function Zr(t, { space: e } = {}) {
|
|
1265
|
+
t = g(t), e || (e = t.space), e = d.get(e);
|
|
1266
|
+
const a = d.get("oklch");
|
|
1267
|
+
if (e.isUnbounded)
|
|
1268
|
+
return y(t, e);
|
|
1269
|
+
const s = y(t, a);
|
|
1270
|
+
let i = s.coords[0];
|
|
1271
|
+
if (i >= 1) {
|
|
1272
|
+
const m = y(Pt.WHITE, e);
|
|
1273
|
+
return m.alpha = t.alpha, y(m, e);
|
|
1274
|
+
}
|
|
1275
|
+
if (i <= 0) {
|
|
1276
|
+
const m = y(Pt.BLACK, e);
|
|
1277
|
+
return m.alpha = t.alpha, y(m, e);
|
|
1278
|
+
}
|
|
1279
|
+
if (G(s, e, { epsilon: 0 }))
|
|
1280
|
+
return y(s, e);
|
|
1281
|
+
function o(m) {
|
|
1282
|
+
const b = y(m, e), M = Object.values(e.coords);
|
|
1283
|
+
return b.coords = b.coords.map((R, L) => {
|
|
1284
|
+
if ("range" in M[L]) {
|
|
1285
|
+
const [_, z] = M[L].range;
|
|
1286
|
+
return d0(_, R, z);
|
|
1287
|
+
}
|
|
1288
|
+
return R;
|
|
1289
|
+
}), b;
|
|
1290
|
+
}
|
|
1291
|
+
let l = 0, f = s.coords[1], u = !0, c = K(s), h = o(c), p = qe(h, c);
|
|
1292
|
+
if (p < 0.02)
|
|
1293
|
+
return h;
|
|
1294
|
+
for (; f - l > 1e-4; ) {
|
|
1295
|
+
const m = (l + f) / 2;
|
|
1296
|
+
if (c.coords[1] = m, u && G(c, e, { epsilon: 0 }))
|
|
1297
|
+
l = m;
|
|
1298
|
+
else if (h = o(c), p = qe(h, c), p < 0.02) {
|
|
1299
|
+
if (0.02 - p < 1e-4)
|
|
1300
|
+
break;
|
|
1301
|
+
u = !1, l = m;
|
|
1302
|
+
} else
|
|
1303
|
+
f = m;
|
|
1304
|
+
}
|
|
1305
|
+
return h;
|
|
1306
|
+
}
|
|
1307
|
+
function y(t, e, { inGamut: r } = {}) {
|
|
1308
|
+
t = g(t), e = d.get(e);
|
|
1309
|
+
let n = e.from(t), a = { space: e, coords: n, alpha: t.alpha };
|
|
1310
|
+
return r && (a = j(a, r === !0 ? void 0 : r)), a;
|
|
1311
|
+
}
|
|
1312
|
+
y.returns = "color";
|
|
1313
|
+
function se(t, {
|
|
1314
|
+
precision: e = E.precision,
|
|
1315
|
+
format: r = "default",
|
|
1316
|
+
inGamut: n = !0,
|
|
1317
|
+
...a
|
|
1318
|
+
} = {}) {
|
|
1319
|
+
let s;
|
|
1320
|
+
t = g(t);
|
|
1321
|
+
let i = r;
|
|
1322
|
+
r = t.space.getFormat(r) ?? t.space.getFormat("default") ?? d.DEFAULT_FORMAT;
|
|
1323
|
+
let o = t.coords.slice();
|
|
1324
|
+
if (n ||= r.toGamut, n && !G(t) && (o = j(K(t), n === !0 ? void 0 : n).coords), r.type === "custom")
|
|
1325
|
+
if (a.precision = e, r.serialize)
|
|
1326
|
+
s = r.serialize(o, t.alpha, a);
|
|
1327
|
+
else
|
|
1328
|
+
throw new TypeError(`format ${i} can only be used to parse colors, not for serialization`);
|
|
1329
|
+
else {
|
|
1330
|
+
let l = r.name || "color";
|
|
1331
|
+
r.serializeCoords ? o = r.serializeCoords(o, e) : e !== null && (o = o.map((h) => Se(h, { precision: e })));
|
|
1332
|
+
let f = [...o];
|
|
1333
|
+
if (l === "color") {
|
|
1334
|
+
let h = r.id || r.ids?.[0] || t.space.id;
|
|
1335
|
+
f.unshift(h);
|
|
1336
|
+
}
|
|
1337
|
+
let u = t.alpha;
|
|
1338
|
+
e !== null && (u = Se(u, { precision: e }));
|
|
1339
|
+
let c = t.alpha >= 1 || r.noAlpha ? "" : `${r.commas ? "," : " /"} ${u}`;
|
|
1340
|
+
s = `${l}(${f.join(r.commas ? ", " : " ")}${c})`;
|
|
1341
|
+
}
|
|
1342
|
+
return s;
|
|
1343
|
+
}
|
|
1344
|
+
const Gr = [
|
|
1345
|
+
[0.6369580483012914, 0.14461690358620832, 0.1688809751641721],
|
|
1346
|
+
[0.2627002120112671, 0.6779980715188708, 0.05930171646986196],
|
|
1347
|
+
[0, 0.028072693049087428, 1.060985057710791]
|
|
1348
|
+
], Jr = [
|
|
1349
|
+
[1.716651187971268, -0.355670783776392, -0.25336628137366],
|
|
1350
|
+
[-0.666684351832489, 1.616481236634939, 0.0157685458139111],
|
|
1351
|
+
[0.017639857445311, -0.042770613257809, 0.942103121235474]
|
|
1352
|
+
];
|
|
1353
|
+
var Ie = new I({
|
|
1354
|
+
id: "rec2020-linear",
|
|
1355
|
+
cssId: "--rec2020-linear",
|
|
1356
|
+
name: "Linear REC.2020",
|
|
1357
|
+
white: "D65",
|
|
1358
|
+
toXYZ_M: Gr,
|
|
1359
|
+
fromXYZ_M: Jr
|
|
1360
|
+
});
|
|
1361
|
+
const we = 1.09929682680944, Et = 0.018053968510807;
|
|
1362
|
+
var B0 = new I({
|
|
1363
|
+
id: "rec2020",
|
|
1364
|
+
name: "REC.2020",
|
|
1365
|
+
base: Ie,
|
|
1366
|
+
// Non-linear transfer function from Rec. ITU-R BT.2020-2 table 4
|
|
1367
|
+
toBase(t) {
|
|
1368
|
+
return t.map(function(e) {
|
|
1369
|
+
return e < Et * 4.5 ? e / 4.5 : Math.pow((e + we - 1) / we, 1 / 0.45);
|
|
1370
|
+
});
|
|
1371
|
+
},
|
|
1372
|
+
fromBase(t) {
|
|
1373
|
+
return t.map(function(e) {
|
|
1374
|
+
return e >= Et ? we * Math.pow(e, 0.45) - (we - 1) : 4.5 * e;
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
const Fr = [
|
|
1379
|
+
[0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
|
|
1380
|
+
[0.2289745640697488, 0.6917385218365064, 0.079286914093745],
|
|
1381
|
+
[0, 0.04511338185890264, 1.043944368900976]
|
|
1382
|
+
], Wr = [
|
|
1383
|
+
[2.493496911941425, -0.9313836179191239, -0.40271078445071684],
|
|
1384
|
+
[-0.8294889695615747, 1.7626640603183463, 0.023624685841943577],
|
|
1385
|
+
[0.03584583024378447, -0.07617238926804182, 0.9568845240076872]
|
|
1386
|
+
];
|
|
1387
|
+
var I0 = new I({
|
|
1388
|
+
id: "p3-linear",
|
|
1389
|
+
cssId: "--display-p3-linear",
|
|
1390
|
+
name: "Linear P3",
|
|
1391
|
+
white: "D65",
|
|
1392
|
+
toXYZ_M: Fr,
|
|
1393
|
+
fromXYZ_M: Wr
|
|
1394
|
+
});
|
|
1395
|
+
const Qr = [
|
|
1396
|
+
[0.41239079926595934, 0.357584339383878, 0.1804807884018343],
|
|
1397
|
+
[0.21263900587151027, 0.715168678767756, 0.07219231536073371],
|
|
1398
|
+
[0.01933081871559182, 0.11919477979462598, 0.9505321522496607]
|
|
1399
|
+
], x = [
|
|
1400
|
+
[3.2409699419045226, -1.537383177570094, -0.4986107602930034],
|
|
1401
|
+
[-0.9692436362808796, 1.8759675015077202, 0.04155505740717559],
|
|
1402
|
+
[0.05563007969699366, -0.20397695888897652, 1.0569715142428786]
|
|
1403
|
+
];
|
|
1404
|
+
var z0 = new I({
|
|
1405
|
+
id: "srgb-linear",
|
|
1406
|
+
name: "Linear sRGB",
|
|
1407
|
+
white: "D65",
|
|
1408
|
+
toXYZ_M: Qr,
|
|
1409
|
+
fromXYZ_M: x
|
|
1410
|
+
}), vt = {
|
|
1411
|
+
aliceblue: [240 / 255, 248 / 255, 1],
|
|
1412
|
+
antiquewhite: [250 / 255, 235 / 255, 215 / 255],
|
|
1413
|
+
aqua: [0, 1, 1],
|
|
1414
|
+
aquamarine: [127 / 255, 1, 212 / 255],
|
|
1415
|
+
azure: [240 / 255, 1, 1],
|
|
1416
|
+
beige: [245 / 255, 245 / 255, 220 / 255],
|
|
1417
|
+
bisque: [1, 228 / 255, 196 / 255],
|
|
1418
|
+
black: [0, 0, 0],
|
|
1419
|
+
blanchedalmond: [1, 235 / 255, 205 / 255],
|
|
1420
|
+
blue: [0, 0, 1],
|
|
1421
|
+
blueviolet: [138 / 255, 43 / 255, 226 / 255],
|
|
1422
|
+
brown: [165 / 255, 42 / 255, 42 / 255],
|
|
1423
|
+
burlywood: [222 / 255, 184 / 255, 135 / 255],
|
|
1424
|
+
cadetblue: [95 / 255, 158 / 255, 160 / 255],
|
|
1425
|
+
chartreuse: [127 / 255, 1, 0],
|
|
1426
|
+
chocolate: [210 / 255, 105 / 255, 30 / 255],
|
|
1427
|
+
coral: [1, 127 / 255, 80 / 255],
|
|
1428
|
+
cornflowerblue: [100 / 255, 149 / 255, 237 / 255],
|
|
1429
|
+
cornsilk: [1, 248 / 255, 220 / 255],
|
|
1430
|
+
crimson: [220 / 255, 20 / 255, 60 / 255],
|
|
1431
|
+
cyan: [0, 1, 1],
|
|
1432
|
+
darkblue: [0, 0, 139 / 255],
|
|
1433
|
+
darkcyan: [0, 139 / 255, 139 / 255],
|
|
1434
|
+
darkgoldenrod: [184 / 255, 134 / 255, 11 / 255],
|
|
1435
|
+
darkgray: [169 / 255, 169 / 255, 169 / 255],
|
|
1436
|
+
darkgreen: [0, 100 / 255, 0],
|
|
1437
|
+
darkgrey: [169 / 255, 169 / 255, 169 / 255],
|
|
1438
|
+
darkkhaki: [189 / 255, 183 / 255, 107 / 255],
|
|
1439
|
+
darkmagenta: [139 / 255, 0, 139 / 255],
|
|
1440
|
+
darkolivegreen: [85 / 255, 107 / 255, 47 / 255],
|
|
1441
|
+
darkorange: [1, 140 / 255, 0],
|
|
1442
|
+
darkorchid: [153 / 255, 50 / 255, 204 / 255],
|
|
1443
|
+
darkred: [139 / 255, 0, 0],
|
|
1444
|
+
darksalmon: [233 / 255, 150 / 255, 122 / 255],
|
|
1445
|
+
darkseagreen: [143 / 255, 188 / 255, 143 / 255],
|
|
1446
|
+
darkslateblue: [72 / 255, 61 / 255, 139 / 255],
|
|
1447
|
+
darkslategray: [47 / 255, 79 / 255, 79 / 255],
|
|
1448
|
+
darkslategrey: [47 / 255, 79 / 255, 79 / 255],
|
|
1449
|
+
darkturquoise: [0, 206 / 255, 209 / 255],
|
|
1450
|
+
darkviolet: [148 / 255, 0, 211 / 255],
|
|
1451
|
+
deeppink: [1, 20 / 255, 147 / 255],
|
|
1452
|
+
deepskyblue: [0, 191 / 255, 1],
|
|
1453
|
+
dimgray: [105 / 255, 105 / 255, 105 / 255],
|
|
1454
|
+
dimgrey: [105 / 255, 105 / 255, 105 / 255],
|
|
1455
|
+
dodgerblue: [30 / 255, 144 / 255, 1],
|
|
1456
|
+
firebrick: [178 / 255, 34 / 255, 34 / 255],
|
|
1457
|
+
floralwhite: [1, 250 / 255, 240 / 255],
|
|
1458
|
+
forestgreen: [34 / 255, 139 / 255, 34 / 255],
|
|
1459
|
+
fuchsia: [1, 0, 1],
|
|
1460
|
+
gainsboro: [220 / 255, 220 / 255, 220 / 255],
|
|
1461
|
+
ghostwhite: [248 / 255, 248 / 255, 1],
|
|
1462
|
+
gold: [1, 215 / 255, 0],
|
|
1463
|
+
goldenrod: [218 / 255, 165 / 255, 32 / 255],
|
|
1464
|
+
gray: [128 / 255, 128 / 255, 128 / 255],
|
|
1465
|
+
green: [0, 128 / 255, 0],
|
|
1466
|
+
greenyellow: [173 / 255, 1, 47 / 255],
|
|
1467
|
+
grey: [128 / 255, 128 / 255, 128 / 255],
|
|
1468
|
+
honeydew: [240 / 255, 1, 240 / 255],
|
|
1469
|
+
hotpink: [1, 105 / 255, 180 / 255],
|
|
1470
|
+
indianred: [205 / 255, 92 / 255, 92 / 255],
|
|
1471
|
+
indigo: [75 / 255, 0, 130 / 255],
|
|
1472
|
+
ivory: [1, 1, 240 / 255],
|
|
1473
|
+
khaki: [240 / 255, 230 / 255, 140 / 255],
|
|
1474
|
+
lavender: [230 / 255, 230 / 255, 250 / 255],
|
|
1475
|
+
lavenderblush: [1, 240 / 255, 245 / 255],
|
|
1476
|
+
lawngreen: [124 / 255, 252 / 255, 0],
|
|
1477
|
+
lemonchiffon: [1, 250 / 255, 205 / 255],
|
|
1478
|
+
lightblue: [173 / 255, 216 / 255, 230 / 255],
|
|
1479
|
+
lightcoral: [240 / 255, 128 / 255, 128 / 255],
|
|
1480
|
+
lightcyan: [224 / 255, 1, 1],
|
|
1481
|
+
lightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],
|
|
1482
|
+
lightgray: [211 / 255, 211 / 255, 211 / 255],
|
|
1483
|
+
lightgreen: [144 / 255, 238 / 255, 144 / 255],
|
|
1484
|
+
lightgrey: [211 / 255, 211 / 255, 211 / 255],
|
|
1485
|
+
lightpink: [1, 182 / 255, 193 / 255],
|
|
1486
|
+
lightsalmon: [1, 160 / 255, 122 / 255],
|
|
1487
|
+
lightseagreen: [32 / 255, 178 / 255, 170 / 255],
|
|
1488
|
+
lightskyblue: [135 / 255, 206 / 255, 250 / 255],
|
|
1489
|
+
lightslategray: [119 / 255, 136 / 255, 153 / 255],
|
|
1490
|
+
lightslategrey: [119 / 255, 136 / 255, 153 / 255],
|
|
1491
|
+
lightsteelblue: [176 / 255, 196 / 255, 222 / 255],
|
|
1492
|
+
lightyellow: [1, 1, 224 / 255],
|
|
1493
|
+
lime: [0, 1, 0],
|
|
1494
|
+
limegreen: [50 / 255, 205 / 255, 50 / 255],
|
|
1495
|
+
linen: [250 / 255, 240 / 255, 230 / 255],
|
|
1496
|
+
magenta: [1, 0, 1],
|
|
1497
|
+
maroon: [128 / 255, 0, 0],
|
|
1498
|
+
mediumaquamarine: [102 / 255, 205 / 255, 170 / 255],
|
|
1499
|
+
mediumblue: [0, 0, 205 / 255],
|
|
1500
|
+
mediumorchid: [186 / 255, 85 / 255, 211 / 255],
|
|
1501
|
+
mediumpurple: [147 / 255, 112 / 255, 219 / 255],
|
|
1502
|
+
mediumseagreen: [60 / 255, 179 / 255, 113 / 255],
|
|
1503
|
+
mediumslateblue: [123 / 255, 104 / 255, 238 / 255],
|
|
1504
|
+
mediumspringgreen: [0, 250 / 255, 154 / 255],
|
|
1505
|
+
mediumturquoise: [72 / 255, 209 / 255, 204 / 255],
|
|
1506
|
+
mediumvioletred: [199 / 255, 21 / 255, 133 / 255],
|
|
1507
|
+
midnightblue: [25 / 255, 25 / 255, 112 / 255],
|
|
1508
|
+
mintcream: [245 / 255, 1, 250 / 255],
|
|
1509
|
+
mistyrose: [1, 228 / 255, 225 / 255],
|
|
1510
|
+
moccasin: [1, 228 / 255, 181 / 255],
|
|
1511
|
+
navajowhite: [1, 222 / 255, 173 / 255],
|
|
1512
|
+
navy: [0, 0, 128 / 255],
|
|
1513
|
+
oldlace: [253 / 255, 245 / 255, 230 / 255],
|
|
1514
|
+
olive: [128 / 255, 128 / 255, 0],
|
|
1515
|
+
olivedrab: [107 / 255, 142 / 255, 35 / 255],
|
|
1516
|
+
orange: [1, 165 / 255, 0],
|
|
1517
|
+
orangered: [1, 69 / 255, 0],
|
|
1518
|
+
orchid: [218 / 255, 112 / 255, 214 / 255],
|
|
1519
|
+
palegoldenrod: [238 / 255, 232 / 255, 170 / 255],
|
|
1520
|
+
palegreen: [152 / 255, 251 / 255, 152 / 255],
|
|
1521
|
+
paleturquoise: [175 / 255, 238 / 255, 238 / 255],
|
|
1522
|
+
palevioletred: [219 / 255, 112 / 255, 147 / 255],
|
|
1523
|
+
papayawhip: [1, 239 / 255, 213 / 255],
|
|
1524
|
+
peachpuff: [1, 218 / 255, 185 / 255],
|
|
1525
|
+
peru: [205 / 255, 133 / 255, 63 / 255],
|
|
1526
|
+
pink: [1, 192 / 255, 203 / 255],
|
|
1527
|
+
plum: [221 / 255, 160 / 255, 221 / 255],
|
|
1528
|
+
powderblue: [176 / 255, 224 / 255, 230 / 255],
|
|
1529
|
+
purple: [128 / 255, 0, 128 / 255],
|
|
1530
|
+
rebeccapurple: [102 / 255, 51 / 255, 153 / 255],
|
|
1531
|
+
red: [1, 0, 0],
|
|
1532
|
+
rosybrown: [188 / 255, 143 / 255, 143 / 255],
|
|
1533
|
+
royalblue: [65 / 255, 105 / 255, 225 / 255],
|
|
1534
|
+
saddlebrown: [139 / 255, 69 / 255, 19 / 255],
|
|
1535
|
+
salmon: [250 / 255, 128 / 255, 114 / 255],
|
|
1536
|
+
sandybrown: [244 / 255, 164 / 255, 96 / 255],
|
|
1537
|
+
seagreen: [46 / 255, 139 / 255, 87 / 255],
|
|
1538
|
+
seashell: [1, 245 / 255, 238 / 255],
|
|
1539
|
+
sienna: [160 / 255, 82 / 255, 45 / 255],
|
|
1540
|
+
silver: [192 / 255, 192 / 255, 192 / 255],
|
|
1541
|
+
skyblue: [135 / 255, 206 / 255, 235 / 255],
|
|
1542
|
+
slateblue: [106 / 255, 90 / 255, 205 / 255],
|
|
1543
|
+
slategray: [112 / 255, 128 / 255, 144 / 255],
|
|
1544
|
+
slategrey: [112 / 255, 128 / 255, 144 / 255],
|
|
1545
|
+
snow: [1, 250 / 255, 250 / 255],
|
|
1546
|
+
springgreen: [0, 1, 127 / 255],
|
|
1547
|
+
steelblue: [70 / 255, 130 / 255, 180 / 255],
|
|
1548
|
+
tan: [210 / 255, 180 / 255, 140 / 255],
|
|
1549
|
+
teal: [0, 128 / 255, 128 / 255],
|
|
1550
|
+
thistle: [216 / 255, 191 / 255, 216 / 255],
|
|
1551
|
+
tomato: [1, 99 / 255, 71 / 255],
|
|
1552
|
+
turquoise: [64 / 255, 224 / 255, 208 / 255],
|
|
1553
|
+
violet: [238 / 255, 130 / 255, 238 / 255],
|
|
1554
|
+
wheat: [245 / 255, 222 / 255, 179 / 255],
|
|
1555
|
+
white: [1, 1, 1],
|
|
1556
|
+
whitesmoke: [245 / 255, 245 / 255, 245 / 255],
|
|
1557
|
+
yellow: [1, 1, 0],
|
|
1558
|
+
yellowgreen: [154 / 255, 205 / 255, 50 / 255]
|
|
1559
|
+
};
|
|
1560
|
+
let At = Array(3).fill("<percentage> | <number>[0, 255]"), kt = Array(3).fill("<number>[0, 255]");
|
|
1561
|
+
var ee = new I({
|
|
1562
|
+
id: "srgb",
|
|
1563
|
+
name: "sRGB",
|
|
1564
|
+
base: z0,
|
|
1565
|
+
fromBase: (t) => t.map((e) => {
|
|
1566
|
+
let r = e < 0 ? -1 : 1, n = e * r;
|
|
1567
|
+
return n > 31308e-7 ? r * (1.055 * n ** (1 / 2.4) - 0.055) : 12.92 * e;
|
|
1568
|
+
}),
|
|
1569
|
+
toBase: (t) => t.map((e) => {
|
|
1570
|
+
let r = e < 0 ? -1 : 1, n = e * r;
|
|
1571
|
+
return n <= 0.04045 ? e / 12.92 : r * ((n + 0.055) / 1.055) ** 2.4;
|
|
1572
|
+
}),
|
|
1573
|
+
formats: {
|
|
1574
|
+
rgb: {
|
|
1575
|
+
coords: At
|
|
1576
|
+
},
|
|
1577
|
+
rgb_number: {
|
|
1578
|
+
name: "rgb",
|
|
1579
|
+
commas: !0,
|
|
1580
|
+
coords: kt,
|
|
1581
|
+
noAlpha: !0
|
|
1582
|
+
},
|
|
1583
|
+
color: {
|
|
1584
|
+
/* use defaults */
|
|
1585
|
+
},
|
|
1586
|
+
rgba: {
|
|
1587
|
+
coords: At,
|
|
1588
|
+
commas: !0,
|
|
1589
|
+
lastAlpha: !0
|
|
1590
|
+
},
|
|
1591
|
+
rgba_number: {
|
|
1592
|
+
name: "rgba",
|
|
1593
|
+
commas: !0,
|
|
1594
|
+
coords: kt
|
|
1595
|
+
},
|
|
1596
|
+
hex: {
|
|
1597
|
+
type: "custom",
|
|
1598
|
+
toGamut: !0,
|
|
1599
|
+
test: (t) => /^#([a-f0-9]{3,4}){1,2}$/i.test(t),
|
|
1600
|
+
parse(t) {
|
|
1601
|
+
t.length <= 5 && (t = t.replace(/[a-f0-9]/gi, "$&$&"));
|
|
1602
|
+
let e = [];
|
|
1603
|
+
return t.replace(/[a-f0-9]{2}/gi, (r) => {
|
|
1604
|
+
e.push(parseInt(r, 16) / 255);
|
|
1605
|
+
}), {
|
|
1606
|
+
spaceId: "srgb",
|
|
1607
|
+
coords: e.slice(0, 3),
|
|
1608
|
+
alpha: e.slice(3)[0]
|
|
1609
|
+
};
|
|
1610
|
+
},
|
|
1611
|
+
serialize: (t, e, {
|
|
1612
|
+
collapse: r = !0
|
|
1613
|
+
// collapse to 3-4 digit hex when possible?
|
|
1614
|
+
} = {}) => {
|
|
1615
|
+
e < 1 && t.push(e), t = t.map((s) => Math.round(s * 255));
|
|
1616
|
+
let n = r && t.every((s) => s % 17 === 0);
|
|
1617
|
+
return "#" + t.map((s) => n ? (s / 17).toString(16) : s.toString(16).padStart(2, "0")).join("");
|
|
1618
|
+
}
|
|
1619
|
+
},
|
|
1620
|
+
keyword: {
|
|
1621
|
+
type: "custom",
|
|
1622
|
+
test: (t) => /^[a-z]+$/i.test(t),
|
|
1623
|
+
parse(t) {
|
|
1624
|
+
t = t.toLowerCase();
|
|
1625
|
+
let e = { spaceId: "srgb", coords: null, alpha: 1 };
|
|
1626
|
+
if (t === "transparent" ? (e.coords = vt.black, e.alpha = 0) : e.coords = vt[t], e.coords)
|
|
1627
|
+
return e;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
}), $0 = new I({
|
|
1632
|
+
id: "p3",
|
|
1633
|
+
cssId: "display-p3",
|
|
1634
|
+
name: "P3",
|
|
1635
|
+
base: I0,
|
|
1636
|
+
// Gamma encoding/decoding is the same as sRGB
|
|
1637
|
+
fromBase: ee.fromBase,
|
|
1638
|
+
toBase: ee.toBase
|
|
1639
|
+
});
|
|
1640
|
+
E.display_space = ee;
|
|
1641
|
+
let Ur;
|
|
1642
|
+
if (typeof CSS < "u" && CSS.supports)
|
|
1643
|
+
for (let t of [P, B0, $0]) {
|
|
1644
|
+
let e = t.getMinCoords(), n = se({ space: t, coords: e, alpha: 1 });
|
|
1645
|
+
if (CSS.supports("color", n)) {
|
|
1646
|
+
E.display_space = t;
|
|
1647
|
+
break;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
function Kr(t, { space: e = E.display_space, ...r } = {}) {
|
|
1651
|
+
let n = se(t, r);
|
|
1652
|
+
if (typeof CSS > "u" || CSS.supports("color", n) || !E.display_space)
|
|
1653
|
+
n = new String(n), n.color = t;
|
|
1654
|
+
else {
|
|
1655
|
+
let a = t;
|
|
1656
|
+
if ((t.coords.some(D) || D(t.alpha)) && !(Ur ??= CSS.supports("color", "hsl(none 50% 50%)")) && (a = K(t), a.coords = a.coords.map(S), a.alpha = S(a.alpha), n = se(a, r), CSS.supports("color", n)))
|
|
1657
|
+
return n = new String(n), n.color = a, n;
|
|
1658
|
+
a = y(a, e), n = new String(se(a, r)), n.color = a;
|
|
1659
|
+
}
|
|
1660
|
+
return n;
|
|
1661
|
+
}
|
|
1662
|
+
function Vr(t, e) {
|
|
1663
|
+
return t = g(t), e = g(e), t.space === e.space && t.alpha === e.alpha && t.coords.every((r, n) => r === e.coords[n]);
|
|
1664
|
+
}
|
|
1665
|
+
function q(t) {
|
|
1666
|
+
return $(t, [N, "y"]);
|
|
1667
|
+
}
|
|
1668
|
+
function P0(t, e) {
|
|
1669
|
+
T(t, [N, "y"], e);
|
|
1670
|
+
}
|
|
1671
|
+
function en(t) {
|
|
1672
|
+
Object.defineProperty(t.prototype, "luminance", {
|
|
1673
|
+
get() {
|
|
1674
|
+
return q(this);
|
|
1675
|
+
},
|
|
1676
|
+
set(e) {
|
|
1677
|
+
P0(this, e);
|
|
1678
|
+
}
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
var tn = /* @__PURE__ */ Object.freeze({
|
|
1682
|
+
__proto__: null,
|
|
1683
|
+
getLuminance: q,
|
|
1684
|
+
register: en,
|
|
1685
|
+
setLuminance: P0
|
|
1686
|
+
});
|
|
1687
|
+
function rn(t, e) {
|
|
1688
|
+
t = g(t), e = g(e);
|
|
1689
|
+
let r = Math.max(q(t), 0), n = Math.max(q(e), 0);
|
|
1690
|
+
return n > r && ([r, n] = [n, r]), (r + 0.05) / (n + 0.05);
|
|
1691
|
+
}
|
|
1692
|
+
const nn = 0.56, an = 0.57, sn = 0.62, on = 0.65, Ht = 0.022, ln = 1.414, cn = 0.1, un = 5e-4, fn = 1.14, Tt = 0.027, hn = 1.14;
|
|
1693
|
+
function Ot(t) {
|
|
1694
|
+
return t >= Ht ? t : t + (Ht - t) ** ln;
|
|
1695
|
+
}
|
|
1696
|
+
function F(t) {
|
|
1697
|
+
let e = t < 0 ? -1 : 1, r = Math.abs(t);
|
|
1698
|
+
return e * Math.pow(r, 2.4);
|
|
1699
|
+
}
|
|
1700
|
+
function dn(t, e) {
|
|
1701
|
+
e = g(e), t = g(t);
|
|
1702
|
+
let r, n, a, s, i, o;
|
|
1703
|
+
e = y(e, "srgb"), [s, i, o] = e.coords;
|
|
1704
|
+
let l = F(s) * 0.2126729 + F(i) * 0.7151522 + F(o) * 0.072175;
|
|
1705
|
+
t = y(t, "srgb"), [s, i, o] = t.coords;
|
|
1706
|
+
let f = F(s) * 0.2126729 + F(i) * 0.7151522 + F(o) * 0.072175, u = Ot(l), c = Ot(f), h = c > u;
|
|
1707
|
+
return Math.abs(c - u) < un ? n = 0 : h ? (r = c ** nn - u ** an, n = r * fn) : (r = c ** on - u ** sn, n = r * hn), Math.abs(n) < cn ? a = 0 : n > 0 ? a = n - Tt : a = n + Tt, a * 100;
|
|
1708
|
+
}
|
|
1709
|
+
function mn(t, e) {
|
|
1710
|
+
t = g(t), e = g(e);
|
|
1711
|
+
let r = Math.max(q(t), 0), n = Math.max(q(e), 0);
|
|
1712
|
+
n > r && ([r, n] = [n, r]);
|
|
1713
|
+
let a = r + n;
|
|
1714
|
+
return a === 0 ? 0 : (r - n) / a;
|
|
1715
|
+
}
|
|
1716
|
+
const gn = 5e4;
|
|
1717
|
+
function pn(t, e) {
|
|
1718
|
+
t = g(t), e = g(e);
|
|
1719
|
+
let r = Math.max(q(t), 0), n = Math.max(q(e), 0);
|
|
1720
|
+
return n > r && ([r, n] = [n, r]), n === 0 ? gn : (r - n) / n;
|
|
1721
|
+
}
|
|
1722
|
+
function bn(t, e) {
|
|
1723
|
+
t = g(t), e = g(e);
|
|
1724
|
+
let r = $(t, [P, "l"]), n = $(e, [P, "l"]);
|
|
1725
|
+
return Math.abs(r - n);
|
|
1726
|
+
}
|
|
1727
|
+
const Mn = 216 / 24389, Yt = 24 / 116, ye = 24389 / 27;
|
|
1728
|
+
let ke = B.D65;
|
|
1729
|
+
var We = new d({
|
|
1730
|
+
id: "lab-d65",
|
|
1731
|
+
name: "Lab D65",
|
|
1732
|
+
coords: {
|
|
1733
|
+
l: {
|
|
1734
|
+
refRange: [0, 100],
|
|
1735
|
+
name: "Lightness"
|
|
1736
|
+
},
|
|
1737
|
+
a: {
|
|
1738
|
+
refRange: [-125, 125]
|
|
1739
|
+
},
|
|
1740
|
+
b: {
|
|
1741
|
+
refRange: [-125, 125]
|
|
1742
|
+
}
|
|
1743
|
+
},
|
|
1744
|
+
// Assuming XYZ is relative to D65, convert to CIE Lab
|
|
1745
|
+
// from CIE standard, which now defines these as a rational fraction
|
|
1746
|
+
white: ke,
|
|
1747
|
+
base: N,
|
|
1748
|
+
// Convert D65-adapted XYZ to Lab
|
|
1749
|
+
// CIE 15.3:2004 section 8.2.1.1
|
|
1750
|
+
fromBase(t) {
|
|
1751
|
+
let r = t.map((n, a) => n / ke[a]).map((n) => n > Mn ? Math.cbrt(n) : (ye * n + 16) / 116);
|
|
1752
|
+
return [
|
|
1753
|
+
116 * r[1] - 16,
|
|
1754
|
+
// L
|
|
1755
|
+
500 * (r[0] - r[1]),
|
|
1756
|
+
// a
|
|
1757
|
+
200 * (r[1] - r[2])
|
|
1758
|
+
// b
|
|
1759
|
+
];
|
|
1760
|
+
},
|
|
1761
|
+
// Convert Lab to D65-adapted XYZ
|
|
1762
|
+
// Same result as CIE 15.3:2004 Appendix D although the derivation is different
|
|
1763
|
+
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
1764
|
+
toBase(t) {
|
|
1765
|
+
let e = [];
|
|
1766
|
+
return e[1] = (t[0] + 16) / 116, e[0] = t[1] / 500 + e[1], e[2] = e[1] - t[2] / 200, [
|
|
1767
|
+
e[0] > Yt ? Math.pow(e[0], 3) : (116 * e[0] - 16) / ye,
|
|
1768
|
+
t[0] > 8 ? Math.pow((t[0] + 16) / 116, 3) : t[0] / ye,
|
|
1769
|
+
e[2] > Yt ? Math.pow(e[2], 3) : (116 * e[2] - 16) / ye
|
|
1770
|
+
].map((n, a) => n * ke[a]);
|
|
1771
|
+
},
|
|
1772
|
+
formats: {
|
|
1773
|
+
"lab-d65": {
|
|
1774
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
const He = Math.pow(5, 0.5) * 0.5 + 0.5;
|
|
1779
|
+
function wn(t, e) {
|
|
1780
|
+
t = g(t), e = g(e);
|
|
1781
|
+
let r = $(t, [We, "l"]), n = $(e, [We, "l"]), a = Math.abs(Math.pow(r, He) - Math.pow(n, He)), s = Math.pow(a, 1 / He) * Math.SQRT2 - 40;
|
|
1782
|
+
return s < 7.5 ? 0 : s;
|
|
1783
|
+
}
|
|
1784
|
+
var _e = /* @__PURE__ */ Object.freeze({
|
|
1785
|
+
__proto__: null,
|
|
1786
|
+
contrastAPCA: dn,
|
|
1787
|
+
contrastDeltaPhi: wn,
|
|
1788
|
+
contrastLstar: bn,
|
|
1789
|
+
contrastMichelson: mn,
|
|
1790
|
+
contrastWCAG21: rn,
|
|
1791
|
+
contrastWeber: pn
|
|
1792
|
+
});
|
|
1793
|
+
function yn(t, e, r = {}) {
|
|
1794
|
+
ce(r) && (r = { algorithm: r });
|
|
1795
|
+
let { algorithm: n, ...a } = r;
|
|
1796
|
+
if (!n) {
|
|
1797
|
+
let s = Object.keys(_e).map((i) => i.replace(/^contrast/, "")).join(", ");
|
|
1798
|
+
throw new TypeError(`contrast() function needs a contrast algorithm. Please specify one of: ${s}`);
|
|
1799
|
+
}
|
|
1800
|
+
t = g(t), e = g(e);
|
|
1801
|
+
for (let s in _e)
|
|
1802
|
+
if ("contrast" + n.toLowerCase() === s.toLowerCase())
|
|
1803
|
+
return _e[s](t, e, a);
|
|
1804
|
+
throw new TypeError(`Unknown contrast algorithm: ${n}`);
|
|
1805
|
+
}
|
|
1806
|
+
function ze(t) {
|
|
1807
|
+
let [e, r, n] = ue(t, N), a = e + 15 * r + 3 * n;
|
|
1808
|
+
return [4 * e / a, 9 * r / a];
|
|
1809
|
+
}
|
|
1810
|
+
function E0(t) {
|
|
1811
|
+
let [e, r, n] = ue(t, N), a = e + r + n;
|
|
1812
|
+
return [e / a, r / a];
|
|
1813
|
+
}
|
|
1814
|
+
function Cn(t) {
|
|
1815
|
+
Object.defineProperty(t.prototype, "uv", {
|
|
1816
|
+
get() {
|
|
1817
|
+
return ze(this);
|
|
1818
|
+
}
|
|
1819
|
+
}), Object.defineProperty(t.prototype, "xy", {
|
|
1820
|
+
get() {
|
|
1821
|
+
return E0(this);
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
var Ln = /* @__PURE__ */ Object.freeze({
|
|
1826
|
+
__proto__: null,
|
|
1827
|
+
register: Cn,
|
|
1828
|
+
uv: ze,
|
|
1829
|
+
xy: E0
|
|
1830
|
+
});
|
|
1831
|
+
function ae(t, e, r = {}) {
|
|
1832
|
+
ce(r) && (r = { method: r });
|
|
1833
|
+
let { method: n = E.deltaE, ...a } = r;
|
|
1834
|
+
for (let s in V)
|
|
1835
|
+
if ("deltae" + n.toLowerCase() === s.toLowerCase())
|
|
1836
|
+
return V[s](t, e, a);
|
|
1837
|
+
throw new TypeError(`Unknown deltaE method: ${n}`);
|
|
1838
|
+
}
|
|
1839
|
+
function _n(t, e = 0.25) {
|
|
1840
|
+
let n = [d.get("oklch", "lch"), "l"];
|
|
1841
|
+
return T(t, n, (a) => a * (1 + e));
|
|
1842
|
+
}
|
|
1843
|
+
function Sn(t, e = 0.25) {
|
|
1844
|
+
let n = [d.get("oklch", "lch"), "l"];
|
|
1845
|
+
return T(t, n, (a) => a * (1 - e));
|
|
1846
|
+
}
|
|
1847
|
+
var Rn = /* @__PURE__ */ Object.freeze({
|
|
1848
|
+
__proto__: null,
|
|
1849
|
+
darken: Sn,
|
|
1850
|
+
lighten: _n
|
|
1851
|
+
});
|
|
1852
|
+
function v0(t, e, r = 0.5, n = {}) {
|
|
1853
|
+
return [t, e] = [g(t), g(e)], Y(r) === "object" && ([r, n] = [0.5, r]), fe(t, e, n)(r);
|
|
1854
|
+
}
|
|
1855
|
+
function A0(t, e, r = {}) {
|
|
1856
|
+
let n;
|
|
1857
|
+
nt(t) && ([n, r] = [t, e], [t, e] = n.rangeArgs.colors);
|
|
1858
|
+
let {
|
|
1859
|
+
maxDeltaE: a,
|
|
1860
|
+
deltaEMethod: s,
|
|
1861
|
+
steps: i = 2,
|
|
1862
|
+
maxSteps: o = 1e3,
|
|
1863
|
+
...l
|
|
1864
|
+
} = r;
|
|
1865
|
+
n || ([t, e] = [g(t), g(e)], n = fe(t, e, l));
|
|
1866
|
+
let f = ae(t, e), u = a > 0 ? Math.max(i, Math.ceil(f / a) + 1) : i, c = [];
|
|
1867
|
+
if (o !== void 0 && (u = Math.min(u, o)), u === 1)
|
|
1868
|
+
c = [{ p: 0.5, color: n(0.5) }];
|
|
1869
|
+
else {
|
|
1870
|
+
let h = 1 / (u - 1);
|
|
1871
|
+
c = Array.from({ length: u }, (p, m) => {
|
|
1872
|
+
let b = m * h;
|
|
1873
|
+
return { p: b, color: n(b) };
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1876
|
+
if (a > 0) {
|
|
1877
|
+
let h = c.reduce((p, m, b) => {
|
|
1878
|
+
if (b === 0)
|
|
1879
|
+
return 0;
|
|
1880
|
+
let M = ae(m.color, c[b - 1].color, s);
|
|
1881
|
+
return Math.max(p, M);
|
|
1882
|
+
}, 0);
|
|
1883
|
+
for (; h > a; ) {
|
|
1884
|
+
h = 0;
|
|
1885
|
+
for (let p = 1; p < c.length && c.length < o; p++) {
|
|
1886
|
+
let m = c[p - 1], b = c[p], M = (b.p + m.p) / 2, R = n(M);
|
|
1887
|
+
h = Math.max(h, ae(R, m.color), ae(R, b.color)), c.splice(p, 0, { p: M, color: n(M) }), p++;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
return c = c.map((h) => h.color), c;
|
|
1892
|
+
}
|
|
1893
|
+
function fe(t, e, r = {}) {
|
|
1894
|
+
if (nt(t)) {
|
|
1895
|
+
let [l, f] = [t, e];
|
|
1896
|
+
return fe(...l.rangeArgs.colors, { ...l.rangeArgs.options, ...f });
|
|
1897
|
+
}
|
|
1898
|
+
let { space: n, outputSpace: a, progression: s, premultiplied: i } = r;
|
|
1899
|
+
t = g(t), e = g(e), t = K(t), e = K(e);
|
|
1900
|
+
let o = { colors: [t, e], options: r };
|
|
1901
|
+
if (n ? n = d.get(n) : n = d.registry[E.interpolationSpace] || t.space, a = a ? d.get(a) : n, t = y(t, n), e = y(e, n), t = j(t), e = j(e), n.coords.h && n.coords.h.type === "angle") {
|
|
1902
|
+
let l = r.hue = r.hue || "shorter", f = [n, "h"], [u, c] = [$(t, f), $(e, f)];
|
|
1903
|
+
isNaN(u) && !isNaN(c) ? u = c : isNaN(c) && !isNaN(u) && (c = u), [u, c] = nr(l, [u, c]), T(t, f, u), T(e, f, c);
|
|
1904
|
+
}
|
|
1905
|
+
return i && (t.coords = t.coords.map((l) => l * t.alpha), e.coords = e.coords.map((l) => l * e.alpha)), Object.assign((l) => {
|
|
1906
|
+
l = s ? s(l) : l;
|
|
1907
|
+
let f = t.coords.map((h, p) => {
|
|
1908
|
+
let m = e.coords[p];
|
|
1909
|
+
return ie(h, m, l);
|
|
1910
|
+
}), u = ie(t.alpha, e.alpha, l), c = { space: n, coords: f, alpha: u };
|
|
1911
|
+
return i && (c.coords = c.coords.map((h) => h / u)), a !== n && (c = y(c, a)), c;
|
|
1912
|
+
}, {
|
|
1913
|
+
rangeArgs: o
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
function nt(t) {
|
|
1917
|
+
return Y(t) === "function" && !!t.rangeArgs;
|
|
1918
|
+
}
|
|
1919
|
+
E.interpolationSpace = "lab";
|
|
1920
|
+
function xn(t) {
|
|
1921
|
+
t.defineFunction("mix", v0, { returns: "color" }), t.defineFunction("range", fe, { returns: "function<color>" }), t.defineFunction("steps", A0, { returns: "array<color>" });
|
|
1922
|
+
}
|
|
1923
|
+
var Nn = /* @__PURE__ */ Object.freeze({
|
|
1924
|
+
__proto__: null,
|
|
1925
|
+
isRange: nt,
|
|
1926
|
+
mix: v0,
|
|
1927
|
+
range: fe,
|
|
1928
|
+
register: xn,
|
|
1929
|
+
steps: A0
|
|
1930
|
+
}), k0 = new d({
|
|
1931
|
+
id: "hsl",
|
|
1932
|
+
name: "HSL",
|
|
1933
|
+
coords: {
|
|
1934
|
+
h: {
|
|
1935
|
+
refRange: [0, 360],
|
|
1936
|
+
type: "angle",
|
|
1937
|
+
name: "Hue"
|
|
1938
|
+
},
|
|
1939
|
+
s: {
|
|
1940
|
+
range: [0, 100],
|
|
1941
|
+
name: "Saturation"
|
|
1942
|
+
},
|
|
1943
|
+
l: {
|
|
1944
|
+
range: [0, 100],
|
|
1945
|
+
name: "Lightness"
|
|
1946
|
+
}
|
|
1947
|
+
},
|
|
1948
|
+
base: ee,
|
|
1949
|
+
// Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js
|
|
1950
|
+
fromBase: (t) => {
|
|
1951
|
+
let e = Math.max(...t), r = Math.min(...t), [n, a, s] = t, [i, o, l] = [NaN, 0, (r + e) / 2], f = e - r;
|
|
1952
|
+
if (f !== 0) {
|
|
1953
|
+
switch (o = l === 0 || l === 1 ? 0 : (e - l) / Math.min(l, 1 - l), e) {
|
|
1954
|
+
case n:
|
|
1955
|
+
i = (a - s) / f + (a < s ? 6 : 0);
|
|
1956
|
+
break;
|
|
1957
|
+
case a:
|
|
1958
|
+
i = (s - n) / f + 2;
|
|
1959
|
+
break;
|
|
1960
|
+
case s:
|
|
1961
|
+
i = (n - a) / f + 4;
|
|
1962
|
+
}
|
|
1963
|
+
i = i * 60;
|
|
1964
|
+
}
|
|
1965
|
+
return o < 0 && (i += 180, o = Math.abs(o)), i >= 360 && (i -= 360), [i, o * 100, l * 100];
|
|
1966
|
+
},
|
|
1967
|
+
// Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative
|
|
1968
|
+
toBase: (t) => {
|
|
1969
|
+
let [e, r, n] = t;
|
|
1970
|
+
e = e % 360, e < 0 && (e += 360), r /= 100, n /= 100;
|
|
1971
|
+
function a(s) {
|
|
1972
|
+
let i = (s + e / 30) % 12, o = r * Math.min(n, 1 - n);
|
|
1973
|
+
return n - o * Math.max(-1, Math.min(i - 3, 9 - i, 1));
|
|
1974
|
+
}
|
|
1975
|
+
return [a(0), a(8), a(4)];
|
|
1976
|
+
},
|
|
1977
|
+
formats: {
|
|
1978
|
+
hsl: {
|
|
1979
|
+
coords: ["<number> | <angle>", "<percentage>", "<percentage>"]
|
|
1980
|
+
},
|
|
1981
|
+
hsla: {
|
|
1982
|
+
coords: ["<number> | <angle>", "<percentage>", "<percentage>"],
|
|
1983
|
+
commas: !0,
|
|
1984
|
+
lastAlpha: !0
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
}), H0 = new d({
|
|
1988
|
+
id: "hsv",
|
|
1989
|
+
name: "HSV",
|
|
1990
|
+
coords: {
|
|
1991
|
+
h: {
|
|
1992
|
+
refRange: [0, 360],
|
|
1993
|
+
type: "angle",
|
|
1994
|
+
name: "Hue"
|
|
1995
|
+
},
|
|
1996
|
+
s: {
|
|
1997
|
+
range: [0, 100],
|
|
1998
|
+
name: "Saturation"
|
|
1999
|
+
},
|
|
2000
|
+
v: {
|
|
2001
|
+
range: [0, 100],
|
|
2002
|
+
name: "Value"
|
|
2003
|
+
}
|
|
2004
|
+
},
|
|
2005
|
+
base: k0,
|
|
2006
|
+
// https://en.wikipedia.org/wiki/HSL_and_HSV#Interconversion
|
|
2007
|
+
fromBase(t) {
|
|
2008
|
+
let [e, r, n] = t;
|
|
2009
|
+
r /= 100, n /= 100;
|
|
2010
|
+
let a = n + r * Math.min(n, 1 - n);
|
|
2011
|
+
return [
|
|
2012
|
+
e,
|
|
2013
|
+
// h is the same
|
|
2014
|
+
a === 0 ? 0 : 200 * (1 - n / a),
|
|
2015
|
+
// s
|
|
2016
|
+
100 * a
|
|
2017
|
+
];
|
|
2018
|
+
},
|
|
2019
|
+
// https://en.wikipedia.org/wiki/HSL_and_HSV#Interconversion
|
|
2020
|
+
toBase(t) {
|
|
2021
|
+
let [e, r, n] = t;
|
|
2022
|
+
r /= 100, n /= 100;
|
|
2023
|
+
let a = n * (1 - r / 2);
|
|
2024
|
+
return [
|
|
2025
|
+
e,
|
|
2026
|
+
// h is the same
|
|
2027
|
+
a === 0 || a === 1 ? 0 : (n - a) / Math.min(a, 1 - a) * 100,
|
|
2028
|
+
a * 100
|
|
2029
|
+
];
|
|
2030
|
+
},
|
|
2031
|
+
formats: {
|
|
2032
|
+
color: {
|
|
2033
|
+
id: "--hsv",
|
|
2034
|
+
coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
}), Bn = new d({
|
|
2038
|
+
id: "hwb",
|
|
2039
|
+
name: "HWB",
|
|
2040
|
+
coords: {
|
|
2041
|
+
h: {
|
|
2042
|
+
refRange: [0, 360],
|
|
2043
|
+
type: "angle",
|
|
2044
|
+
name: "Hue"
|
|
2045
|
+
},
|
|
2046
|
+
w: {
|
|
2047
|
+
range: [0, 100],
|
|
2048
|
+
name: "Whiteness"
|
|
2049
|
+
},
|
|
2050
|
+
b: {
|
|
2051
|
+
range: [0, 100],
|
|
2052
|
+
name: "Blackness"
|
|
2053
|
+
}
|
|
2054
|
+
},
|
|
2055
|
+
base: H0,
|
|
2056
|
+
fromBase(t) {
|
|
2057
|
+
let [e, r, n] = t;
|
|
2058
|
+
return [e, n * (100 - r) / 100, 100 - n];
|
|
2059
|
+
},
|
|
2060
|
+
toBase(t) {
|
|
2061
|
+
let [e, r, n] = t;
|
|
2062
|
+
r /= 100, n /= 100;
|
|
2063
|
+
let a = r + n;
|
|
2064
|
+
if (a >= 1) {
|
|
2065
|
+
let o = r / a;
|
|
2066
|
+
return [e, 0, o * 100];
|
|
2067
|
+
}
|
|
2068
|
+
let s = 1 - n, i = s === 0 ? 0 : 1 - r / s;
|
|
2069
|
+
return [e, i * 100, s * 100];
|
|
2070
|
+
},
|
|
2071
|
+
formats: {
|
|
2072
|
+
hwb: {
|
|
2073
|
+
coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
const In = [
|
|
2078
|
+
[0.5766690429101305, 0.1855582379065463, 0.1882286462349947],
|
|
2079
|
+
[0.29734497525053605, 0.6273635662554661, 0.07529145849399788],
|
|
2080
|
+
[0.02703136138641234, 0.07068885253582723, 0.9913375368376388]
|
|
2081
|
+
], zn = [
|
|
2082
|
+
[2.0415879038107465, -0.5650069742788596, -0.34473135077832956],
|
|
2083
|
+
[-0.9692436362808795, 1.8759675015077202, 0.04155505740717557],
|
|
2084
|
+
[0.013444280632031142, -0.11836239223101838, 1.0151749943912054]
|
|
2085
|
+
];
|
|
2086
|
+
var T0 = new I({
|
|
2087
|
+
id: "a98rgb-linear",
|
|
2088
|
+
cssId: "--a98-rgb-linear",
|
|
2089
|
+
name: "Linear Adobe® 98 RGB compatible",
|
|
2090
|
+
white: "D65",
|
|
2091
|
+
toXYZ_M: In,
|
|
2092
|
+
fromXYZ_M: zn
|
|
2093
|
+
}), $n = new I({
|
|
2094
|
+
id: "a98rgb",
|
|
2095
|
+
cssId: "a98-rgb",
|
|
2096
|
+
name: "Adobe® 98 RGB compatible",
|
|
2097
|
+
base: T0,
|
|
2098
|
+
toBase: (t) => t.map((e) => Math.pow(Math.abs(e), 563 / 256) * Math.sign(e)),
|
|
2099
|
+
fromBase: (t) => t.map((e) => Math.pow(Math.abs(e), 256 / 563) * Math.sign(e))
|
|
2100
|
+
});
|
|
2101
|
+
const Pn = [
|
|
2102
|
+
[0.7977666449006423, 0.13518129740053308, 0.0313477341283922],
|
|
2103
|
+
[0.2880748288194013, 0.711835234241873, 8993693872564e-17],
|
|
2104
|
+
[0, 0, 0.8251046025104602]
|
|
2105
|
+
], En = [
|
|
2106
|
+
[1.3457868816471583, -0.25557208737979464, -0.05110186497554526],
|
|
2107
|
+
[-0.5446307051249019, 1.5082477428451468, 0.02052744743642139],
|
|
2108
|
+
[0, 0, 1.2119675456389452]
|
|
2109
|
+
];
|
|
2110
|
+
var O0 = new I({
|
|
2111
|
+
id: "prophoto-linear",
|
|
2112
|
+
cssId: "--prophoto-rgb-linear",
|
|
2113
|
+
name: "Linear ProPhoto",
|
|
2114
|
+
white: "D50",
|
|
2115
|
+
base: et,
|
|
2116
|
+
toXYZ_M: Pn,
|
|
2117
|
+
fromXYZ_M: En
|
|
2118
|
+
});
|
|
2119
|
+
const vn = 1 / 512, An = 16 / 512;
|
|
2120
|
+
var kn = new I({
|
|
2121
|
+
id: "prophoto",
|
|
2122
|
+
cssId: "prophoto-rgb",
|
|
2123
|
+
name: "ProPhoto",
|
|
2124
|
+
base: O0,
|
|
2125
|
+
toBase(t) {
|
|
2126
|
+
return t.map((e) => e < An ? e / 16 : e ** 1.8);
|
|
2127
|
+
},
|
|
2128
|
+
fromBase(t) {
|
|
2129
|
+
return t.map((e) => e >= vn ? e ** (1 / 1.8) : 16 * e);
|
|
2130
|
+
}
|
|
2131
|
+
}), Hn = new d({
|
|
2132
|
+
id: "oklch",
|
|
2133
|
+
name: "Oklch",
|
|
2134
|
+
coords: {
|
|
2135
|
+
l: {
|
|
2136
|
+
refRange: [0, 1],
|
|
2137
|
+
name: "Lightness"
|
|
2138
|
+
},
|
|
2139
|
+
c: {
|
|
2140
|
+
refRange: [0, 0.4],
|
|
2141
|
+
name: "Chroma"
|
|
2142
|
+
},
|
|
2143
|
+
h: {
|
|
2144
|
+
refRange: [0, 360],
|
|
2145
|
+
type: "angle",
|
|
2146
|
+
name: "Hue"
|
|
2147
|
+
}
|
|
2148
|
+
},
|
|
2149
|
+
white: "D65",
|
|
2150
|
+
base: U,
|
|
2151
|
+
fromBase(t) {
|
|
2152
|
+
let [e, r, n] = t, a;
|
|
2153
|
+
const s = 2e-4;
|
|
2154
|
+
return Math.abs(r) < s && Math.abs(n) < s ? a = NaN : a = Math.atan2(n, r) * 180 / Math.PI, [
|
|
2155
|
+
e,
|
|
2156
|
+
// OKLab L is still L
|
|
2157
|
+
Math.sqrt(r ** 2 + n ** 2),
|
|
2158
|
+
// Chroma
|
|
2159
|
+
k(a)
|
|
2160
|
+
// Hue, in degrees [0 to 360)
|
|
2161
|
+
];
|
|
2162
|
+
},
|
|
2163
|
+
// Convert from polar form
|
|
2164
|
+
toBase(t) {
|
|
2165
|
+
let [e, r, n] = t, a, s;
|
|
2166
|
+
return isNaN(n) ? (a = 0, s = 0) : (a = r * Math.cos(n * Math.PI / 180), s = r * Math.sin(n * Math.PI / 180)), [e, a, s];
|
|
2167
|
+
},
|
|
2168
|
+
formats: {
|
|
2169
|
+
oklch: {
|
|
2170
|
+
coords: ["<percentage> | <number>", "<number> | <percentage>[0,1]", "<number> | <angle>"]
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
let Y0 = B.D65;
|
|
2175
|
+
const Tn = 216 / 24389, Dt = 24389 / 27, [Xt, jt] = ze({ space: N, coords: Y0 });
|
|
2176
|
+
var D0 = new d({
|
|
2177
|
+
id: "luv",
|
|
2178
|
+
name: "Luv",
|
|
2179
|
+
coords: {
|
|
2180
|
+
l: {
|
|
2181
|
+
refRange: [0, 100],
|
|
2182
|
+
name: "Lightness"
|
|
2183
|
+
},
|
|
2184
|
+
// Reference ranges from https://facelessuser.github.io/coloraide/colors/luv/
|
|
2185
|
+
u: {
|
|
2186
|
+
refRange: [-215, 215]
|
|
2187
|
+
},
|
|
2188
|
+
v: {
|
|
2189
|
+
refRange: [-215, 215]
|
|
2190
|
+
}
|
|
2191
|
+
},
|
|
2192
|
+
white: Y0,
|
|
2193
|
+
base: N,
|
|
2194
|
+
// Convert D65-adapted XYZ to Luv
|
|
2195
|
+
// https://en.wikipedia.org/wiki/CIELUV#The_forward_transformation
|
|
2196
|
+
fromBase(t) {
|
|
2197
|
+
let e = [S(t[0]), S(t[1]), S(t[2])], r = e[1], [n, a] = ze({ space: N, coords: e });
|
|
2198
|
+
if (!Number.isFinite(n) || !Number.isFinite(a))
|
|
2199
|
+
return [0, 0, 0];
|
|
2200
|
+
let s = r <= Tn ? Dt * r : 116 * Math.cbrt(r) - 16;
|
|
2201
|
+
return [
|
|
2202
|
+
s,
|
|
2203
|
+
13 * s * (n - Xt),
|
|
2204
|
+
13 * s * (a - jt)
|
|
2205
|
+
];
|
|
2206
|
+
},
|
|
2207
|
+
// Convert Luv to D65-adapted XYZ
|
|
2208
|
+
// https://en.wikipedia.org/wiki/CIELUV#The_reverse_transformation
|
|
2209
|
+
toBase(t) {
|
|
2210
|
+
let [e, r, n] = t;
|
|
2211
|
+
if (e === 0 || D(e))
|
|
2212
|
+
return [0, 0, 0];
|
|
2213
|
+
r = S(r), n = S(n);
|
|
2214
|
+
let a = r / (13 * e) + Xt, s = n / (13 * e) + jt, i = e <= 8 ? e / Dt : Math.pow((e + 16) / 116, 3);
|
|
2215
|
+
return [
|
|
2216
|
+
i * (9 * a / (4 * s)),
|
|
2217
|
+
i,
|
|
2218
|
+
i * ((12 - 3 * a - 20 * s) / (4 * s))
|
|
2219
|
+
];
|
|
2220
|
+
},
|
|
2221
|
+
formats: {
|
|
2222
|
+
color: {
|
|
2223
|
+
id: "--luv",
|
|
2224
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>[-1,1]", "<number> | <percentage>[-1,1]"]
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}), at = new d({
|
|
2228
|
+
id: "lchuv",
|
|
2229
|
+
name: "LChuv",
|
|
2230
|
+
coords: {
|
|
2231
|
+
l: {
|
|
2232
|
+
refRange: [0, 100],
|
|
2233
|
+
name: "Lightness"
|
|
2234
|
+
},
|
|
2235
|
+
c: {
|
|
2236
|
+
refRange: [0, 220],
|
|
2237
|
+
name: "Chroma"
|
|
2238
|
+
},
|
|
2239
|
+
h: {
|
|
2240
|
+
refRange: [0, 360],
|
|
2241
|
+
type: "angle",
|
|
2242
|
+
name: "Hue"
|
|
2243
|
+
}
|
|
2244
|
+
},
|
|
2245
|
+
base: D0,
|
|
2246
|
+
fromBase(t) {
|
|
2247
|
+
let [e, r, n] = t, a;
|
|
2248
|
+
const s = 0.02;
|
|
2249
|
+
return Math.abs(r) < s && Math.abs(n) < s ? a = NaN : a = Math.atan2(n, r) * 180 / Math.PI, [
|
|
2250
|
+
e,
|
|
2251
|
+
// L is still L
|
|
2252
|
+
Math.sqrt(r ** 2 + n ** 2),
|
|
2253
|
+
// Chroma
|
|
2254
|
+
k(a)
|
|
2255
|
+
// Hue, in degrees [0 to 360)
|
|
2256
|
+
];
|
|
2257
|
+
},
|
|
2258
|
+
toBase(t) {
|
|
2259
|
+
let [e, r, n] = t;
|
|
2260
|
+
return r < 0 && (r = 0), isNaN(n) && (n = 0), [
|
|
2261
|
+
e,
|
|
2262
|
+
// L is still L
|
|
2263
|
+
r * Math.cos(n * Math.PI / 180),
|
|
2264
|
+
// u
|
|
2265
|
+
r * Math.sin(n * Math.PI / 180)
|
|
2266
|
+
// v
|
|
2267
|
+
];
|
|
2268
|
+
},
|
|
2269
|
+
formats: {
|
|
2270
|
+
color: {
|
|
2271
|
+
id: "--lchuv",
|
|
2272
|
+
coords: ["<number> | <percentage>", "<number> | <percentage>", "<number> | <angle>"]
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
const On = 216 / 24389, Yn = 24389 / 27, qt = x[0][0], Zt = x[0][1], Te = x[0][2], Gt = x[1][0], Jt = x[1][1], Oe = x[1][2], Ft = x[2][0], Wt = x[2][1], Ye = x[2][2];
|
|
2277
|
+
function W(t, e, r) {
|
|
2278
|
+
const n = e / (Math.sin(r) - t * Math.cos(r));
|
|
2279
|
+
return n < 0 ? 1 / 0 : n;
|
|
2280
|
+
}
|
|
2281
|
+
function Ne(t) {
|
|
2282
|
+
const e = Math.pow(t + 16, 3) / 1560896, r = e > On ? e : t / Yn, n = r * (284517 * qt - 94839 * Te), a = r * (838422 * Te + 769860 * Zt + 731718 * qt), s = r * (632260 * Te - 126452 * Zt), i = r * (284517 * Gt - 94839 * Oe), o = r * (838422 * Oe + 769860 * Jt + 731718 * Gt), l = r * (632260 * Oe - 126452 * Jt), f = r * (284517 * Ft - 94839 * Ye), u = r * (838422 * Ye + 769860 * Wt + 731718 * Ft), c = r * (632260 * Ye - 126452 * Wt);
|
|
2283
|
+
return {
|
|
2284
|
+
r0s: n / s,
|
|
2285
|
+
r0i: a * t / s,
|
|
2286
|
+
r1s: n / (s + 126452),
|
|
2287
|
+
r1i: (a - 769860) * t / (s + 126452),
|
|
2288
|
+
g0s: i / l,
|
|
2289
|
+
g0i: o * t / l,
|
|
2290
|
+
g1s: i / (l + 126452),
|
|
2291
|
+
g1i: (o - 769860) * t / (l + 126452),
|
|
2292
|
+
b0s: f / c,
|
|
2293
|
+
b0i: u * t / c,
|
|
2294
|
+
b1s: f / (c + 126452),
|
|
2295
|
+
b1i: (u - 769860) * t / (c + 126452)
|
|
2296
|
+
};
|
|
2297
|
+
}
|
|
2298
|
+
function Qt(t, e) {
|
|
2299
|
+
const r = e / 360 * Math.PI * 2, n = W(t.r0s, t.r0i, r), a = W(t.r1s, t.r1i, r), s = W(t.g0s, t.g0i, r), i = W(t.g1s, t.g1i, r), o = W(t.b0s, t.b0i, r), l = W(t.b1s, t.b1i, r);
|
|
2300
|
+
return Math.min(n, a, s, i, o, l);
|
|
2301
|
+
}
|
|
2302
|
+
var Dn = new d({
|
|
2303
|
+
id: "hsluv",
|
|
2304
|
+
name: "HSLuv",
|
|
2305
|
+
coords: {
|
|
2306
|
+
h: {
|
|
2307
|
+
refRange: [0, 360],
|
|
2308
|
+
type: "angle",
|
|
2309
|
+
name: "Hue"
|
|
2310
|
+
},
|
|
2311
|
+
s: {
|
|
2312
|
+
range: [0, 100],
|
|
2313
|
+
name: "Saturation"
|
|
2314
|
+
},
|
|
2315
|
+
l: {
|
|
2316
|
+
range: [0, 100],
|
|
2317
|
+
name: "Lightness"
|
|
2318
|
+
}
|
|
2319
|
+
},
|
|
2320
|
+
base: at,
|
|
2321
|
+
gamutSpace: ee,
|
|
2322
|
+
// Convert LCHuv to HSLuv
|
|
2323
|
+
fromBase(t) {
|
|
2324
|
+
let [e, r, n] = [S(t[0]), S(t[1]), S(t[2])], a;
|
|
2325
|
+
if (e > 99.9999999)
|
|
2326
|
+
a = 0, e = 100;
|
|
2327
|
+
else if (e < 1e-8)
|
|
2328
|
+
a = 0, e = 0;
|
|
2329
|
+
else {
|
|
2330
|
+
let s = Ne(e), i = Qt(s, n);
|
|
2331
|
+
a = r / i * 100;
|
|
2332
|
+
}
|
|
2333
|
+
return [n, a, e];
|
|
2334
|
+
},
|
|
2335
|
+
// Convert HSLuv to LCHuv
|
|
2336
|
+
toBase(t) {
|
|
2337
|
+
let [e, r, n] = [S(t[0]), S(t[1]), S(t[2])], a;
|
|
2338
|
+
if (n > 99.9999999)
|
|
2339
|
+
n = 100, a = 0;
|
|
2340
|
+
else if (n < 1e-8)
|
|
2341
|
+
n = 0, a = 0;
|
|
2342
|
+
else {
|
|
2343
|
+
let s = Ne(n);
|
|
2344
|
+
a = Qt(s, e) / 100 * r;
|
|
2345
|
+
}
|
|
2346
|
+
return [n, a, e];
|
|
2347
|
+
},
|
|
2348
|
+
formats: {
|
|
2349
|
+
color: {
|
|
2350
|
+
id: "--hsluv",
|
|
2351
|
+
coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
});
|
|
2355
|
+
x[0][0];
|
|
2356
|
+
x[0][1];
|
|
2357
|
+
x[0][2];
|
|
2358
|
+
x[1][0];
|
|
2359
|
+
x[1][1];
|
|
2360
|
+
x[1][2];
|
|
2361
|
+
x[2][0];
|
|
2362
|
+
x[2][1];
|
|
2363
|
+
x[2][2];
|
|
2364
|
+
function Q(t, e) {
|
|
2365
|
+
return Math.abs(e) / Math.sqrt(Math.pow(t, 2) + 1);
|
|
2366
|
+
}
|
|
2367
|
+
function Ut(t) {
|
|
2368
|
+
let e = Q(t.r0s, t.r0i), r = Q(t.r1s, t.r1i), n = Q(t.g0s, t.g0i), a = Q(t.g1s, t.g1i), s = Q(t.b0s, t.b0i), i = Q(t.b1s, t.b1i);
|
|
2369
|
+
return Math.min(e, r, n, a, s, i);
|
|
2370
|
+
}
|
|
2371
|
+
var Xn = new d({
|
|
2372
|
+
id: "hpluv",
|
|
2373
|
+
name: "HPLuv",
|
|
2374
|
+
coords: {
|
|
2375
|
+
h: {
|
|
2376
|
+
refRange: [0, 360],
|
|
2377
|
+
type: "angle",
|
|
2378
|
+
name: "Hue"
|
|
2379
|
+
},
|
|
2380
|
+
s: {
|
|
2381
|
+
range: [0, 100],
|
|
2382
|
+
name: "Saturation"
|
|
2383
|
+
},
|
|
2384
|
+
l: {
|
|
2385
|
+
range: [0, 100],
|
|
2386
|
+
name: "Lightness"
|
|
2387
|
+
}
|
|
2388
|
+
},
|
|
2389
|
+
base: at,
|
|
2390
|
+
gamutSpace: "self",
|
|
2391
|
+
// Convert LCHuv to HPLuv
|
|
2392
|
+
fromBase(t) {
|
|
2393
|
+
let [e, r, n] = [S(t[0]), S(t[1]), S(t[2])], a;
|
|
2394
|
+
if (e > 99.9999999)
|
|
2395
|
+
a = 0, e = 100;
|
|
2396
|
+
else if (e < 1e-8)
|
|
2397
|
+
a = 0, e = 0;
|
|
2398
|
+
else {
|
|
2399
|
+
let s = Ne(e), i = Ut(s);
|
|
2400
|
+
a = r / i * 100;
|
|
2401
|
+
}
|
|
2402
|
+
return [n, a, e];
|
|
2403
|
+
},
|
|
2404
|
+
// Convert HPLuv to LCHuv
|
|
2405
|
+
toBase(t) {
|
|
2406
|
+
let [e, r, n] = [S(t[0]), S(t[1]), S(t[2])], a;
|
|
2407
|
+
if (n > 99.9999999)
|
|
2408
|
+
n = 100, a = 0;
|
|
2409
|
+
else if (n < 1e-8)
|
|
2410
|
+
n = 0, a = 0;
|
|
2411
|
+
else {
|
|
2412
|
+
let s = Ne(n);
|
|
2413
|
+
a = Ut(s) / 100 * r;
|
|
2414
|
+
}
|
|
2415
|
+
return [n, a, e];
|
|
2416
|
+
},
|
|
2417
|
+
formats: {
|
|
2418
|
+
color: {
|
|
2419
|
+
id: "--hpluv",
|
|
2420
|
+
coords: ["<number> | <angle>", "<percentage> | <number>", "<percentage> | <number>"]
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
});
|
|
2424
|
+
const Kt = 203, Vt = 2610 / 2 ** 14, jn = 2 ** 14 / 2610, qn = 2523 / 2 ** 5, e0 = 2 ** 5 / 2523, t0 = 3424 / 2 ** 12, r0 = 2413 / 2 ** 7, n0 = 2392 / 2 ** 7;
|
|
2425
|
+
var Zn = new I({
|
|
2426
|
+
id: "rec2100pq",
|
|
2427
|
+
cssId: "rec2100-pq",
|
|
2428
|
+
name: "REC.2100-PQ",
|
|
2429
|
+
base: Ie,
|
|
2430
|
+
toBase(t) {
|
|
2431
|
+
return t.map(function(e) {
|
|
2432
|
+
return (Math.max(e ** e0 - t0, 0) / (r0 - n0 * e ** e0)) ** jn * 1e4 / Kt;
|
|
2433
|
+
});
|
|
2434
|
+
},
|
|
2435
|
+
fromBase(t) {
|
|
2436
|
+
return t.map(function(e) {
|
|
2437
|
+
let r = Math.max(e * Kt / 1e4, 0), n = t0 + r0 * r ** Vt, a = 1 + n0 * r ** Vt;
|
|
2438
|
+
return (n / a) ** qn;
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
const a0 = 0.17883277, s0 = 0.28466892, i0 = 0.55991073, De = 3.7743;
|
|
2443
|
+
var Gn = new I({
|
|
2444
|
+
id: "rec2100hlg",
|
|
2445
|
+
cssId: "rec2100-hlg",
|
|
2446
|
+
name: "REC.2100-HLG",
|
|
2447
|
+
referred: "scene",
|
|
2448
|
+
base: Ie,
|
|
2449
|
+
toBase(t) {
|
|
2450
|
+
return t.map(function(e) {
|
|
2451
|
+
return e <= 0.5 ? e ** 2 / 3 * De : (Math.exp((e - i0) / a0) + s0) / 12 * De;
|
|
2452
|
+
});
|
|
2453
|
+
},
|
|
2454
|
+
fromBase(t) {
|
|
2455
|
+
return t.map(function(e) {
|
|
2456
|
+
return e /= De, e <= 1 / 12 ? Math.sqrt(3 * e) : a0 * Math.log(12 * e - s0) + i0;
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2460
|
+
const X0 = {};
|
|
2461
|
+
X.add("chromatic-adaptation-start", (t) => {
|
|
2462
|
+
t.options.method && (t.M = j0(t.W1, t.W2, t.options.method));
|
|
2463
|
+
});
|
|
2464
|
+
X.add("chromatic-adaptation-end", (t) => {
|
|
2465
|
+
t.M || (t.M = j0(t.W1, t.W2, t.options.method));
|
|
2466
|
+
});
|
|
2467
|
+
function $e({ id: t, toCone_M: e, fromCone_M: r }) {
|
|
2468
|
+
X0[t] = arguments[0];
|
|
2469
|
+
}
|
|
2470
|
+
function j0(t, e, r = "Bradford") {
|
|
2471
|
+
let n = X0[r], [a, s, i] = C(n.toCone_M, t), [o, l, f] = C(n.toCone_M, e), u = [
|
|
2472
|
+
[o / a, 0, 0],
|
|
2473
|
+
[0, l / s, 0],
|
|
2474
|
+
[0, 0, f / i]
|
|
2475
|
+
], c = C(u, n.toCone_M);
|
|
2476
|
+
return C(n.fromCone_M, c);
|
|
2477
|
+
}
|
|
2478
|
+
$e({
|
|
2479
|
+
id: "von Kries",
|
|
2480
|
+
toCone_M: [
|
|
2481
|
+
[0.40024, 0.7076, -0.08081],
|
|
2482
|
+
[-0.2263, 1.16532, 0.0457],
|
|
2483
|
+
[0, 0, 0.91822]
|
|
2484
|
+
],
|
|
2485
|
+
fromCone_M: [
|
|
2486
|
+
[1.8599363874558397, -1.1293816185800916, 0.21989740959619328],
|
|
2487
|
+
[0.3611914362417676, 0.6388124632850422, -6370596838649899e-21],
|
|
2488
|
+
[0, 0, 1.0890636230968613]
|
|
2489
|
+
]
|
|
2490
|
+
});
|
|
2491
|
+
$e({
|
|
2492
|
+
id: "Bradford",
|
|
2493
|
+
// Convert an array of XYZ values in the range 0.0 - 1.0
|
|
2494
|
+
// to cone fundamentals
|
|
2495
|
+
toCone_M: [
|
|
2496
|
+
[0.8951, 0.2664, -0.1614],
|
|
2497
|
+
[-0.7502, 1.7135, 0.0367],
|
|
2498
|
+
[0.0389, -0.0685, 1.0296]
|
|
2499
|
+
],
|
|
2500
|
+
// and back
|
|
2501
|
+
fromCone_M: [
|
|
2502
|
+
[0.9869929054667121, -0.14705425642099013, 0.15996265166373122],
|
|
2503
|
+
[0.4323052697233945, 0.5183602715367774, 0.049291228212855594],
|
|
2504
|
+
[-0.00852866457517732, 0.04004282165408486, 0.96848669578755]
|
|
2505
|
+
]
|
|
2506
|
+
});
|
|
2507
|
+
$e({
|
|
2508
|
+
id: "CAT02",
|
|
2509
|
+
// with complete chromatic adaptation to W2, so D = 1.0
|
|
2510
|
+
toCone_M: [
|
|
2511
|
+
[0.7328, 0.4296, -0.1624],
|
|
2512
|
+
[-0.7036, 1.6975, 61e-4],
|
|
2513
|
+
[3e-3, 0.0136, 0.9834]
|
|
2514
|
+
],
|
|
2515
|
+
fromCone_M: [
|
|
2516
|
+
[1.0961238208355142, -0.27886900021828726, 0.18274517938277307],
|
|
2517
|
+
[0.4543690419753592, 0.4735331543074117, 0.07209780371722911],
|
|
2518
|
+
[-0.009627608738429355, -0.00569803121611342, 1.0153256399545427]
|
|
2519
|
+
]
|
|
2520
|
+
});
|
|
2521
|
+
$e({
|
|
2522
|
+
id: "CAT16",
|
|
2523
|
+
toCone_M: [
|
|
2524
|
+
[0.401288, 0.650173, -0.051461],
|
|
2525
|
+
[-0.250268, 1.204414, 0.045854],
|
|
2526
|
+
[-2079e-6, 0.048952, 0.953127]
|
|
2527
|
+
],
|
|
2528
|
+
// the extra precision is needed to avoid roundtripping errors
|
|
2529
|
+
fromCone_M: [
|
|
2530
|
+
[1.862067855087233, -1.0112546305316845, 0.14918677544445172],
|
|
2531
|
+
[0.3875265432361372, 0.6214474419314753, -0.008973985167612521],
|
|
2532
|
+
[-0.01584149884933386, -0.03412293802851557, 1.0499644368778496]
|
|
2533
|
+
]
|
|
2534
|
+
});
|
|
2535
|
+
Object.assign(B, {
|
|
2536
|
+
// whitepoint values from ASTM E308-01 with 10nm spacing, 1931 2 degree observer
|
|
2537
|
+
// all normalized to Y (luminance) = 1.00000
|
|
2538
|
+
// Illuminant A is a tungsten electric light, giving a very warm, orange light.
|
|
2539
|
+
A: [1.0985, 1, 0.35585],
|
|
2540
|
+
// Illuminant C was an early approximation to daylight: illuminant A with a blue filter.
|
|
2541
|
+
C: [0.98074, 1, 1.18232],
|
|
2542
|
+
// The daylight series of illuminants simulate natural daylight.
|
|
2543
|
+
// The color temperature (in degrees Kelvin/100) ranges from
|
|
2544
|
+
// cool, overcast daylight (D50) to bright, direct sunlight (D65).
|
|
2545
|
+
D55: [0.95682, 1, 0.92149],
|
|
2546
|
+
D75: [0.94972, 1, 1.22638],
|
|
2547
|
+
// Equal-energy illuminant, used in two-stage CAT16
|
|
2548
|
+
E: [1, 1, 1],
|
|
2549
|
+
// The F series of illuminants represent fluorescent lights
|
|
2550
|
+
F2: [0.99186, 1, 0.67393],
|
|
2551
|
+
F7: [0.95041, 1, 1.08747],
|
|
2552
|
+
F11: [1.00962, 1, 0.6435]
|
|
2553
|
+
});
|
|
2554
|
+
B.ACES = [0.32168 / 0.33767, 1, (1 - 0.32168 - 0.33767) / 0.33767];
|
|
2555
|
+
const Jn = [
|
|
2556
|
+
[0.6624541811085053, 0.13400420645643313, 0.1561876870049078],
|
|
2557
|
+
[0.27222871678091454, 0.6740817658111484, 0.05368951740793705],
|
|
2558
|
+
[-0.005574649490394108, 0.004060733528982826, 1.0103391003129971]
|
|
2559
|
+
], Fn = [
|
|
2560
|
+
[1.6410233796943257, -0.32480329418479, -0.23642469523761225],
|
|
2561
|
+
[-0.6636628587229829, 1.6153315916573379, 0.016756347685530137],
|
|
2562
|
+
[0.011721894328375376, -0.008284441996237409, 0.9883948585390215]
|
|
2563
|
+
];
|
|
2564
|
+
var q0 = new I({
|
|
2565
|
+
id: "acescg",
|
|
2566
|
+
cssId: "--acescg",
|
|
2567
|
+
name: "ACEScg",
|
|
2568
|
+
// ACEScg – A scene-referred, linear-light encoding of ACES Data
|
|
2569
|
+
// https://docs.acescentral.com/specifications/acescg/
|
|
2570
|
+
// uses the AP1 primaries, see section 4.3.1 Color primaries
|
|
2571
|
+
coords: {
|
|
2572
|
+
r: {
|
|
2573
|
+
range: [0, 65504],
|
|
2574
|
+
name: "Red"
|
|
2575
|
+
},
|
|
2576
|
+
g: {
|
|
2577
|
+
range: [0, 65504],
|
|
2578
|
+
name: "Green"
|
|
2579
|
+
},
|
|
2580
|
+
b: {
|
|
2581
|
+
range: [0, 65504],
|
|
2582
|
+
name: "Blue"
|
|
2583
|
+
}
|
|
2584
|
+
},
|
|
2585
|
+
referred: "scene",
|
|
2586
|
+
white: B.ACES,
|
|
2587
|
+
toXYZ_M: Jn,
|
|
2588
|
+
fromXYZ_M: Fn
|
|
2589
|
+
});
|
|
2590
|
+
const Ce = 2 ** -16, Xe = -0.35828683, Le = (Math.log2(65504) + 9.72) / 17.52;
|
|
2591
|
+
var Wn = new I({
|
|
2592
|
+
id: "acescc",
|
|
2593
|
+
cssId: "--acescc",
|
|
2594
|
+
name: "ACEScc",
|
|
2595
|
+
// see S-2014-003 ACEScc – A Logarithmic Encoding of ACES Data
|
|
2596
|
+
// https://docs.acescentral.com/specifications/acescc/
|
|
2597
|
+
// uses the AP1 primaries, see section 4.3.1 Color primaries
|
|
2598
|
+
// Appendix A: "Very small ACES scene referred values below 7 1/4 stops
|
|
2599
|
+
// below 18% middle gray are encoded as negative ACEScc values.
|
|
2600
|
+
// These values should be preserved per the encoding in Section 4.4
|
|
2601
|
+
// so that all positive ACES values are maintained."
|
|
2602
|
+
coords: {
|
|
2603
|
+
r: {
|
|
2604
|
+
range: [Xe, Le],
|
|
2605
|
+
name: "Red"
|
|
2606
|
+
},
|
|
2607
|
+
g: {
|
|
2608
|
+
range: [Xe, Le],
|
|
2609
|
+
name: "Green"
|
|
2610
|
+
},
|
|
2611
|
+
b: {
|
|
2612
|
+
range: [Xe, Le],
|
|
2613
|
+
name: "Blue"
|
|
2614
|
+
}
|
|
2615
|
+
},
|
|
2616
|
+
referred: "scene",
|
|
2617
|
+
base: q0,
|
|
2618
|
+
// from section 4.4.2 Decoding Function
|
|
2619
|
+
toBase(t) {
|
|
2620
|
+
const e = -0.3013698630136986;
|
|
2621
|
+
return t.map(function(r) {
|
|
2622
|
+
return r <= e ? (2 ** (r * 17.52 - 9.72) - Ce) * 2 : r < Le ? 2 ** (r * 17.52 - 9.72) : 65504;
|
|
2623
|
+
});
|
|
2624
|
+
},
|
|
2625
|
+
// Non-linear encoding function from S-2014-003, section 4.4.1 Encoding Function
|
|
2626
|
+
fromBase(t) {
|
|
2627
|
+
return t.map(function(e) {
|
|
2628
|
+
return e <= 0 ? (Math.log2(Ce) + 9.72) / 17.52 : e < Ce ? (Math.log2(Ce + e * 0.5) + 9.72) / 17.52 : (Math.log2(e) + 9.72) / 17.52;
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2631
|
+
// encoded media white (rgb 1,1,1) => linear [ 222.861, 222.861, 222.861 ]
|
|
2632
|
+
// encoded media black (rgb 0,0,0) => linear [ 0.0011857, 0.0011857, 0.0011857]
|
|
2633
|
+
}), o0 = /* @__PURE__ */ Object.freeze({
|
|
2634
|
+
__proto__: null,
|
|
2635
|
+
A98RGB: $n,
|
|
2636
|
+
A98RGB_Linear: T0,
|
|
2637
|
+
ACEScc: Wn,
|
|
2638
|
+
ACEScg: q0,
|
|
2639
|
+
CAM16_JMh: kr,
|
|
2640
|
+
HCT: le,
|
|
2641
|
+
HPLuv: Xn,
|
|
2642
|
+
HSL: k0,
|
|
2643
|
+
HSLuv: Dn,
|
|
2644
|
+
HSV: H0,
|
|
2645
|
+
HWB: Bn,
|
|
2646
|
+
ICTCP: Ge,
|
|
2647
|
+
JzCzHz: Ze,
|
|
2648
|
+
Jzazbz: M0,
|
|
2649
|
+
LCH: oe,
|
|
2650
|
+
LCHuv: at,
|
|
2651
|
+
Lab: P,
|
|
2652
|
+
Lab_D65: We,
|
|
2653
|
+
Luv: D0,
|
|
2654
|
+
OKLCH: Hn,
|
|
2655
|
+
OKLab: U,
|
|
2656
|
+
P3: $0,
|
|
2657
|
+
P3_Linear: I0,
|
|
2658
|
+
ProPhoto: kn,
|
|
2659
|
+
ProPhoto_Linear: O0,
|
|
2660
|
+
REC_2020: B0,
|
|
2661
|
+
REC_2020_Linear: Ie,
|
|
2662
|
+
REC_2100_HLG: Gn,
|
|
2663
|
+
REC_2100_PQ: Zn,
|
|
2664
|
+
XYZ_ABS_D65: tt,
|
|
2665
|
+
XYZ_D50: et,
|
|
2666
|
+
XYZ_D65: N,
|
|
2667
|
+
sRGB: ee,
|
|
2668
|
+
sRGB_Linear: z0
|
|
2669
|
+
});
|
|
2670
|
+
class w {
|
|
2671
|
+
/**
|
|
2672
|
+
* Creates an instance of Color.
|
|
2673
|
+
* Signatures:
|
|
2674
|
+
* - `new Color(stringToParse)`
|
|
2675
|
+
* - `new Color(otherColor)`
|
|
2676
|
+
* - `new Color({space, coords, alpha})`
|
|
2677
|
+
* - `new Color(space, coords, alpha)`
|
|
2678
|
+
* - `new Color(spaceId, coords, alpha)`
|
|
2679
|
+
*/
|
|
2680
|
+
constructor(...e) {
|
|
2681
|
+
let r;
|
|
2682
|
+
e.length === 1 && (r = g(e[0]));
|
|
2683
|
+
let n, a, s;
|
|
2684
|
+
r ? (n = r.space || r.spaceId, a = r.coords, s = r.alpha) : [n, a, s] = e, Object.defineProperty(this, "space", {
|
|
2685
|
+
value: d.get(n),
|
|
2686
|
+
writable: !1,
|
|
2687
|
+
enumerable: !0,
|
|
2688
|
+
configurable: !0
|
|
2689
|
+
// see note in https://262.ecma-international.org/8.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
|
|
2690
|
+
}), this.coords = a ? a.slice() : [0, 0, 0], this.alpha = s > 1 || s === void 0 ? 1 : s < 0 ? 0 : s;
|
|
2691
|
+
for (let i = 0; i < this.coords.length; i++)
|
|
2692
|
+
this.coords[i] === "NaN" && (this.coords[i] = NaN);
|
|
2693
|
+
for (let i in this.space.coords)
|
|
2694
|
+
Object.defineProperty(this, i, {
|
|
2695
|
+
get: () => this.get(i),
|
|
2696
|
+
set: (o) => this.set(i, o)
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2699
|
+
get spaceId() {
|
|
2700
|
+
return this.space.id;
|
|
2701
|
+
}
|
|
2702
|
+
clone() {
|
|
2703
|
+
return new w(this.space, this.coords, this.alpha);
|
|
2704
|
+
}
|
|
2705
|
+
toJSON() {
|
|
2706
|
+
return {
|
|
2707
|
+
spaceId: this.spaceId,
|
|
2708
|
+
coords: this.coords,
|
|
2709
|
+
alpha: this.alpha
|
|
2710
|
+
};
|
|
2711
|
+
}
|
|
2712
|
+
display(...e) {
|
|
2713
|
+
let r = Kr(this, ...e);
|
|
2714
|
+
return r.color = new w(r.color), r;
|
|
2715
|
+
}
|
|
2716
|
+
/**
|
|
2717
|
+
* Get a color from the argument passed
|
|
2718
|
+
* Basically gets us the same result as new Color(color) but doesn't clone an existing color object
|
|
2719
|
+
*/
|
|
2720
|
+
static get(e, ...r) {
|
|
2721
|
+
return e instanceof w ? e : new w(e, ...r);
|
|
2722
|
+
}
|
|
2723
|
+
static defineFunction(e, r, n = r) {
|
|
2724
|
+
let { instance: a = !0, returns: s } = n, i = function(...o) {
|
|
2725
|
+
let l = r(...o);
|
|
2726
|
+
if (s === "color")
|
|
2727
|
+
l = w.get(l);
|
|
2728
|
+
else if (s === "function<color>") {
|
|
2729
|
+
let f = l;
|
|
2730
|
+
l = function(...u) {
|
|
2731
|
+
let c = f(...u);
|
|
2732
|
+
return w.get(c);
|
|
2733
|
+
}, Object.assign(l, f);
|
|
2734
|
+
} else s === "array<color>" && (l = l.map((f) => w.get(f)));
|
|
2735
|
+
return l;
|
|
2736
|
+
};
|
|
2737
|
+
e in w || (w[e] = i), a && (w.prototype[e] = function(...o) {
|
|
2738
|
+
return i(this, ...o);
|
|
2739
|
+
});
|
|
2740
|
+
}
|
|
2741
|
+
static defineFunctions(e) {
|
|
2742
|
+
for (let r in e)
|
|
2743
|
+
w.defineFunction(r, e[r], e[r]);
|
|
2744
|
+
}
|
|
2745
|
+
static extend(e) {
|
|
2746
|
+
if (e.register)
|
|
2747
|
+
e.register(w);
|
|
2748
|
+
else
|
|
2749
|
+
for (let r in e)
|
|
2750
|
+
w.defineFunction(r, e[r]);
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
w.defineFunctions({
|
|
2754
|
+
get: $,
|
|
2755
|
+
getAll: ue,
|
|
2756
|
+
set: T,
|
|
2757
|
+
setAll: Ve,
|
|
2758
|
+
to: y,
|
|
2759
|
+
equals: Vr,
|
|
2760
|
+
inGamut: G,
|
|
2761
|
+
toGamut: j,
|
|
2762
|
+
distance: b0,
|
|
2763
|
+
toString: se
|
|
2764
|
+
});
|
|
2765
|
+
Object.assign(w, {
|
|
2766
|
+
util: U0,
|
|
2767
|
+
hooks: X,
|
|
2768
|
+
WHITES: B,
|
|
2769
|
+
Space: d,
|
|
2770
|
+
spaces: d.registry,
|
|
2771
|
+
parse: g0,
|
|
2772
|
+
// Global defaults one may want to configure
|
|
2773
|
+
defaults: E
|
|
2774
|
+
});
|
|
2775
|
+
for (let t of Object.keys(o0))
|
|
2776
|
+
d.register(o0[t]);
|
|
2777
|
+
for (let t in d.registry)
|
|
2778
|
+
Qe(t, d.registry[t]);
|
|
2779
|
+
X.add("colorspace-init-end", (t) => {
|
|
2780
|
+
Qe(t.id, t), t.aliases?.forEach((e) => {
|
|
2781
|
+
Qe(e, t);
|
|
2782
|
+
});
|
|
2783
|
+
});
|
|
2784
|
+
function Qe(t, e) {
|
|
2785
|
+
let r = t.replace(/-/g, "_");
|
|
2786
|
+
Object.defineProperty(w.prototype, r, {
|
|
2787
|
+
// Convert coords to coords in another colorspace and return them
|
|
2788
|
+
// Source colorspace: this.spaceId
|
|
2789
|
+
// Target colorspace: id
|
|
2790
|
+
get() {
|
|
2791
|
+
let n = this.getAll(t);
|
|
2792
|
+
return typeof Proxy > "u" ? n : new Proxy(n, {
|
|
2793
|
+
has: (a, s) => {
|
|
2794
|
+
try {
|
|
2795
|
+
return d.resolveCoord([e, s]), !0;
|
|
2796
|
+
} catch {
|
|
2797
|
+
}
|
|
2798
|
+
return Reflect.has(a, s);
|
|
2799
|
+
},
|
|
2800
|
+
get: (a, s, i) => {
|
|
2801
|
+
if (s && typeof s != "symbol" && !(s in a)) {
|
|
2802
|
+
let { index: o } = d.resolveCoord([e, s]);
|
|
2803
|
+
if (o >= 0)
|
|
2804
|
+
return a[o];
|
|
2805
|
+
}
|
|
2806
|
+
return Reflect.get(a, s, i);
|
|
2807
|
+
},
|
|
2808
|
+
set: (a, s, i, o) => {
|
|
2809
|
+
if (s && typeof s != "symbol" && !(s in a) || s >= 0) {
|
|
2810
|
+
let { index: l } = d.resolveCoord([e, s]);
|
|
2811
|
+
if (l >= 0)
|
|
2812
|
+
return a[l] = i, this.setAll(t, a), !0;
|
|
2813
|
+
}
|
|
2814
|
+
return Reflect.set(a, s, i, o);
|
|
2815
|
+
}
|
|
2816
|
+
});
|
|
2817
|
+
},
|
|
2818
|
+
// Convert coords in another colorspace to internal coords and set them
|
|
2819
|
+
// Target colorspace: this.spaceId
|
|
2820
|
+
// Source colorspace: id
|
|
2821
|
+
set(n) {
|
|
2822
|
+
this.setAll(t, n);
|
|
2823
|
+
},
|
|
2824
|
+
configurable: !0,
|
|
2825
|
+
enumerable: !0
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
w.extend(V);
|
|
2829
|
+
w.extend({ deltaE: ae });
|
|
2830
|
+
Object.assign(w, { deltaEMethods: V });
|
|
2831
|
+
w.extend(Rn);
|
|
2832
|
+
w.extend({ contrast: yn });
|
|
2833
|
+
w.extend(Ln);
|
|
2834
|
+
w.extend(tn);
|
|
2835
|
+
w.extend(Nn);
|
|
2836
|
+
w.extend(_e);
|
|
2837
|
+
export {
|
|
2838
|
+
w as default
|
|
2839
|
+
};
|