@aviala-design/color 0.3.0 → 0.4.1
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/README.md +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +549 -315
- package/dist/linear.d.ts +9 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/theme-blend.d.ts +300 -26
- package/dist/theme-blend.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import b from "color";
|
|
2
|
+
function st(t) {
|
|
3
|
+
return b(t).rgb().round().color.join(",");
|
|
4
4
|
}
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return !t || !
|
|
5
|
+
const W = ["hex", "rgb", "hsl"];
|
|
6
|
+
function J(t) {
|
|
7
|
+
return !t || !W.includes(
|
|
8
8
|
/** @type {any} */
|
|
9
9
|
t
|
|
10
10
|
) ? "hex" : (
|
|
@@ -12,432 +12,656 @@ function z(t) {
|
|
|
12
12
|
t
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
return
|
|
15
|
+
function E(t, n) {
|
|
16
|
+
const r = J(n);
|
|
17
|
+
return r === "hex" ? t[r]().toLowerCase() : t[r]().round().string();
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
return o >= 60 && o <= 240 ?
|
|
19
|
+
function T(t, n, r) {
|
|
20
|
+
const e = b(t), o = e.hue(), s = e.saturationv(), a = e.value(), i = ((p) => p >= 60 && p <= 240 ? 2.5 : p >= 0 && p < 60 || p > 300 && p <= 360 ? 1.5 : 2)(o), h = 100, f = 9, u = 100, l = 30;
|
|
21
|
+
function m(p, x) {
|
|
22
|
+
let y;
|
|
23
|
+
return o >= 60 && o <= 240 ? y = p ? o - i * x : o + i * x : y = p ? o + i * x : o - i * x, y < 0 ? y += 360 : y >= 360 && (y -= 360), Math.round(y);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
25
|
+
function d(p, x) {
|
|
26
|
+
let y;
|
|
27
27
|
if (p)
|
|
28
|
-
|
|
28
|
+
y = s <= f ? s : s - (s - f) / 5.5 * Math.pow(x, 1.05);
|
|
29
29
|
else {
|
|
30
|
-
const v = Math.min(
|
|
31
|
-
|
|
30
|
+
const v = Math.min(h, s + 30);
|
|
31
|
+
y = s + (v - s) / 4.2 * Math.pow(x, 0.95);
|
|
32
32
|
}
|
|
33
|
-
return Math.max(0, Math.min(100,
|
|
33
|
+
return Math.max(0, Math.min(100, y));
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return p ? Math.min(u,
|
|
35
|
+
function M(p, x) {
|
|
36
|
+
return p ? Math.min(u, a + (u - a) / 5.2 * Math.pow(x, 0.9)) : a <= l ? a : Math.max(l, a - (a - l) / 4.2 * Math.pow(x, 1.05));
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
h:
|
|
40
|
-
s:
|
|
41
|
-
v: g
|
|
38
|
+
const g = n < 6, w = g ? 6 - n : n - 6, L = n === 6 ? e : b({
|
|
39
|
+
h: m(g, w),
|
|
40
|
+
s: d(g, w),
|
|
41
|
+
v: M(g, w)
|
|
42
42
|
});
|
|
43
|
-
return L
|
|
44
|
-
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
function
|
|
48
|
-
if (
|
|
49
|
-
return
|
|
50
|
-
if (
|
|
43
|
+
return E(L, r);
|
|
44
|
+
}
|
|
45
|
+
function q(t, n, r) {
|
|
46
|
+
const e = b(T(t, 10 - n + 1, "hex")), o = b(t), s = o.hue(), a = o.saturationv();
|
|
47
|
+
function c(m) {
|
|
48
|
+
if (m < 6)
|
|
49
|
+
return h + (6 - m) * u;
|
|
50
|
+
if (m === 6) {
|
|
51
51
|
if (s >= 0 && s < 50)
|
|
52
|
-
return
|
|
52
|
+
return a - 15;
|
|
53
53
|
if (s >= 50 && s < 191)
|
|
54
|
-
return
|
|
54
|
+
return a - 20;
|
|
55
55
|
if (s >= 191 && s <= 360)
|
|
56
|
-
return
|
|
56
|
+
return a - 15;
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return h - f * (m - 6);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const h = b({
|
|
61
61
|
h: o.hue(),
|
|
62
|
-
s:
|
|
62
|
+
s: c(6),
|
|
63
63
|
v: o.value()
|
|
64
|
-
}).saturationv(), f = Math.ceil((
|
|
65
|
-
h:
|
|
66
|
-
s:
|
|
67
|
-
v:
|
|
64
|
+
}).saturationv(), f = Math.ceil((h - 9) / 4), u = Math.ceil((100 - h) / 5), l = b({
|
|
65
|
+
h: e.hue(),
|
|
66
|
+
s: c(n),
|
|
67
|
+
v: e.value()
|
|
68
68
|
});
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
function
|
|
72
|
-
const { dark:
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
for (let
|
|
76
|
-
|
|
77
|
-
return
|
|
69
|
+
return E(l, r);
|
|
70
|
+
}
|
|
71
|
+
function P(t, n = {}) {
|
|
72
|
+
const { dark: r, list: e, index: o = 6, format: s = "hex" } = n;
|
|
73
|
+
if (e) {
|
|
74
|
+
const a = [], c = r ? q : T;
|
|
75
|
+
for (let i = 1; i <= 10; i++)
|
|
76
|
+
a.push(c(t, i, s));
|
|
77
|
+
return a;
|
|
78
78
|
}
|
|
79
|
-
return
|
|
79
|
+
return r ? q(t, o, s) : T(t, o, s);
|
|
80
80
|
}
|
|
81
|
-
async function
|
|
81
|
+
async function Q(t) {
|
|
82
82
|
try {
|
|
83
|
-
const n = await
|
|
84
|
-
return
|
|
83
|
+
const n = await X(t), r = Y(n);
|
|
84
|
+
return Z(r);
|
|
85
85
|
} catch (n) {
|
|
86
86
|
throw console.error("提取图片颜色失败:", n), n;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
return new Promise((n,
|
|
89
|
+
async function X(t) {
|
|
90
|
+
return new Promise((n, r) => {
|
|
91
91
|
try {
|
|
92
92
|
if (typeof document > "u") {
|
|
93
|
-
|
|
93
|
+
r(new Error("图像颜色提取功能仅在浏览器环境中可用"));
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const e = document.createElement("canvas"), o = e.getContext("2d");
|
|
97
97
|
if (!o) {
|
|
98
|
-
|
|
98
|
+
r(new Error("无法获取canvas 2d context"));
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
const s = Math.min(t.width, 100),
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
n(
|
|
105
|
-
} catch (
|
|
106
|
-
|
|
101
|
+
const s = Math.min(t.width, 100), a = Math.min(t.height, 100), c = Math.min(s / t.width, a / t.height);
|
|
102
|
+
e.width = t.width * c, e.height = t.height * c, o.drawImage(t, 0, 0, e.width, e.height);
|
|
103
|
+
const i = o.getImageData(0, 0, e.width, e.height);
|
|
104
|
+
n(i);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
r(e);
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
const n = t.data,
|
|
110
|
+
function Y(t) {
|
|
111
|
+
const n = t.data, r = /* @__PURE__ */ new Map();
|
|
112
112
|
for (let o = 0; o < n.length; o += 4) {
|
|
113
|
-
const s = n[o],
|
|
113
|
+
const s = n[o], a = n[o + 1], c = n[o + 2];
|
|
114
114
|
if (n[o + 3] < 128) continue;
|
|
115
|
-
const
|
|
116
|
-
|
|
115
|
+
const h = Math.round(s / 16) * 16, f = Math.round(a / 16) * 16, u = Math.round(c / 16) * 16, l = `${h},${f},${u}`;
|
|
116
|
+
r.has(l) ? r.set(l, r.get(l) + 1) : r.set(l, 1);
|
|
117
117
|
}
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
const [
|
|
121
|
-
|
|
122
|
-
}),
|
|
118
|
+
const e = [];
|
|
119
|
+
return r.forEach((o, s) => {
|
|
120
|
+
const [a, c, i] = s.split(",").map(Number);
|
|
121
|
+
e.push({ r: a, g: c, b: i, count: o });
|
|
122
|
+
}), e;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function Z(t) {
|
|
125
125
|
t.sort((o, s) => s.count - o.count);
|
|
126
126
|
const n = t.filter((o) => {
|
|
127
|
-
const { r: s, g:
|
|
128
|
-
return u > 0.15 &&
|
|
129
|
-
}),
|
|
130
|
-
return
|
|
127
|
+
const { r: s, g: a, b: c } = o, i = Math.max(s, a, c), h = Math.min(s, a, c), f = i - h, u = i === 0 ? 0 : f / i, l = i / 255;
|
|
128
|
+
return u > 0.15 && l > 0.2 && l < 0.8;
|
|
129
|
+
}), r = n.length > 0 ? n[0] : t[0];
|
|
130
|
+
return b({ r: r.r, g: r.g, b: r.b }).hex();
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return new Promise((n,
|
|
132
|
+
function at(t) {
|
|
133
|
+
return new Promise((n, r) => {
|
|
134
134
|
if (typeof FileReader > "u" || typeof Image > "u") {
|
|
135
|
-
|
|
135
|
+
r(new Error("文件读取功能仅在浏览器环境中可用"));
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
if (!t.type.startsWith("image/")) {
|
|
139
|
-
|
|
139
|
+
r(new Error("请选择图片文件"));
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
142
|
+
const e = new FileReader();
|
|
143
|
+
e.onload = async (o) => {
|
|
144
144
|
var s;
|
|
145
145
|
try {
|
|
146
|
-
const
|
|
147
|
-
|
|
146
|
+
const a = new Image();
|
|
147
|
+
a.onload = async () => {
|
|
148
148
|
try {
|
|
149
|
-
const
|
|
150
|
-
n(
|
|
151
|
-
} catch (
|
|
152
|
-
|
|
149
|
+
const i = await Q(a);
|
|
150
|
+
n(i);
|
|
151
|
+
} catch (i) {
|
|
152
|
+
r(i);
|
|
153
153
|
}
|
|
154
|
-
},
|
|
155
|
-
const
|
|
156
|
-
typeof
|
|
157
|
-
} catch (
|
|
158
|
-
|
|
154
|
+
}, a.onerror = () => r(new Error("图片加载失败"));
|
|
155
|
+
const c = (s = o.target) == null ? void 0 : s.result;
|
|
156
|
+
typeof c == "string" ? a.src = c : r(new Error("无法读取图片数据"));
|
|
157
|
+
} catch (a) {
|
|
158
|
+
r(a);
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, e.onerror = () => r(new Error("文件读取失败")), e.readAsDataURL(t);
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
const { steps:
|
|
165
|
-
if (
|
|
163
|
+
function O(t, n, r = {}) {
|
|
164
|
+
const { steps: e = 10, format: o = "hex", includeEnds: s = !0 } = r;
|
|
165
|
+
if (e < 2)
|
|
166
166
|
throw new Error("步数必须至少为2");
|
|
167
|
-
const
|
|
168
|
-
for (let u = 0; u <
|
|
169
|
-
const
|
|
170
|
-
!s && (u === 0 || u ===
|
|
167
|
+
const a = b(t), c = b(n), i = [], h = s ? e : e + 2, f = 1 / (h - 1);
|
|
168
|
+
for (let u = 0; u < h; u++) {
|
|
169
|
+
const l = u * f, m = Math.round(a.red() + (c.red() - a.red()) * l), d = Math.round(a.green() + (c.green() - a.green()) * l), M = Math.round(a.blue() + (c.blue() - a.blue()) * l), g = b({ r: m, g: d, b: M });
|
|
170
|
+
!s && (u === 0 || u === h - 1) || i.push(E(g, o));
|
|
171
171
|
}
|
|
172
|
-
return
|
|
172
|
+
return i;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function it(t = {}) {
|
|
175
175
|
const {
|
|
176
176
|
startGray: n = "#ffffff",
|
|
177
|
-
endGray:
|
|
178
|
-
steps:
|
|
177
|
+
endGray: r = "#000000",
|
|
178
|
+
steps: e = 10,
|
|
179
179
|
format: o = "hex"
|
|
180
180
|
} = t;
|
|
181
|
-
return
|
|
181
|
+
return O(n, r, { steps: e, format: o, includeEnds: !0 });
|
|
182
182
|
}
|
|
183
|
-
function
|
|
183
|
+
function I(t, n = {}) {
|
|
184
184
|
const {
|
|
185
|
-
steps:
|
|
186
|
-
format:
|
|
185
|
+
steps: r = 10,
|
|
186
|
+
format: e = "hex",
|
|
187
187
|
lightnessRange: o = 80,
|
|
188
188
|
minLightness: s = null,
|
|
189
|
-
maxLightness:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
maxLightness: a = null,
|
|
190
|
+
preserveChroma: c = !1
|
|
191
|
+
} = n, i = b(t);
|
|
192
|
+
let h, f;
|
|
193
|
+
if (s !== null && a !== null) {
|
|
194
|
+
if (s > a)
|
|
194
195
|
throw new Error("minLightness 不能大于 maxLightness");
|
|
195
|
-
|
|
196
|
+
h = Math.max(0, Math.min(100, a)), f = Math.max(0, Math.min(100, s));
|
|
196
197
|
} else {
|
|
197
|
-
const
|
|
198
|
-
|
|
198
|
+
const m = i.lightness();
|
|
199
|
+
h = Math.min(95, m + o / 2), f = Math.max(5, m - o / 2);
|
|
199
200
|
}
|
|
200
|
-
|
|
201
|
+
if (c)
|
|
202
|
+
return _(i, h, f, r, e);
|
|
203
|
+
const u = b({
|
|
201
204
|
h: i.hue(),
|
|
202
205
|
s: i.saturationl(),
|
|
203
|
-
l:
|
|
204
|
-
}),
|
|
206
|
+
l: h
|
|
207
|
+
}), l = b({
|
|
205
208
|
h: i.hue(),
|
|
206
209
|
s: i.saturationl(),
|
|
207
|
-
l
|
|
210
|
+
l: f
|
|
208
211
|
});
|
|
209
|
-
return
|
|
212
|
+
return O(u.hex(), l.hex(), { steps: r, format: e, includeEnds: !0 });
|
|
210
213
|
}
|
|
211
|
-
function
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
+
function _(t, n, r, e, o) {
|
|
215
|
+
const s = t.a(), a = t.b(), c = Math.sqrt(s * s + a * a), i = Math.atan2(a, s), h = [], f = (n - r) / (e - 1);
|
|
216
|
+
for (let u = 0; u < e; u++) {
|
|
217
|
+
const l = n - f * u;
|
|
218
|
+
let m = c;
|
|
219
|
+
if (l > 85) {
|
|
220
|
+
const p = Math.max(0, (100 - l) / 15);
|
|
221
|
+
m = c * p;
|
|
222
|
+
} else if (l < 15) {
|
|
223
|
+
const p = Math.max(0, l / 15);
|
|
224
|
+
m = c * p;
|
|
225
|
+
}
|
|
226
|
+
const d = m * Math.cos(i), M = m * Math.sin(i);
|
|
227
|
+
let g = b.lab(l, d, M), w = g.rgb().array(), L = m;
|
|
228
|
+
for (; (w[0] < 0 || w[0] > 255 || w[1] < 0 || w[1] > 255 || w[2] < 0 || w[2] > 255) && L > 0; ) {
|
|
229
|
+
L -= 1;
|
|
230
|
+
const p = L * Math.cos(i), x = L * Math.sin(i);
|
|
231
|
+
g = b.lab(l, p, x), w = g.rgb().array();
|
|
232
|
+
}
|
|
233
|
+
h.push(E(g, o));
|
|
234
|
+
}
|
|
235
|
+
return h;
|
|
236
|
+
}
|
|
237
|
+
function ct(t, n, r = {}) {
|
|
238
|
+
const { steps: e = 10, format: o = "hex", includeEnds: s = !0 } = r;
|
|
239
|
+
if (e < 2)
|
|
214
240
|
throw new Error("步数必须至少为2");
|
|
215
|
-
const
|
|
216
|
-
let u =
|
|
217
|
-
const
|
|
218
|
-
Math.abs(
|
|
219
|
-
const
|
|
220
|
-
for (let
|
|
221
|
-
const p =
|
|
222
|
-
let
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
const A =
|
|
226
|
-
!s && (
|
|
241
|
+
const a = b(t), c = b(n), i = [], h = s ? e : e + 2, f = 1 / (h - 1);
|
|
242
|
+
let u = a.hue() || 0, l = c.hue() || 0;
|
|
243
|
+
const m = l - u;
|
|
244
|
+
Math.abs(m) > 180 && (m > 0 ? u += 360 : l += 360);
|
|
245
|
+
const d = a.saturationl(), M = c.saturationl(), g = a.lightness(), w = c.lightness();
|
|
246
|
+
for (let L = 0; L < h; L++) {
|
|
247
|
+
const p = L * f;
|
|
248
|
+
let x = u + (l - u) * p;
|
|
249
|
+
const y = d + (M - d) * p, v = g + (w - g) * p;
|
|
250
|
+
x = x % 360, x < 0 && (x += 360);
|
|
251
|
+
const A = b({ h: x, s: y, l: v });
|
|
252
|
+
!s && (L === 0 || L === h - 1) || i.push(E(A, o));
|
|
227
253
|
}
|
|
228
|
-
return
|
|
254
|
+
return i;
|
|
229
255
|
}
|
|
230
|
-
function
|
|
256
|
+
function R(t) {
|
|
231
257
|
if (!t || typeof t != "string")
|
|
232
258
|
throw new Error("Invalid RGB color: must be a string");
|
|
233
|
-
let n
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
259
|
+
let n;
|
|
260
|
+
try {
|
|
261
|
+
n = b(t);
|
|
262
|
+
} catch {
|
|
263
|
+
throw new Error("Invalid RGB color format");
|
|
264
|
+
}
|
|
265
|
+
const r = n.l(), e = n.a(), o = n.b();
|
|
266
|
+
let s = Math.atan2(o, e) * (180 / Math.PI);
|
|
267
|
+
s < 0 && (s += 360);
|
|
268
|
+
const a = Math.sqrt(e * e + o * o);
|
|
269
|
+
return {
|
|
270
|
+
h: s,
|
|
271
|
+
c: a,
|
|
272
|
+
t: r
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function C(t, n = {}) {
|
|
246
276
|
if (!t || typeof t != "object" || t.h === void 0 || t.c === void 0 || t.t === void 0)
|
|
247
277
|
throw new Error("Invalid HCT color: must be an object with h, c, t properties");
|
|
248
|
-
const {
|
|
249
|
-
let
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
278
|
+
const { gamutMapping: r = "reduce-chroma" } = n;
|
|
279
|
+
let { h: e, c: o, t: s } = t;
|
|
280
|
+
e = (e % 360 + 360) % 360, o = Math.max(0, o), s = Math.max(0, Math.min(100, s));
|
|
281
|
+
const a = e * (Math.PI / 180), c = o * Math.cos(a), i = o * Math.sin(a);
|
|
282
|
+
try {
|
|
283
|
+
let h = b.lab(s, c, i);
|
|
284
|
+
if (r === "reduce-chroma") {
|
|
285
|
+
let d = o, M = h.rgb().array();
|
|
286
|
+
for (; (M[0] < 0 || M[0] > 255 || M[1] < 0 || M[1] > 255 || M[2] < 0 || M[2] > 255) && d > 0; ) {
|
|
287
|
+
d -= 1;
|
|
288
|
+
const g = d * Math.cos(a), w = d * Math.sin(a);
|
|
289
|
+
h = b.lab(s, g, w), M = h.rgb().array();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const f = h.rgb().array(), u = Math.max(0, Math.min(255, Math.round(f[0]))), l = Math.max(0, Math.min(255, Math.round(f[1]))), m = Math.max(0, Math.min(255, Math.round(f[2])));
|
|
293
|
+
return `#${u.toString(16).padStart(2, "0")}${l.toString(16).padStart(2, "0")}${m.toString(16).padStart(2, "0")}`;
|
|
294
|
+
} catch {
|
|
295
|
+
return b.lab(s, c, i).hex().toLowerCase();
|
|
253
296
|
}
|
|
254
|
-
const u = (1 - Math.abs(2 * l - 1)) * Math.min(1, f), h = u * (1 - Math.abs(e / 60 % 2 - 1)), d = l - u / 2;
|
|
255
|
-
let M, g, m;
|
|
256
|
-
e >= 0 && e < 60 ? [M, g, m] = [u, h, 0] : e >= 60 && e < 120 ? [M, g, m] = [h, u, 0] : e >= 120 && e < 180 ? [M, g, m] = [0, u, h] : e >= 180 && e < 240 ? [M, g, m] = [0, h, u] : e >= 240 && e < 300 ? [M, g, m] = [h, 0, u] : [M, g, m] = [u, 0, h];
|
|
257
|
-
const E = (y) => {
|
|
258
|
-
const p = Math.max(0, Math.min(1, y + d)), b = Math.round(p * 255).toString(16);
|
|
259
|
-
return b.length === 1 ? "0" + b : b;
|
|
260
|
-
};
|
|
261
|
-
return `#${E(M)}${E(g)}${E(m)}`;
|
|
262
297
|
}
|
|
263
|
-
function
|
|
298
|
+
function $(t, n, r = 0.5, e = {}) {
|
|
264
299
|
if (!t || !n)
|
|
265
300
|
throw new Error("Both colors are required for blending");
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
301
|
+
const { mode: o = "lab" } = e, s = Math.max(0, Math.min(1, r));
|
|
302
|
+
return o === "lab" ? tt(t, n, s) : o === "hue-only" ? j(t, n, s) : nt(t, n, s);
|
|
303
|
+
}
|
|
304
|
+
function tt(t, n, r) {
|
|
305
|
+
const e = b(t), o = b(n), s = e.l(), a = e.a(), c = e.b(), i = o.l(), h = o.a(), f = o.b(), u = s + (i - s) * r, l = a + (h - a) * r, m = c + (f - c) * r;
|
|
306
|
+
return b.lab(u, l, m).hex().toLowerCase();
|
|
307
|
+
}
|
|
308
|
+
function nt(t, n, r) {
|
|
309
|
+
const e = R(t), o = R(n), s = k(e.h, o.h, r), a = e.c + (o.c - e.c) * r, c = e.t + (o.t - e.t) * r;
|
|
310
|
+
return C({
|
|
311
|
+
h: s,
|
|
312
|
+
c: Math.max(0, a),
|
|
313
|
+
t: Math.max(0, Math.min(100, c))
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function j(t, n, r) {
|
|
317
|
+
const e = R(t), o = R(n), s = k(e.h, o.h, r);
|
|
318
|
+
return C({
|
|
319
|
+
h: s,
|
|
320
|
+
c: e.c,
|
|
321
|
+
// 保持第一个颜色的色度
|
|
322
|
+
t: e.t
|
|
323
|
+
// 保持第一个颜色的明度
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function k(t, n, r) {
|
|
327
|
+
let e = n - t;
|
|
328
|
+
e > 180 ? e -= 360 : e < -180 && (e += 360);
|
|
329
|
+
let o = t + e * r;
|
|
330
|
+
return o < 0 && (o += 360), o >= 360 && (o -= 360), o;
|
|
331
|
+
}
|
|
332
|
+
function lt(t, n) {
|
|
333
|
+
const r = b(t), e = b(n), o = r.l(), s = r.a(), a = r.b(), c = e.l(), i = e.a(), h = e.b();
|
|
334
|
+
return Math.sqrt(
|
|
335
|
+
Math.pow(c - o, 2) + Math.pow(i - s, 2) + Math.pow(h - a, 2)
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
function ht(t, n) {
|
|
339
|
+
const r = R(t);
|
|
340
|
+
return C({
|
|
341
|
+
h: r.h,
|
|
342
|
+
c: r.c,
|
|
343
|
+
t: Math.max(0, Math.min(100, n))
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function ut(t, n) {
|
|
347
|
+
const r = R(t);
|
|
348
|
+
return C({
|
|
349
|
+
h: r.h,
|
|
350
|
+
c: Math.max(0, n),
|
|
351
|
+
t: r.t
|
|
274
352
|
});
|
|
275
353
|
}
|
|
276
|
-
function
|
|
354
|
+
function ft(t, n) {
|
|
355
|
+
const r = R(t);
|
|
356
|
+
return C({
|
|
357
|
+
h: (n % 360 + 360) % 360,
|
|
358
|
+
c: r.c,
|
|
359
|
+
t: r.t
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function S(t, n) {
|
|
363
|
+
const r = R(t);
|
|
364
|
+
let e = r.h + n;
|
|
365
|
+
return e = (e % 360 + 360) % 360, C({
|
|
366
|
+
h: e,
|
|
367
|
+
c: r.c,
|
|
368
|
+
t: r.t
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function mt(t) {
|
|
372
|
+
return S(t, 180);
|
|
373
|
+
}
|
|
374
|
+
function dt(t) {
|
|
375
|
+
return [
|
|
376
|
+
t,
|
|
377
|
+
S(t, 120),
|
|
378
|
+
S(t, 240)
|
|
379
|
+
];
|
|
380
|
+
}
|
|
381
|
+
function gt(t, n = 30) {
|
|
382
|
+
return [
|
|
383
|
+
t,
|
|
384
|
+
S(t, 180 - n),
|
|
385
|
+
S(t, 180 + n)
|
|
386
|
+
];
|
|
387
|
+
}
|
|
388
|
+
function Mt(t, n = 3, r = 30) {
|
|
389
|
+
const e = [], o = -r * Math.floor(n / 2);
|
|
390
|
+
for (let s = 0; s < n; s++)
|
|
391
|
+
e.push(S(t, o + r * s));
|
|
392
|
+
return e;
|
|
393
|
+
}
|
|
394
|
+
function pt(t, n, r = 0.15) {
|
|
277
395
|
if (!t || !n)
|
|
278
396
|
throw new Error("Both theme color and target color are required");
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
Math.abs(a) > 180 && (a > 0 ? e += 360 : i += 360, a = i - e);
|
|
282
|
-
const l = (e + a * r) % 360;
|
|
283
|
-
return R({
|
|
284
|
-
h: l < 0 ? l + 360 : l,
|
|
285
|
-
c: s.c,
|
|
286
|
-
// 保持原有色度
|
|
287
|
-
t: s.t
|
|
288
|
-
// 保持原有色调
|
|
289
|
-
});
|
|
397
|
+
const e = Math.max(0, Math.min(1, r));
|
|
398
|
+
return j(n, t, e);
|
|
290
399
|
}
|
|
291
|
-
function
|
|
400
|
+
function bt(t, n) {
|
|
292
401
|
if (!t)
|
|
293
402
|
throw new Error("Theme color is required");
|
|
294
|
-
const
|
|
295
|
-
let
|
|
296
|
-
if (Array.isArray(n) ?
|
|
403
|
+
const r = R(t);
|
|
404
|
+
let e;
|
|
405
|
+
if (Array.isArray(n) ? e = n : n && n.tones && Array.isArray(n.tones) ? e = n.tones : e = [10, 20, 30, 40, 50, 60, 70, 80, 90], !Array.isArray(e) || e.length === 0)
|
|
297
406
|
throw new Error("Tone steps must be a non-empty array");
|
|
298
|
-
const o =
|
|
407
|
+
const o = e.filter((s) => typeof s == "number" && s >= 0 && s <= 100);
|
|
299
408
|
if (o.length === 0)
|
|
300
409
|
throw new Error("No valid tone values found (must be numbers between 0-100)");
|
|
301
|
-
return o.map((s) =>
|
|
302
|
-
h:
|
|
303
|
-
c:
|
|
410
|
+
return o.map((s) => C({
|
|
411
|
+
h: r.h,
|
|
412
|
+
c: r.c,
|
|
304
413
|
t: s
|
|
305
414
|
}));
|
|
306
415
|
}
|
|
307
|
-
function
|
|
416
|
+
function et(t, n, r = 0.2) {
|
|
308
417
|
if (!t)
|
|
309
418
|
throw new Error("Theme color is required");
|
|
310
419
|
if (!n || typeof n != "object")
|
|
311
420
|
throw new Error("UI colors must be an object");
|
|
312
|
-
const
|
|
313
|
-
for (const [s,
|
|
421
|
+
const e = Math.max(0, Math.min(1, r)), o = {};
|
|
422
|
+
for (const [s, a] of Object.entries(n))
|
|
314
423
|
try {
|
|
315
|
-
o[s] =
|
|
316
|
-
} catch (
|
|
424
|
+
o[s] = $(t, a, e);
|
|
425
|
+
} catch (c) {
|
|
317
426
|
console.warn(`Failed to blend color for key "${s}": ${/** @type {Error} */
|
|
318
|
-
|
|
427
|
+
c.message}`), o[s] = a;
|
|
319
428
|
}
|
|
320
429
|
return o;
|
|
321
430
|
}
|
|
322
|
-
function
|
|
431
|
+
function z(t, n = {}) {
|
|
323
432
|
if (!t)
|
|
324
433
|
throw new Error("Theme color is required");
|
|
325
434
|
const {
|
|
326
|
-
baseGray:
|
|
327
|
-
blendRatio:
|
|
435
|
+
baseGray: r = "#989898",
|
|
436
|
+
blendRatio: e = 0.08,
|
|
328
437
|
isDark: o = !1,
|
|
329
438
|
steps: s = 12,
|
|
330
439
|
// 默认 12 个等级,可以增加到 24、36 等以获得更细腻的梯度
|
|
331
|
-
lightnessRange:
|
|
440
|
+
lightnessRange: a = 85,
|
|
332
441
|
// 亮度变化范围(中心扩展模式),默认 85
|
|
333
|
-
minLightness:
|
|
442
|
+
minLightness: c = null,
|
|
334
443
|
// 最小亮度(固定端点模式),优先级高于 lightnessRange
|
|
335
|
-
maxLightness:
|
|
444
|
+
maxLightness: i = null
|
|
336
445
|
// 最大亮度(固定端点模式),优先级高于 lightnessRange
|
|
337
|
-
} = n,
|
|
446
|
+
} = n, h = Math.max(0, Math.min(1, e)), f = Math.max(2, Math.min(100, Math.round(s))), u = $(r, t, h), l = {
|
|
338
447
|
steps: f,
|
|
339
448
|
format: "hex"
|
|
340
449
|
};
|
|
341
|
-
if (
|
|
342
|
-
|
|
450
|
+
if (c !== null && i !== null)
|
|
451
|
+
l.minLightness = c, l.maxLightness = i;
|
|
343
452
|
else {
|
|
344
|
-
const
|
|
345
|
-
|
|
453
|
+
const g = Math.max(20, Math.min(95, a));
|
|
454
|
+
l.lightnessRange = g;
|
|
346
455
|
}
|
|
347
|
-
const
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
}),
|
|
456
|
+
const m = I(u, l), d = o ? m.reverse() : m, M = {};
|
|
457
|
+
return d.forEach((g, w) => {
|
|
458
|
+
M[`gray-${w + 1}`] = g;
|
|
459
|
+
}), M;
|
|
460
|
+
}
|
|
461
|
+
function rt(t, n = {}) {
|
|
462
|
+
if (!t)
|
|
463
|
+
throw new Error("Theme color is required");
|
|
464
|
+
const {
|
|
465
|
+
baseGray: r = "#f5f5f5",
|
|
466
|
+
// 使用浅灰作为基础,比控件色更浅
|
|
467
|
+
blendRatio: e = 0.03,
|
|
468
|
+
// 较低的混合比例,保持中性但带有品牌色调
|
|
469
|
+
steps: o = 6,
|
|
470
|
+
// 默认 6 个等级
|
|
471
|
+
minLightness: s = 92,
|
|
472
|
+
// 最深的浅灰亮度
|
|
473
|
+
maxLightness: a = 100,
|
|
474
|
+
// 最浅接近白色
|
|
475
|
+
prefix: c = "neutral"
|
|
476
|
+
// 颜色名称前缀
|
|
477
|
+
} = n, i = Math.max(0, Math.min(1, e)), h = Math.max(2, Math.min(20, Math.round(o))), f = Math.max(80, Math.min(99, s)), u = Math.max(f + 1, Math.min(100, a)), l = $(r, t, i), m = I(l, {
|
|
478
|
+
steps: h,
|
|
479
|
+
format: "hex",
|
|
480
|
+
minLightness: f,
|
|
481
|
+
maxLightness: u
|
|
482
|
+
}), d = {};
|
|
483
|
+
return m.forEach((M, g) => {
|
|
484
|
+
d[`${c}-${g + 1}`] = M;
|
|
485
|
+
}), d;
|
|
351
486
|
}
|
|
352
|
-
function
|
|
487
|
+
function G(t, n = {}) {
|
|
353
488
|
if (!t)
|
|
354
489
|
throw new Error("Theme color is required");
|
|
355
490
|
const {
|
|
356
|
-
semanticColors:
|
|
491
|
+
semanticColors: r = {
|
|
357
492
|
success: "#52c41a",
|
|
358
493
|
warning: "#faad14",
|
|
359
494
|
error: "#ff4d4f",
|
|
360
495
|
info: "#1890ff"
|
|
361
496
|
},
|
|
362
|
-
blendRatio:
|
|
363
|
-
isDark: o = !1
|
|
497
|
+
blendRatio: e = 0,
|
|
498
|
+
isDark: o = !1,
|
|
499
|
+
steps: s = 10,
|
|
500
|
+
// 默认生成 10 个色阶
|
|
501
|
+
lightnessRange: a = 80,
|
|
502
|
+
// 亮度变化范围(中心扩展模式)
|
|
503
|
+
minLightness: c = 8,
|
|
504
|
+
// 最小亮度(固定端点模式)- 默认接近黑色
|
|
505
|
+
maxLightness: i = 97,
|
|
506
|
+
// 最大亮度(固定端点模式)- 默认接近白色
|
|
507
|
+
preserveChroma: h = !0
|
|
508
|
+
// 默认保持色度,避免灰蒙蒙
|
|
364
509
|
} = n;
|
|
365
|
-
if (!
|
|
510
|
+
if (!r || typeof r != "object")
|
|
366
511
|
throw new Error("Semantic colors must be an object");
|
|
367
|
-
const
|
|
368
|
-
return Object.entries(
|
|
369
|
-
if (!
|
|
370
|
-
console.warn(`Invalid color for semantic color "${
|
|
512
|
+
const f = Math.max(0, Math.min(1, e)), u = Math.max(2, Math.min(100, Math.round(s))), l = {};
|
|
513
|
+
return Object.entries(r).forEach(([m, d]) => {
|
|
514
|
+
if (!d || typeof d != "string") {
|
|
515
|
+
console.warn(`Invalid color for semantic color "${m}": ${d}`);
|
|
371
516
|
return;
|
|
372
517
|
}
|
|
373
518
|
try {
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
519
|
+
const M = $(d, t, f), g = {
|
|
520
|
+
steps: u,
|
|
521
|
+
format: "hex",
|
|
522
|
+
preserveChroma: h
|
|
523
|
+
// 保持色度,避免灰蒙蒙
|
|
524
|
+
};
|
|
525
|
+
if (c !== null && i !== null)
|
|
526
|
+
g.minLightness = c, g.maxLightness = i;
|
|
527
|
+
else {
|
|
528
|
+
const p = Math.max(20, Math.min(95, a));
|
|
529
|
+
g.lightnessRange = p;
|
|
530
|
+
}
|
|
531
|
+
const w = I(M, g);
|
|
532
|
+
(o ? w.reverse() : w).forEach((p, x) => {
|
|
533
|
+
l[`${m}-${x + 1}`] = p;
|
|
534
|
+
});
|
|
535
|
+
} catch (M) {
|
|
536
|
+
console.warn(`Failed to generate variants for semantic color "${m}": ${/** @type {Error} */
|
|
537
|
+
M.message}`);
|
|
382
538
|
}
|
|
383
|
-
}),
|
|
539
|
+
}), l;
|
|
384
540
|
}
|
|
385
|
-
function
|
|
541
|
+
function N(t, n = {}) {
|
|
386
542
|
if (!t)
|
|
387
543
|
throw new Error("Theme color is required");
|
|
388
|
-
const {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
544
|
+
const {
|
|
545
|
+
isDark: r = !1,
|
|
546
|
+
steps: e = 10,
|
|
547
|
+
// 默认生成 10 个色阶
|
|
548
|
+
lightnessRange: o = 80,
|
|
549
|
+
// 亮度变化范围(中心扩展模式)
|
|
550
|
+
minLightness: s = 8,
|
|
551
|
+
// 最小亮度(固定端点模式)- 默认接近黑色
|
|
552
|
+
maxLightness: a = 97,
|
|
553
|
+
// 最大亮度(固定端点模式)- 默认接近白色
|
|
554
|
+
preserveChroma: c = !0
|
|
555
|
+
// 默认保持色度
|
|
556
|
+
} = n, h = {
|
|
557
|
+
steps: Math.max(2, Math.min(100, Math.round(e))),
|
|
558
|
+
format: "hex",
|
|
559
|
+
preserveChroma: c
|
|
560
|
+
};
|
|
561
|
+
if (s !== null && a !== null)
|
|
562
|
+
h.minLightness = s, h.maxLightness = a;
|
|
563
|
+
else {
|
|
564
|
+
const m = Math.max(20, Math.min(95, o));
|
|
565
|
+
h.lightnessRange = m;
|
|
566
|
+
}
|
|
567
|
+
const f = I(t, h), u = r ? f.reverse() : f, l = {};
|
|
568
|
+
return u.forEach((m, d) => {
|
|
569
|
+
l[`theme-${d + 1}`] = m;
|
|
570
|
+
}), l;
|
|
393
571
|
}
|
|
394
|
-
function
|
|
572
|
+
function wt(t, n = {}) {
|
|
395
573
|
if (!t)
|
|
396
574
|
throw new Error("Theme color is required");
|
|
397
575
|
const {
|
|
398
|
-
baseGray:
|
|
399
|
-
isDark:
|
|
576
|
+
baseGray: r = "#666666",
|
|
577
|
+
isDark: e = !1,
|
|
400
578
|
semanticColors: o,
|
|
401
579
|
controlBlendRatio: s = 0.08,
|
|
402
|
-
semanticBlendRatio:
|
|
403
|
-
controlSteps:
|
|
580
|
+
semanticBlendRatio: a = 0.12,
|
|
581
|
+
controlSteps: c = 12,
|
|
404
582
|
// 控件色灰度等级数
|
|
405
|
-
controlLightnessRange:
|
|
583
|
+
controlLightnessRange: i = 85,
|
|
406
584
|
// 控件色亮度变化范围(中心扩展模式)
|
|
407
|
-
controlMinLightness:
|
|
585
|
+
controlMinLightness: h = null,
|
|
408
586
|
// 控件色最小亮度(固定端点模式)
|
|
409
|
-
controlMaxLightness: f = null
|
|
587
|
+
controlMaxLightness: f = null,
|
|
410
588
|
// 控件色最大亮度(固定端点模式)
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
589
|
+
semanticSteps: u = 10,
|
|
590
|
+
// 语义色等级数
|
|
591
|
+
semanticLightnessRange: l = 80,
|
|
592
|
+
// 语义色亮度变化范围
|
|
593
|
+
semanticMinLightness: m = null,
|
|
594
|
+
// 语义色最小亮度
|
|
595
|
+
semanticMaxLightness: d = null,
|
|
596
|
+
// 语义色最大亮度
|
|
597
|
+
semanticPreserveChroma: M = !0,
|
|
598
|
+
// 语义色保持色度(默认开启)
|
|
599
|
+
themeSteps: g = 10,
|
|
600
|
+
// 主题色等级数
|
|
601
|
+
themeLightnessRange: w = 80,
|
|
602
|
+
// 主题色亮度变化范围
|
|
603
|
+
themeMinLightness: L = null,
|
|
604
|
+
// 主题色最小亮度
|
|
605
|
+
themeMaxLightness: p = null,
|
|
606
|
+
// 主题色最大亮度
|
|
607
|
+
themePreserveChroma: x = !0,
|
|
608
|
+
// 主题色保持色度(默认开启)
|
|
609
|
+
// 浅灰度颜色配置
|
|
610
|
+
neutralSteps: y = 6,
|
|
611
|
+
// 浅灰度等级数
|
|
612
|
+
neutralMinLightness: v = 92,
|
|
613
|
+
// 浅灰度最小亮度
|
|
614
|
+
neutralMaxLightness: A = 100,
|
|
615
|
+
// 浅灰度最大亮度
|
|
616
|
+
neutralBlendRatio: V = 0.03
|
|
617
|
+
// 浅灰度主题色混合比例
|
|
618
|
+
} = n, U = Math.max(0, Math.min(1, s)), K = Math.max(0, Math.min(1, a)), B = {
|
|
619
|
+
baseGray: r,
|
|
620
|
+
blendRatio: U,
|
|
621
|
+
isDark: e,
|
|
622
|
+
steps: c
|
|
623
|
+
};
|
|
624
|
+
h !== null && f !== null ? (B.minLightness = h, B.maxLightness = f) : B.lightnessRange = i;
|
|
625
|
+
const D = {
|
|
626
|
+
semanticColors: o,
|
|
627
|
+
blendRatio: K,
|
|
628
|
+
isDark: e,
|
|
629
|
+
steps: u,
|
|
630
|
+
preserveChroma: M
|
|
631
|
+
};
|
|
632
|
+
m !== null && d !== null ? (D.minLightness = m, D.maxLightness = d) : D.lightnessRange = l;
|
|
633
|
+
const F = {
|
|
634
|
+
isDark: e,
|
|
635
|
+
steps: g,
|
|
636
|
+
preserveChroma: x
|
|
416
637
|
};
|
|
417
|
-
return
|
|
638
|
+
return L !== null && p !== null ? (F.minLightness = L, F.maxLightness = p) : F.lightnessRange = w, {
|
|
418
639
|
// 1. 基础控件颜色(灰色系1-12或更多)
|
|
419
|
-
controls:
|
|
420
|
-
// 2.
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
640
|
+
controls: z(t, B),
|
|
641
|
+
// 2. 浅灰度颜色(用于背景、卡片等)
|
|
642
|
+
neutrals: rt(t, {
|
|
643
|
+
blendRatio: V,
|
|
644
|
+
steps: y,
|
|
645
|
+
minLightness: v,
|
|
646
|
+
maxLightness: A
|
|
425
647
|
}),
|
|
426
|
-
// 3.
|
|
427
|
-
|
|
648
|
+
// 3. 表意色(1-10或更多)
|
|
649
|
+
semantic: G(t, D),
|
|
650
|
+
// 4. 主题色(1-10或更多)
|
|
651
|
+
theme: N(t, F)
|
|
428
652
|
};
|
|
429
653
|
}
|
|
430
|
-
function
|
|
654
|
+
function xt(t, n = {}) {
|
|
431
655
|
if (!t)
|
|
432
656
|
throw new Error("Theme color is required");
|
|
433
657
|
const {
|
|
434
|
-
semanticColors:
|
|
658
|
+
semanticColors: r = {
|
|
435
659
|
success: "#52c41a",
|
|
436
660
|
warning: "#faad14",
|
|
437
661
|
error: "#ff4d4f",
|
|
438
662
|
info: "#1890ff"
|
|
439
663
|
},
|
|
440
|
-
uiColors:
|
|
664
|
+
uiColors: e = {
|
|
441
665
|
background: "#ffffff",
|
|
442
666
|
surface: "#fafafa",
|
|
443
667
|
border: "#d9d9d9",
|
|
@@ -445,36 +669,36 @@ function _(t, n = {}) {
|
|
|
445
669
|
},
|
|
446
670
|
harmonizeRatio: o = 0.15,
|
|
447
671
|
blendRatio: s = 0.12,
|
|
448
|
-
isDark:
|
|
672
|
+
isDark: a = !1
|
|
449
673
|
} = (
|
|
450
674
|
/** @type {any} */
|
|
451
675
|
n
|
|
452
|
-
),
|
|
453
|
-
blendRatio:
|
|
676
|
+
), c = Math.max(0, Math.min(1, o)), i = Math.max(0, Math.min(1, s)), h = N(t, { isDark: a }), f = z(t, {
|
|
677
|
+
blendRatio: i * 0.5,
|
|
454
678
|
// 中性色混合比例稍低
|
|
455
|
-
isDark:
|
|
456
|
-
}), u =
|
|
457
|
-
semanticColors:
|
|
458
|
-
blendRatio:
|
|
459
|
-
isDark:
|
|
460
|
-
}),
|
|
461
|
-
return Object.entries(
|
|
462
|
-
|
|
463
|
-
for (let
|
|
464
|
-
const
|
|
465
|
-
u[
|
|
679
|
+
isDark: a
|
|
680
|
+
}), u = G(t, {
|
|
681
|
+
semanticColors: r,
|
|
682
|
+
blendRatio: c,
|
|
683
|
+
isDark: a
|
|
684
|
+
}), l = {};
|
|
685
|
+
return Object.entries(r).forEach(([d]) => {
|
|
686
|
+
l[d] = {};
|
|
687
|
+
for (let M = 1; M <= 10; M++) {
|
|
688
|
+
const g = `${d}-${M}`;
|
|
689
|
+
u[g] && (l[d][M] = u[g]);
|
|
466
690
|
}
|
|
467
691
|
}), {
|
|
468
|
-
theme:
|
|
692
|
+
theme: h,
|
|
469
693
|
// 主题色阶 theme-1 到 theme-10
|
|
470
694
|
controls: f,
|
|
471
695
|
// 中性色阶 gray-1 到 gray-12
|
|
472
|
-
semantic:
|
|
696
|
+
semantic: l,
|
|
473
697
|
// 功能色系
|
|
474
|
-
ui:
|
|
698
|
+
ui: et(t, e, i)
|
|
475
699
|
};
|
|
476
700
|
}
|
|
477
|
-
const
|
|
701
|
+
const H = {
|
|
478
702
|
red: "#F53F3F",
|
|
479
703
|
orangered: "#F77234",
|
|
480
704
|
orange: "#FF7D00",
|
|
@@ -489,16 +713,16 @@ const C = {
|
|
|
489
713
|
pinkpurple: "#D91AD9",
|
|
490
714
|
magenta: "#F5319D"
|
|
491
715
|
};
|
|
492
|
-
function
|
|
716
|
+
function Lt() {
|
|
493
717
|
const t = {};
|
|
494
|
-
return Object.keys(
|
|
495
|
-
t[n] = {}, t[n].light =
|
|
718
|
+
return Object.keys(H).forEach((n) => {
|
|
719
|
+
t[n] = {}, t[n].light = P(H[
|
|
496
720
|
/** @type {keyof typeof colorList} */
|
|
497
721
|
n
|
|
498
|
-
], { list: !0 }), t[n].dark =
|
|
722
|
+
], { list: !0 }), t[n].dark = P(H[
|
|
499
723
|
/** @type {keyof typeof colorList} */
|
|
500
724
|
n
|
|
501
|
-
], { list: !0, dark: !0 }), t[n].primary =
|
|
725
|
+
], { list: !0, dark: !0 }), t[n].primary = H[
|
|
502
726
|
/** @type {keyof typeof colorList} */
|
|
503
727
|
n
|
|
504
728
|
];
|
|
@@ -527,25 +751,35 @@ function tt() {
|
|
|
527
751
|
], t.gray.primary = t.gray.light[6], t;
|
|
528
752
|
}
|
|
529
753
|
export {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
754
|
+
ut as adjustChroma,
|
|
755
|
+
ft as adjustHue,
|
|
756
|
+
ht as adjustTone,
|
|
757
|
+
$ as blendInHct,
|
|
758
|
+
et as blendUIColors,
|
|
759
|
+
lt as colorDifference,
|
|
760
|
+
H as colorList,
|
|
761
|
+
at as extractColorFromFile,
|
|
762
|
+
Q as extractColorFromImage,
|
|
763
|
+
P as generate,
|
|
764
|
+
z as generateControlColors,
|
|
765
|
+
it as generateGrayLinear,
|
|
766
|
+
wt as generateInterfaceColorSystem,
|
|
767
|
+
O as generateLinear,
|
|
768
|
+
ct as generateLinearHSL,
|
|
769
|
+
I as generateMonochromeLinear,
|
|
770
|
+
rt as generateNeutralColors,
|
|
771
|
+
G as generateSemanticColors,
|
|
772
|
+
N as generateThemeColors,
|
|
773
|
+
xt as generateThemePalette,
|
|
774
|
+
bt as generateThemeVariants,
|
|
775
|
+
Mt as getAnalogous,
|
|
776
|
+
mt as getComplementary,
|
|
777
|
+
Lt as getPresetColors,
|
|
778
|
+
st as getRgbStr,
|
|
779
|
+
gt as getSplitComplementary,
|
|
780
|
+
dt as getTriadic,
|
|
781
|
+
pt as harmonizeColor,
|
|
782
|
+
C as hctToRgb,
|
|
783
|
+
R as rgbToHct,
|
|
784
|
+
S as rotateHue
|
|
551
785
|
};
|