@a_ng_d/utils-ui-color-palette 1.7.8 → 1.8.0
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/dist/{color-1CXTuV84.js → color-S7JZ1G0L.js} +217 -155
- package/dist/color-S7JZ1G0L.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/modules/color/color.d.ts +4 -0
- package/dist/modules/color/color.d.ts.map +1 -1
- package/dist/modules/color/color.js +1 -1
- package/dist/modules/data/data.d.ts.map +1 -1
- package/dist/modules/data/data.js +162 -122
- package/dist/modules/data/data.js.map +1 -1
- package/dist/types/configuration.types.d.ts +2 -1
- package/dist/types/configuration.types.d.ts.map +1 -1
- package/dist/types/data.types.d.ts +2 -0
- package/dist/types/data.types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/color-1CXTuV84.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var R = (b, t, h) => t in b ? A(b, t, { enumerable: !0, configurable: !0, writable: !0, value: h }) : b[t] = h;
|
|
3
|
+
var a = (b, t, h) => R(b, typeof t != "symbol" ? t + "" : t, h);
|
|
4
4
|
import { c as n } from "./index-Beb8qoyd.js";
|
|
5
5
|
class s {
|
|
6
6
|
constructor() {
|
|
@@ -19,22 +19,22 @@ class s {
|
|
|
19
19
|
return t <= 8 ? s.refY * t / s.kappa : s.refY * Math.pow((t + 16) / 116, 3);
|
|
20
20
|
}
|
|
21
21
|
static rgbChannelToHex(t) {
|
|
22
|
-
const h = Math.round(t * 255),
|
|
23
|
-
return s.hexChars.charAt(
|
|
22
|
+
const h = Math.round(t * 255), i = h % 16, e = (h - i) / 16 | 0;
|
|
23
|
+
return s.hexChars.charAt(e) + s.hexChars.charAt(i);
|
|
24
24
|
}
|
|
25
25
|
static hexToRgbChannel(t, h) {
|
|
26
|
-
const
|
|
27
|
-
return (
|
|
26
|
+
const i = s.hexChars.indexOf(t.charAt(h)), e = s.hexChars.indexOf(t.charAt(h + 1));
|
|
27
|
+
return (i * 16 + e) / 255;
|
|
28
28
|
}
|
|
29
|
-
static distanceFromOriginAngle(t, h,
|
|
30
|
-
const
|
|
31
|
-
return
|
|
29
|
+
static distanceFromOriginAngle(t, h, i) {
|
|
30
|
+
const e = h / (Math.sin(i) - t * Math.cos(i));
|
|
31
|
+
return e < 0 ? 1 / 0 : e;
|
|
32
32
|
}
|
|
33
33
|
static distanceFromOrigin(t, h) {
|
|
34
34
|
return Math.abs(h) / Math.sqrt(Math.pow(t, 2) + 1);
|
|
35
35
|
}
|
|
36
|
-
static min6(t, h,
|
|
37
|
-
return Math.min(t, Math.min(h, Math.min(
|
|
36
|
+
static min6(t, h, i, e, r, o) {
|
|
37
|
+
return Math.min(t, Math.min(h, Math.min(i, Math.min(e, Math.min(r, o)))));
|
|
38
38
|
}
|
|
39
39
|
rgbToHex() {
|
|
40
40
|
this.hex = "#", this.hex += s.rgbChannelToHex(this.rgb_r), this.hex += s.rgbChannelToHex(this.rgb_g), this.hex += s.rgbChannelToHex(this.rgb_b);
|
|
@@ -46,13 +46,13 @@ class s {
|
|
|
46
46
|
this.rgb_r = s.fromLinear(s.m_r0 * this.xyz_x + s.m_r1 * this.xyz_y + s.m_r2 * this.xyz_z), this.rgb_g = s.fromLinear(s.m_g0 * this.xyz_x + s.m_g1 * this.xyz_y + s.m_g2 * this.xyz_z), this.rgb_b = s.fromLinear(s.m_b0 * this.xyz_x + s.m_b1 * this.xyz_y + s.m_b2 * this.xyz_z);
|
|
47
47
|
}
|
|
48
48
|
rgbToXyz() {
|
|
49
|
-
const t = s.toLinear(this.rgb_r), h = s.toLinear(this.rgb_g),
|
|
50
|
-
this.xyz_x = 0.41239079926595 * t + 0.35758433938387 * h + 0.18048078840183 *
|
|
49
|
+
const t = s.toLinear(this.rgb_r), h = s.toLinear(this.rgb_g), i = s.toLinear(this.rgb_b);
|
|
50
|
+
this.xyz_x = 0.41239079926595 * t + 0.35758433938387 * h + 0.18048078840183 * i, this.xyz_y = 0.21263900587151 * t + 0.71516867876775 * h + 0.072192315360733 * i, this.xyz_z = 0.019330818715591 * t + 0.11919477979462 * h + 0.95053215224966 * i;
|
|
51
51
|
}
|
|
52
52
|
xyzToLuv() {
|
|
53
53
|
const t = this.xyz_x + 15 * this.xyz_y + 3 * this.xyz_z;
|
|
54
|
-
let h = 4 * this.xyz_x,
|
|
55
|
-
t !== 0 ? (h /= t,
|
|
54
|
+
let h = 4 * this.xyz_x, i = 9 * this.xyz_y;
|
|
55
|
+
t !== 0 ? (h /= t, i /= t) : (h = NaN, i = NaN), this.luv_l = s.yToL(this.xyz_y), this.luv_l === 0 ? (this.luv_u = 0, this.luv_v = 0) : (this.luv_u = 13 * this.luv_l * (h - s.refU), this.luv_v = 13 * this.luv_l * (i - s.refV));
|
|
56
56
|
}
|
|
57
57
|
luvToXyz() {
|
|
58
58
|
if (this.luv_l === 0) {
|
|
@@ -75,16 +75,16 @@ class s {
|
|
|
75
75
|
this.luv_l = this.lch_l, this.luv_u = Math.cos(t) * this.lch_c, this.luv_v = Math.sin(t) * this.lch_c;
|
|
76
76
|
}
|
|
77
77
|
calculateBoundingLines(t) {
|
|
78
|
-
const h = Math.pow(t + 16, 3) / 1560896,
|
|
79
|
-
this.r0s =
|
|
78
|
+
const h = Math.pow(t + 16, 3) / 1560896, i = h > s.epsilon ? h : t / s.kappa, e = i * (284517 * s.m_r0 - 94839 * s.m_r2), r = i * (838422 * s.m_r2 + 769860 * s.m_r1 + 731718 * s.m_r0), o = i * (632260 * s.m_r2 - 126452 * s.m_r1), l = i * (284517 * s.m_g0 - 94839 * s.m_g2), u = i * (838422 * s.m_g2 + 769860 * s.m_g1 + 731718 * s.m_g0), d = i * (632260 * s.m_g2 - 126452 * s.m_g1), C = i * (284517 * s.m_b0 - 94839 * s.m_b2), M = i * (838422 * s.m_b2 + 769860 * s.m_b1 + 731718 * s.m_b0), m = i * (632260 * s.m_b2 - 126452 * s.m_b1);
|
|
79
|
+
this.r0s = e / o, this.r0i = r * t / o, this.r1s = e / (o + 126452), this.r1i = (r - 769860) * t / (o + 126452), this.g0s = l / d, this.g0i = u * t / d, this.g1s = l / (d + 126452), this.g1i = (u - 769860) * t / (d + 126452), this.b0s = C / m, this.b0i = M * t / m, this.b1s = C / (m + 126452), this.b1i = (M - 769860) * t / (m + 126452);
|
|
80
80
|
}
|
|
81
81
|
calcMaxChromaHpluv() {
|
|
82
|
-
const t = s.distanceFromOrigin(this.r0s, this.r0i), h = s.distanceFromOrigin(this.r1s, this.r1i),
|
|
83
|
-
return s.min6(t, h,
|
|
82
|
+
const t = s.distanceFromOrigin(this.r0s, this.r0i), h = s.distanceFromOrigin(this.r1s, this.r1i), i = s.distanceFromOrigin(this.g0s, this.g0i), e = s.distanceFromOrigin(this.g1s, this.g1i), r = s.distanceFromOrigin(this.b0s, this.b0i), o = s.distanceFromOrigin(this.b1s, this.b1i);
|
|
83
|
+
return s.min6(t, h, i, e, r, o);
|
|
84
84
|
}
|
|
85
85
|
calcMaxChromaHsluv(t) {
|
|
86
|
-
const h = t / 360 * Math.PI * 2,
|
|
87
|
-
return s.min6(
|
|
86
|
+
const h = t / 360 * Math.PI * 2, i = s.distanceFromOriginAngle(this.r0s, this.r0i, h), e = s.distanceFromOriginAngle(this.r1s, this.r1i, h), r = s.distanceFromOriginAngle(this.g0s, this.g0i, h), o = s.distanceFromOriginAngle(this.g1s, this.g1i, h), l = s.distanceFromOriginAngle(this.b0s, this.b0i, h), u = s.distanceFromOriginAngle(this.b1s, this.b1i, h);
|
|
87
|
+
return s.min6(i, e, r, o, l, u);
|
|
88
88
|
}
|
|
89
89
|
hsluvToLch() {
|
|
90
90
|
if (this.hsluv_l > 99.9999999)
|
|
@@ -174,7 +174,7 @@ s.m_g2 = 0.041555057407175;
|
|
|
174
174
|
s.m_b0 = 0.055630079696993;
|
|
175
175
|
s.m_b1 = -0.20397695888897;
|
|
176
176
|
s.m_b2 = 1.056971514242878;
|
|
177
|
-
const
|
|
177
|
+
const c = {
|
|
178
178
|
PROTANOPIA: [
|
|
179
179
|
[0.567, 0.433, 0],
|
|
180
180
|
[0.558, 0.442, 0],
|
|
@@ -215,47 +215,59 @@ const u = {
|
|
|
215
215
|
[0.163, 0.775, 0.062],
|
|
216
216
|
[0.163, 0.32, 0.516]
|
|
217
217
|
]
|
|
218
|
-
},
|
|
219
|
-
const [h,
|
|
218
|
+
}, g = (b, t) => {
|
|
219
|
+
const [h, i, e] = b, [r, o, l] = t;
|
|
220
220
|
return [
|
|
221
|
-
Math.round(h *
|
|
222
|
-
Math.round(h *
|
|
223
|
-
Math.round(h *
|
|
221
|
+
Math.round(h * r[0] + i * r[1] + e * r[2]),
|
|
222
|
+
Math.round(h * o[0] + i * o[1] + e * o[2]),
|
|
223
|
+
Math.round(h * l[0] + i * l[1] + e * l[2])
|
|
224
224
|
];
|
|
225
|
-
}
|
|
226
|
-
|
|
225
|
+
}, _ = (b, t, h) => {
|
|
226
|
+
const i = b / 255, e = t / 255, r = h / 255, o = 1 - Math.max(i, e, r);
|
|
227
|
+
return o === 1 ? [0, 0, 0, 1] : [
|
|
228
|
+
(1 - i - o) / (1 - o),
|
|
229
|
+
(1 - e - o) / (1 - o),
|
|
230
|
+
(1 - r - o) / (1 - o),
|
|
231
|
+
o
|
|
232
|
+
];
|
|
233
|
+
}, x = (b, t, h, i) => [
|
|
234
|
+
Math.round(255 * (1 - b) * (1 - i)),
|
|
235
|
+
Math.round(255 * (1 - t) * (1 - i)),
|
|
236
|
+
Math.round(255 * (1 - h) * (1 - i))
|
|
237
|
+
];
|
|
238
|
+
class O {
|
|
227
239
|
constructor({
|
|
228
240
|
render: t = "HEX",
|
|
229
241
|
sourceColor: h = [0, 0, 0],
|
|
230
|
-
lightness:
|
|
231
|
-
alpha:
|
|
232
|
-
hueShifting:
|
|
233
|
-
chromaShifting:
|
|
234
|
-
algorithmVersion:
|
|
235
|
-
visionSimulationMode:
|
|
242
|
+
lightness: i = parseFloat((n(h).luminance() * 100).toFixed(1)),
|
|
243
|
+
alpha: e = 1,
|
|
244
|
+
hueShifting: r = 0,
|
|
245
|
+
chromaShifting: o = 100,
|
|
246
|
+
algorithmVersion: l = "v3",
|
|
247
|
+
visionSimulationMode: u = "NONE"
|
|
236
248
|
}) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
249
|
+
a(this, "render");
|
|
250
|
+
a(this, "sourceColor");
|
|
251
|
+
a(this, "lightness");
|
|
252
|
+
a(this, "alpha");
|
|
253
|
+
a(this, "hueShifting");
|
|
254
|
+
a(this, "chromaShifting");
|
|
255
|
+
a(this, "algorithmVersion");
|
|
256
|
+
a(this, "visionSimulationMode");
|
|
257
|
+
a(this, "adjustHue", (t) => t + this.hueShifting < 0 ? t + this.hueShifting + 360 : t + this.hueShifting > 360 ? t + this.hueShifting - 360 : t + this.hueShifting);
|
|
258
|
+
a(this, "adjustChroma", (t) => {
|
|
247
259
|
if (this.algorithmVersion === "v1") return t;
|
|
248
260
|
if (this.algorithmVersion === "v2")
|
|
249
261
|
return Math.sin(this.lightness / 100 * Math.PI) * t;
|
|
250
262
|
if (this.algorithmVersion === "v3") {
|
|
251
|
-
const h = this.lightness / 100,
|
|
252
|
-
return Math.pow(
|
|
263
|
+
const h = this.lightness / 100, i = Math.sin(h * Math.PI), e = Math.tanh(h * Math.PI), r = i * 0.5 + e * 0.5;
|
|
264
|
+
return Math.pow(r, 0.5) * t;
|
|
253
265
|
}
|
|
254
266
|
return t;
|
|
255
267
|
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
268
|
+
a(this, "setColor", () => this.render === "HEX" ? this.simulateColorBlindHex(this.sourceColor) : this.simulateColorBlindRgb(this.sourceColor));
|
|
269
|
+
a(this, "setColorWithAlpha", () => this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(this.sourceColor), this.alpha).hex() : [...this.simulateColorBlindRgb(this.sourceColor), this.alpha]);
|
|
270
|
+
a(this, "lch", () => {
|
|
259
271
|
const t = n(this.sourceColor).lch(), h = n.lch(
|
|
260
272
|
this.lightness,
|
|
261
273
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -263,7 +275,7 @@ class p {
|
|
|
263
275
|
).rgb();
|
|
264
276
|
return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
|
|
265
277
|
});
|
|
266
|
-
|
|
278
|
+
a(this, "lcha", () => {
|
|
267
279
|
const t = n(this.sourceColor).lch(), h = n.lch(
|
|
268
280
|
t[0],
|
|
269
281
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -271,7 +283,7 @@ class p {
|
|
|
271
283
|
).rgb();
|
|
272
284
|
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
|
|
273
285
|
});
|
|
274
|
-
|
|
286
|
+
a(this, "oklch", () => {
|
|
275
287
|
const t = n(this.sourceColor).oklch(), h = n.oklch(
|
|
276
288
|
this.lightness / 100,
|
|
277
289
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -279,7 +291,7 @@ class p {
|
|
|
279
291
|
).rgb();
|
|
280
292
|
return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
|
|
281
293
|
});
|
|
282
|
-
|
|
294
|
+
a(this, "oklcha", () => {
|
|
283
295
|
const t = n(this.sourceColor).oklch(), h = n.oklch(
|
|
284
296
|
t[0],
|
|
285
297
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -287,51 +299,51 @@ class p {
|
|
|
287
299
|
).rgb();
|
|
288
300
|
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
|
|
289
301
|
});
|
|
290
|
-
|
|
291
|
-
const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"),
|
|
292
|
-
let
|
|
293
|
-
(
|
|
294
|
-
let
|
|
295
|
-
Math.sign(t) === -1 && Math.sign(h) === 1 && (
|
|
296
|
-
const
|
|
302
|
+
a(this, "lab", () => {
|
|
303
|
+
const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), i = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
|
|
304
|
+
let e = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
|
|
305
|
+
(e > Math.PI || e < -Math.PI) && (e = Math.PI);
|
|
306
|
+
let r = i * Math.cos(e), o = i * Math.sin(e);
|
|
307
|
+
Math.sign(t) === -1 && Math.sign(h) === 1 && (r *= -1, o *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (r *= -1, o *= -1);
|
|
308
|
+
const l = n.lab(
|
|
297
309
|
this.lightness,
|
|
298
|
-
this.adjustChroma(
|
|
299
|
-
this.adjustChroma(
|
|
310
|
+
this.adjustChroma(r),
|
|
311
|
+
this.adjustChroma(o)
|
|
300
312
|
).rgb();
|
|
301
|
-
return this.render === "HEX" ? this.simulateColorBlindHex(
|
|
313
|
+
return this.render === "HEX" ? this.simulateColorBlindHex(l) : this.simulateColorBlindRgb(l);
|
|
302
314
|
});
|
|
303
|
-
|
|
304
|
-
const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"),
|
|
305
|
-
let
|
|
306
|
-
(
|
|
307
|
-
let
|
|
308
|
-
Math.sign(t) === -1 && Math.sign(h) === 1 && (
|
|
309
|
-
const
|
|
310
|
-
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(
|
|
315
|
+
a(this, "laba", () => {
|
|
316
|
+
const t = n(this.sourceColor).get("lab.a"), h = n(this.sourceColor).get("lab.b"), i = n(this.sourceColor).get("lab.l"), e = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
|
|
317
|
+
let r = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
|
|
318
|
+
(r > Math.PI || r < -Math.PI) && (r = Math.PI);
|
|
319
|
+
let o = e * Math.cos(r), l = e * Math.sin(r);
|
|
320
|
+
Math.sign(t) === -1 && Math.sign(h) === 1 && (o *= -1, l *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (o *= -1, l *= -1);
|
|
321
|
+
const u = n.lab(i, this.adjustChroma(o), this.adjustChroma(l)).rgb();
|
|
322
|
+
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(u), this.alpha).hex() : [...this.simulateColorBlindRgb(u), this.alpha];
|
|
311
323
|
});
|
|
312
|
-
|
|
313
|
-
const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"),
|
|
314
|
-
let
|
|
315
|
-
(
|
|
316
|
-
let
|
|
317
|
-
Math.sign(t) === -1 && Math.sign(h) === 1 && (
|
|
318
|
-
const
|
|
324
|
+
a(this, "oklab", () => {
|
|
325
|
+
const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), i = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
|
|
326
|
+
let e = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
|
|
327
|
+
(e > Math.PI || e < -Math.PI) && (e = Math.PI);
|
|
328
|
+
let r = i * Math.cos(e), o = i * Math.sin(e);
|
|
329
|
+
Math.sign(t) === -1 && Math.sign(h) === 1 && (r *= -1, o *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (r *= -1, o *= -1), Number.isNaN(r) && (r = 0), Number.isNaN(o) && (o = 0);
|
|
330
|
+
const l = n.oklab(
|
|
319
331
|
this.lightness / 100,
|
|
320
|
-
this.adjustChroma(
|
|
321
|
-
this.adjustChroma(
|
|
332
|
+
this.adjustChroma(r),
|
|
333
|
+
this.adjustChroma(o)
|
|
322
334
|
).rgb();
|
|
323
|
-
return this.render === "HEX" ? this.simulateColorBlindHex(
|
|
335
|
+
return this.render === "HEX" ? this.simulateColorBlindHex(l) : this.simulateColorBlindRgb(l);
|
|
324
336
|
});
|
|
325
|
-
|
|
326
|
-
const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"),
|
|
327
|
-
let
|
|
328
|
-
(
|
|
329
|
-
let
|
|
330
|
-
Math.sign(t) === -1 && Math.sign(h) === 1 && (
|
|
331
|
-
const
|
|
332
|
-
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(
|
|
337
|
+
a(this, "oklaba", () => {
|
|
338
|
+
const t = n(this.sourceColor).get("oklab.a"), h = n(this.sourceColor).get("oklab.b"), i = n(this.sourceColor).get("oklab.l"), e = Math.sqrt(t ** 2 + h ** 2) * (this.chromaShifting / 100);
|
|
339
|
+
let r = Math.atan(h / t) + this.hueShifting * (Math.PI / 180);
|
|
340
|
+
(r > Math.PI || r < -Math.PI) && (r = Math.PI);
|
|
341
|
+
let o = e * Math.cos(r), l = e * Math.sin(r);
|
|
342
|
+
Math.sign(t) === -1 && Math.sign(h) === 1 && (o *= -1, l *= -1), Math.sign(t) === -1 && Math.sign(h) === -1 && (o *= -1, l *= -1), Number.isNaN(o) && (o = 0), Number.isNaN(l) && (l = 0);
|
|
343
|
+
const u = n.oklab(i, this.adjustChroma(o), this.adjustChroma(l)).rgb();
|
|
344
|
+
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(u), this.alpha).hex() : [...this.simulateColorBlindRgb(u), this.alpha];
|
|
333
345
|
});
|
|
334
|
-
|
|
346
|
+
a(this, "hsl", () => {
|
|
335
347
|
const t = n(this.sourceColor).hsl(), h = n.hsl(
|
|
336
348
|
this.adjustHue(t[0]),
|
|
337
349
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -339,7 +351,7 @@ class p {
|
|
|
339
351
|
).rgb();
|
|
340
352
|
return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
|
|
341
353
|
});
|
|
342
|
-
|
|
354
|
+
a(this, "hsla", () => {
|
|
343
355
|
const t = n(this.sourceColor).hsl(), h = n.hsl(
|
|
344
356
|
this.adjustHue(t[0]),
|
|
345
357
|
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
@@ -347,7 +359,7 @@ class p {
|
|
|
347
359
|
).rgb();
|
|
348
360
|
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
|
|
349
361
|
});
|
|
350
|
-
|
|
362
|
+
a(this, "hsluv", () => {
|
|
351
363
|
const t = new s();
|
|
352
364
|
t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), t.hsluv_l = this.lightness, t.hsluv_s = this.adjustChroma(
|
|
353
365
|
t.hsluv_s * (this.chromaShifting / 100)
|
|
@@ -359,7 +371,7 @@ class p {
|
|
|
359
371
|
];
|
|
360
372
|
return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
|
|
361
373
|
});
|
|
362
|
-
|
|
374
|
+
a(this, "hsluva", () => {
|
|
363
375
|
const t = new s();
|
|
364
376
|
t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), t.hsluv_s = this.adjustChroma(
|
|
365
377
|
t.hsluv_s * (this.chromaShifting / 100)
|
|
@@ -371,116 +383,166 @@ class p {
|
|
|
371
383
|
];
|
|
372
384
|
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
|
|
373
385
|
});
|
|
374
|
-
|
|
386
|
+
a(this, "hsv", () => {
|
|
387
|
+
const t = n(this.sourceColor).hsv(), h = n.hsv(
|
|
388
|
+
this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
|
|
389
|
+
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
390
|
+
this.lightness / 100
|
|
391
|
+
).rgb();
|
|
392
|
+
return this.render === "HEX" ? this.simulateColorBlindHex(h) : this.simulateColorBlindRgb(h);
|
|
393
|
+
});
|
|
394
|
+
a(this, "hsva", () => {
|
|
395
|
+
const t = n(this.sourceColor).hsv(), h = n.hsv(
|
|
396
|
+
this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
|
|
397
|
+
this.adjustChroma(t[1] * (this.chromaShifting / 100)),
|
|
398
|
+
t[2]
|
|
399
|
+
).rgb();
|
|
400
|
+
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(h), this.alpha).hex() : [...this.simulateColorBlindRgb(h), this.alpha];
|
|
401
|
+
});
|
|
402
|
+
a(this, "cmyk", () => {
|
|
403
|
+
const t = n(this.sourceColor).hsl(), [h, i, e] = n.hsl(
|
|
404
|
+
this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
|
|
405
|
+
t[1],
|
|
406
|
+
t[2]
|
|
407
|
+
).rgb(), [r, o, l] = _(h, i, e), u = Math.min(
|
|
408
|
+
1,
|
|
409
|
+
Math.max(0, this.adjustChroma(r * (this.chromaShifting / 100)))
|
|
410
|
+
), d = Math.min(
|
|
411
|
+
1,
|
|
412
|
+
Math.max(0, this.adjustChroma(o * (this.chromaShifting / 100)))
|
|
413
|
+
), C = Math.min(
|
|
414
|
+
1,
|
|
415
|
+
Math.max(0, this.adjustChroma(l * (this.chromaShifting / 100)))
|
|
416
|
+
), M = Math.min(1, Math.max(0, 1 - this.lightness / 100)), m = x(u, d, C, M);
|
|
417
|
+
return this.render === "HEX" ? this.simulateColorBlindHex(m) : this.simulateColorBlindRgb(m);
|
|
418
|
+
});
|
|
419
|
+
a(this, "cmyka", () => {
|
|
420
|
+
const t = n(this.sourceColor).hsl(), [h, i, e] = n.hsl(
|
|
421
|
+
this.adjustHue(Number.isNaN(t[0]) ? 0 : t[0]),
|
|
422
|
+
t[1],
|
|
423
|
+
t[2]
|
|
424
|
+
).rgb(), [r, o, l, u] = _(h, i, e), d = Math.min(
|
|
425
|
+
1,
|
|
426
|
+
Math.max(0, this.adjustChroma(r * (this.chromaShifting / 100)))
|
|
427
|
+
), C = Math.min(
|
|
428
|
+
1,
|
|
429
|
+
Math.max(0, this.adjustChroma(o * (this.chromaShifting / 100)))
|
|
430
|
+
), M = Math.min(
|
|
431
|
+
1,
|
|
432
|
+
Math.max(0, this.adjustChroma(l * (this.chromaShifting / 100)))
|
|
433
|
+
), m = x(d, C, M, u);
|
|
434
|
+
return this.render === "HEX" ? n.rgb(...this.simulateColorBlindRgb(m), this.alpha).hex() : [...this.simulateColorBlindRgb(m), this.alpha];
|
|
435
|
+
});
|
|
436
|
+
a(this, "getHsluv", () => {
|
|
375
437
|
const t = new s();
|
|
376
438
|
return t.rgb_r = this.sourceColor[0] / 255, t.rgb_g = this.sourceColor[1] / 255, t.rgb_b = this.sourceColor[2] / 255, t.rgbToHsluv(), [t.hsluv_h, t.hsluv_s, t.hsluv_l];
|
|
377
439
|
});
|
|
378
|
-
|
|
379
|
-
var
|
|
440
|
+
a(this, "simulateColorBlindHex", (t) => {
|
|
441
|
+
var e;
|
|
380
442
|
const h = {
|
|
381
443
|
NONE: () => n(t).hex(),
|
|
382
444
|
PROTANOMALY: () => {
|
|
383
|
-
const
|
|
445
|
+
const r = g(
|
|
384
446
|
t,
|
|
385
|
-
|
|
447
|
+
c.PROTANOMALY
|
|
386
448
|
);
|
|
387
|
-
return n(
|
|
449
|
+
return n(r).hex();
|
|
388
450
|
},
|
|
389
451
|
PROTANOPIA: () => {
|
|
390
|
-
const
|
|
452
|
+
const r = g(
|
|
391
453
|
t,
|
|
392
|
-
|
|
454
|
+
c.PROTANOPIA
|
|
393
455
|
);
|
|
394
|
-
return n(
|
|
456
|
+
return n(r).hex();
|
|
395
457
|
},
|
|
396
458
|
DEUTERANOMALY: () => {
|
|
397
|
-
const
|
|
459
|
+
const r = g(
|
|
398
460
|
t,
|
|
399
|
-
|
|
461
|
+
c.DEUTERANOMALY
|
|
400
462
|
);
|
|
401
|
-
return n(
|
|
463
|
+
return n(r).hex();
|
|
402
464
|
},
|
|
403
465
|
DEUTERANOPIA: () => {
|
|
404
|
-
const
|
|
466
|
+
const r = g(
|
|
405
467
|
t,
|
|
406
|
-
|
|
468
|
+
c.DEUTERANOPIA
|
|
407
469
|
);
|
|
408
|
-
return n(
|
|
470
|
+
return n(r).hex();
|
|
409
471
|
},
|
|
410
472
|
TRITANOMALY: () => {
|
|
411
|
-
const
|
|
473
|
+
const r = g(
|
|
412
474
|
t,
|
|
413
|
-
|
|
475
|
+
c.TRITANOMALY
|
|
414
476
|
);
|
|
415
|
-
return n(
|
|
477
|
+
return n(r).hex();
|
|
416
478
|
},
|
|
417
479
|
TRITANOPIA: () => {
|
|
418
|
-
const
|
|
480
|
+
const r = g(
|
|
419
481
|
t,
|
|
420
|
-
|
|
482
|
+
c.TRITANOPIA
|
|
421
483
|
);
|
|
422
|
-
return n(
|
|
484
|
+
return n(r).hex();
|
|
423
485
|
},
|
|
424
486
|
ACHROMATOMALY: () => {
|
|
425
|
-
const
|
|
487
|
+
const r = g(
|
|
426
488
|
t,
|
|
427
|
-
|
|
489
|
+
c.ACHROMATOMALY
|
|
428
490
|
);
|
|
429
|
-
return n(
|
|
491
|
+
return n(r).hex();
|
|
430
492
|
},
|
|
431
493
|
ACHROMATOPSIA: () => {
|
|
432
|
-
const
|
|
494
|
+
const r = g(
|
|
433
495
|
t,
|
|
434
|
-
|
|
496
|
+
c.ACHROMATOPSIA
|
|
435
497
|
);
|
|
436
|
-
return n(
|
|
498
|
+
return n(r).hex();
|
|
437
499
|
}
|
|
438
|
-
},
|
|
439
|
-
return
|
|
500
|
+
}, i = (e = h[this.visionSimulationMode]) == null ? void 0 : e.call(h);
|
|
501
|
+
return i !== void 0 ? i : "#000000";
|
|
440
502
|
});
|
|
441
|
-
|
|
442
|
-
var
|
|
503
|
+
a(this, "simulateColorBlindRgb", (t) => {
|
|
504
|
+
var e;
|
|
443
505
|
const h = {
|
|
444
506
|
NONE: () => n(t).rgb(),
|
|
445
|
-
PROTANOMALY: () =>
|
|
446
|
-
PROTANOPIA: () =>
|
|
447
|
-
DEUTERANOMALY: () =>
|
|
448
|
-
DEUTERANOPIA: () =>
|
|
449
|
-
TRITANOMALY: () =>
|
|
450
|
-
TRITANOPIA: () =>
|
|
451
|
-
ACHROMATOMALY: () =>
|
|
452
|
-
ACHROMATOPSIA: () =>
|
|
453
|
-
},
|
|
454
|
-
return
|
|
507
|
+
PROTANOMALY: () => g(t, c.PROTANOMALY),
|
|
508
|
+
PROTANOPIA: () => g(t, c.PROTANOPIA),
|
|
509
|
+
DEUTERANOMALY: () => g(t, c.DEUTERANOMALY),
|
|
510
|
+
DEUTERANOPIA: () => g(t, c.DEUTERANOPIA),
|
|
511
|
+
TRITANOMALY: () => g(t, c.TRITANOMALY),
|
|
512
|
+
TRITANOPIA: () => g(t, c.TRITANOPIA),
|
|
513
|
+
ACHROMATOMALY: () => g(t, c.ACHROMATOMALY),
|
|
514
|
+
ACHROMATOPSIA: () => g(t, c.ACHROMATOPSIA)
|
|
515
|
+
}, i = (e = h[this.visionSimulationMode]) == null ? void 0 : e.call(h);
|
|
516
|
+
return i !== void 0 ? i : [0, 0, 0];
|
|
455
517
|
});
|
|
456
|
-
|
|
457
|
-
const [
|
|
458
|
-
if (
|
|
459
|
-
if (
|
|
460
|
-
const M =
|
|
518
|
+
a(this, "mixColorsRgb", (t, h) => {
|
|
519
|
+
const [i, e, r, o] = t, [l, u, d, C] = h;
|
|
520
|
+
if (o === 1) return [i, e, r];
|
|
521
|
+
if (o === 0) return [l, u, d];
|
|
522
|
+
const M = o + C * (1 - o), m = Math.min(
|
|
461
523
|
255,
|
|
462
|
-
Math.max(0, Math.round((
|
|
463
|
-
),
|
|
524
|
+
Math.max(0, Math.round((i * o + l * C * (1 - o)) / M))
|
|
525
|
+
), f = Math.min(
|
|
464
526
|
255,
|
|
465
|
-
Math.max(0, Math.round((
|
|
466
|
-
),
|
|
527
|
+
Math.max(0, Math.round((e * o + u * C * (1 - o)) / M))
|
|
528
|
+
), T = Math.min(
|
|
467
529
|
255,
|
|
468
|
-
Math.max(0, Math.round((
|
|
530
|
+
Math.max(0, Math.round((r * o + d * C * (1 - o)) / M))
|
|
469
531
|
);
|
|
470
|
-
return this.simulateColorBlindRgb([
|
|
532
|
+
return this.simulateColorBlindRgb([m, f, T]);
|
|
471
533
|
});
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
if (!
|
|
475
|
-
if (!
|
|
476
|
-
const
|
|
477
|
-
return n(
|
|
534
|
+
a(this, "mixColorsHex", (t, h) => {
|
|
535
|
+
const i = /^#([0-9A-Fa-f]{3}){1,2}([0-9A-Fa-f]{2})?$/;
|
|
536
|
+
if (!i.test(t)) return t;
|
|
537
|
+
if (!i.test(h)) return h;
|
|
538
|
+
const e = n(t).rgba(), r = n(h).rgba(), o = this.mixColorsRgb(e, r);
|
|
539
|
+
return n(o).hex();
|
|
478
540
|
});
|
|
479
|
-
this.render = t, this.sourceColor = h, this.lightness =
|
|
541
|
+
this.render = t, this.sourceColor = h, this.lightness = i, this.alpha = e, this.hueShifting = r, this.chromaShifting = o, this.algorithmVersion = l, this.visionSimulationMode = u;
|
|
480
542
|
}
|
|
481
543
|
}
|
|
482
544
|
export {
|
|
483
|
-
|
|
545
|
+
O as C,
|
|
484
546
|
s as H
|
|
485
547
|
};
|
|
486
|
-
//# sourceMappingURL=color-
|
|
548
|
+
//# sourceMappingURL=color-S7JZ1G0L.js.map
|