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