koishi-plugin-cchess 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const name = "cchess";
|
|
3
|
-
export declare const usage = "## \u4F7F\u7528\n\n`cchess.\u5F00\u59CB` \u5373\u53EF\u5165\u5EA7\uFF0C\u53CC\u65B9\u5C31\u4F4D\u540E\u81EA\u52A8\u5F00\u5C40\uFF1B`cchess.\u5F00\u59CB \u4EBA\u673A` \u76F4\u63A5\u6311\u6218\u76AE\u5361\u9C7C\u3002\u7740\u6CD5\u53EF\u76F4\u63A5\u53D1\u9001\uFF0C\u4F8B\u5982 `\u70AE\u4E8C\u5E73\u4E94` \u6216 `b2e2`\u3002\n\n\u6094\u68CB\u8BF7\u6C42\u9001\u51FA\u540E\uFF0C\u5BF9\u65B9\u65E0\u9700\u5E26\u6307\u4EE4\u524D\u7F00\uFF0C\u76F4\u63A5\u56DE\u590D `\u540C\u610F` \u6216 `\u62D2\u7EDD` \u5373\u53EF\u8868\u51B3\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `cchess.\u5F00\u59CB [\u7EA2/\u9ED1] [\u4EBA\u4EBA/\u4EBA\u673A]` | \u5165\u5EA7\u5E76\u5F00\u5C40\uFF0C\u53CC\u65B9\u5C31\u4F4D\u540E\u81EA\u52A8\u5F00\u6218 |\n| `cchess.\u5F00\u59CB <FEN>` | \u6446\u8C31\uFF0C\u5BFC\u5165\u5C40\u9762\u540E\u518D `cchess.\u5F00\u59CB` \u5373\u53EF |\n| `cchess.\u6094\u68CB [\u540C\u610F/\u62D2\u7EDD]` | \u8BF7\u6C42\u6094\u68CB\uFF0C\u4E5F\u53EF\u76F4\u63A5\u56DE\u590D\u540C\u610F\u6216\u62D2\u7EDD\u8868\u51B3 |\n| `cchess.\u8BA4\u8F93` | \u8BA4\u8F93 |\n| `cchess.\u7ED3\u675F` | \
|
|
3
|
+
export declare const usage = "## \u4F7F\u7528\n\n`cchess.\u5F00\u59CB` \u5373\u53EF\u5165\u5EA7\uFF0C\u53CC\u65B9\u5C31\u4F4D\u540E\u81EA\u52A8\u5F00\u5C40\uFF1B`cchess.\u5F00\u59CB \u4EBA\u673A` \u76F4\u63A5\u6311\u6218\u76AE\u5361\u9C7C\u3002\u7740\u6CD5\u53EF\u76F4\u63A5\u53D1\u9001\uFF0C\u4F8B\u5982 `\u70AE\u4E8C\u5E73\u4E94` \u6216 `b2e2`\u3002\n\n\u6094\u68CB\u8BF7\u6C42\u9001\u51FA\u540E\uFF0C\u5BF9\u65B9\u65E0\u9700\u5E26\u6307\u4EE4\u524D\u7F00\uFF0C\u76F4\u63A5\u56DE\u590D `\u540C\u610F` \u6216 `\u62D2\u7EDD` \u5373\u53EF\u8868\u51B3\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `cchess.\u5F00\u59CB [\u7EA2/\u9ED1] [\u4EBA\u4EBA/\u4EBA\u673A]` | \u5165\u5EA7\u5E76\u5F00\u5C40\uFF0C\u53CC\u65B9\u5C31\u4F4D\u540E\u81EA\u52A8\u5F00\u6218 |\n| `cchess.\u5F00\u59CB <FEN>` | \u6446\u8C31\uFF0C\u5BFC\u5165\u5C40\u9762\u540E\u518D `cchess.\u5F00\u59CB` \u5373\u53EF |\n| `cchess.\u6094\u68CB [\u540C\u610F/\u62D2\u7EDD]` | \u8BF7\u6C42\u6094\u68CB\uFF0C\u4E5F\u53EF\u76F4\u63A5\u56DE\u590D\u540C\u610F\u6216\u62D2\u7EDD\u8868\u51B3 |\n| `cchess.\u8BA4\u8F93` | \u8BA4\u8F93\u5E76\u7ED3\u675F\u5BF9\u5C40 |\n| `cchess.\u7ED3\u675F` | \u7ED3\u675F\u5F53\u524D\u5BF9\u5C40 |\n| `cchess.\u68CB\u7EE9 [@\u67D0\u4EBA/\u699C] [\u80DC\u573A/\u8F93\u573A] [\u4EBA\u6570]` | \u67E5\u8BE2\u6218\u7EE9\u6216\u6392\u884C\u699C |\n| `cchess.\u67E5\u770B\u4E91\u5E93\u6B8B\u5C40 [DTM/DTC]` | \u67E5\u8BE2\u4E91\u5E93\u6B8B\u5C40\u7EDF\u8BA1 |";
|
|
4
4
|
export declare const inject: string[];
|
|
5
5
|
export interface Config {
|
|
6
6
|
boardSkin: string;
|
package/lib/index.js
CHANGED
|
@@ -38,6 +38,209 @@ __export(src_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
40
|
var import_koishi = require("koishi");
|
|
41
|
+
|
|
42
|
+
// src/m3.ts
|
|
43
|
+
var WHITE_X = 95.047;
|
|
44
|
+
var WHITE_Y = 100;
|
|
45
|
+
var WHITE_Z = 108.883;
|
|
46
|
+
function labToXyz(l, a, b) {
|
|
47
|
+
const fy = (l + 16) / 116;
|
|
48
|
+
const fx = fy + a / 500;
|
|
49
|
+
const fz = fy - b / 200;
|
|
50
|
+
const f = /* @__PURE__ */ __name((t) => t > 6 / 29 ? t * t * t : 3 * (6 / 29) ** 2 * (t - 4 / 29), "f");
|
|
51
|
+
return [f(fx) * WHITE_X, f(fy) * WHITE_Y, f(fz) * WHITE_Z];
|
|
52
|
+
}
|
|
53
|
+
__name(labToXyz, "labToXyz");
|
|
54
|
+
function gamma(value) {
|
|
55
|
+
return value <= 31308e-7 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
56
|
+
}
|
|
57
|
+
__name(gamma, "gamma");
|
|
58
|
+
function xyzToRgb(x, y, z) {
|
|
59
|
+
x /= 100;
|
|
60
|
+
y /= 100;
|
|
61
|
+
z /= 100;
|
|
62
|
+
return [
|
|
63
|
+
gamma(3.2406 * x - 1.5372 * y - 0.4986 * z),
|
|
64
|
+
gamma(-0.9689 * x + 1.8758 * y + 0.0415 * z),
|
|
65
|
+
gamma(0.0557 * x - 0.204 * y + 1.057 * z)
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
__name(xyzToRgb, "xyzToRgb");
|
|
69
|
+
var EPSILON = 1 / 512;
|
|
70
|
+
function lch(tone, chroma, hue) {
|
|
71
|
+
const radian = hue * Math.PI / 180;
|
|
72
|
+
const at = /* @__PURE__ */ __name((c) => xyzToRgb(...labToXyz(tone, Math.cos(radian) * c, Math.sin(radian) * c)), "at");
|
|
73
|
+
const inGamut = /* @__PURE__ */ __name((rgb2) => rgb2.every((value) => value >= -EPSILON && value <= 1 + EPSILON), "inGamut");
|
|
74
|
+
let rgb = at(chroma);
|
|
75
|
+
if (!inGamut(rgb)) {
|
|
76
|
+
let low = 0;
|
|
77
|
+
let high = chroma;
|
|
78
|
+
while (high - low > 0.05) {
|
|
79
|
+
const mid = (low + high) / 2;
|
|
80
|
+
if (inGamut(at(mid))) low = mid;
|
|
81
|
+
else high = mid;
|
|
82
|
+
}
|
|
83
|
+
rgb = at(low);
|
|
84
|
+
}
|
|
85
|
+
return "#" + rgb.map((value) => Math.round(Math.min(1, Math.max(0, value)) * 255).toString(16).padStart(2, "0")).join("");
|
|
86
|
+
}
|
|
87
|
+
__name(lch, "lch");
|
|
88
|
+
function degamma(value) {
|
|
89
|
+
value /= 255;
|
|
90
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
91
|
+
}
|
|
92
|
+
__name(degamma, "degamma");
|
|
93
|
+
function lchOf(hex) {
|
|
94
|
+
const value = parseInt(hex.replace("#", "").slice(0, 6), 16) || 0;
|
|
95
|
+
const r = degamma(value >> 16 & 255);
|
|
96
|
+
const g = degamma(value >> 8 & 255);
|
|
97
|
+
const b = degamma(value & 255);
|
|
98
|
+
const x = (0.4124 * r + 0.3576 * g + 0.1805 * b) * 100 / WHITE_X;
|
|
99
|
+
const y = (0.2126 * r + 0.7152 * g + 0.0722 * b) * 100 / WHITE_Y;
|
|
100
|
+
const z = (0.0193 * r + 0.1192 * g + 0.9505 * b) * 100 / WHITE_Z;
|
|
101
|
+
const f = /* @__PURE__ */ __name((t) => t > (6 / 29) ** 3 ? Math.cbrt(t) : t / (3 * (6 / 29) ** 2) + 4 / 29, "f");
|
|
102
|
+
const [fx, fy, fz] = [f(x), f(y), f(z)];
|
|
103
|
+
const a = 500 * (fx - fy);
|
|
104
|
+
const bb = 200 * (fy - fz);
|
|
105
|
+
return {
|
|
106
|
+
tone: 116 * fy - 16,
|
|
107
|
+
chroma: Math.hypot(a, bb),
|
|
108
|
+
hue: (Math.atan2(bb, a) * 180 / Math.PI + 360) % 360
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
__name(lchOf, "lchOf");
|
|
112
|
+
function harmonize(hex, tone, chroma = 48, fallbackHue = 0) {
|
|
113
|
+
const source = lchOf(hex);
|
|
114
|
+
const hue = source.chroma < 4 ? fallbackHue : source.hue;
|
|
115
|
+
return lch(tone, source.chroma < 4 ? Math.min(chroma, 6) : chroma, hue);
|
|
116
|
+
}
|
|
117
|
+
__name(harmonize, "harmonize");
|
|
118
|
+
function palette(hue, chroma) {
|
|
119
|
+
const cache = /* @__PURE__ */ new Map();
|
|
120
|
+
return (tone) => {
|
|
121
|
+
const hit = cache.get(tone);
|
|
122
|
+
if (hit) return hit;
|
|
123
|
+
const value = lch(tone, chroma, hue);
|
|
124
|
+
cache.set(tone, value);
|
|
125
|
+
return value;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
__name(palette, "palette");
|
|
129
|
+
function palettesOf(hue, options = {}) {
|
|
130
|
+
const { chroma = 56, tertiaryShift = 60 } = options;
|
|
131
|
+
return {
|
|
132
|
+
primary: palette(hue, chroma),
|
|
133
|
+
secondary: palette(hue, Math.max(16, chroma / 3.2)),
|
|
134
|
+
tertiary: palette(hue + tertiaryShift, Math.max(28, chroma / 1.8)),
|
|
135
|
+
neutral: palette(hue, 4),
|
|
136
|
+
neutralVariant: palette(hue, 9),
|
|
137
|
+
error: palette(36, 68)
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
__name(palettesOf, "palettesOf");
|
|
141
|
+
function scheme(hue, dark = false, options = {}) {
|
|
142
|
+
const p = palettesOf(hue, options);
|
|
143
|
+
const { primary: P, secondary: S, tertiary: T, neutral: N, neutralVariant: V, error: E } = p;
|
|
144
|
+
if (dark) {
|
|
145
|
+
return {
|
|
146
|
+
primary: P(80),
|
|
147
|
+
onPrimary: P(20),
|
|
148
|
+
primaryContainer: P(30),
|
|
149
|
+
onPrimaryContainer: P(90),
|
|
150
|
+
secondary: S(80),
|
|
151
|
+
onSecondary: S(20),
|
|
152
|
+
secondaryContainer: S(30),
|
|
153
|
+
onSecondaryContainer: S(90),
|
|
154
|
+
tertiary: T(80),
|
|
155
|
+
onTertiary: T(20),
|
|
156
|
+
tertiaryContainer: T(30),
|
|
157
|
+
onTertiaryContainer: T(90),
|
|
158
|
+
error: E(80),
|
|
159
|
+
onError: E(20),
|
|
160
|
+
errorContainer: E(30),
|
|
161
|
+
onErrorContainer: E(90),
|
|
162
|
+
background: N(6),
|
|
163
|
+
onBackground: N(90),
|
|
164
|
+
surface: N(6),
|
|
165
|
+
onSurface: N(90),
|
|
166
|
+
surfaceVariant: V(30),
|
|
167
|
+
onSurfaceVariant: V(80),
|
|
168
|
+
surfaceDim: N(6),
|
|
169
|
+
surfaceBright: N(24),
|
|
170
|
+
surfaceContainerLowest: N(4),
|
|
171
|
+
surfaceContainerLow: N(10),
|
|
172
|
+
surfaceContainer: N(12),
|
|
173
|
+
surfaceContainerHigh: N(17),
|
|
174
|
+
surfaceContainerHighest: N(22),
|
|
175
|
+
outline: V(60),
|
|
176
|
+
outlineVariant: V(30),
|
|
177
|
+
inverseSurface: N(90),
|
|
178
|
+
inverseOnSurface: N(20),
|
|
179
|
+
inversePrimary: P(40),
|
|
180
|
+
scrim: N(0),
|
|
181
|
+
shadow: N(0)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
primary: P(40),
|
|
186
|
+
onPrimary: P(100),
|
|
187
|
+
primaryContainer: P(90),
|
|
188
|
+
onPrimaryContainer: P(30),
|
|
189
|
+
secondary: S(40),
|
|
190
|
+
onSecondary: S(100),
|
|
191
|
+
secondaryContainer: S(90),
|
|
192
|
+
onSecondaryContainer: S(30),
|
|
193
|
+
tertiary: T(40),
|
|
194
|
+
onTertiary: T(100),
|
|
195
|
+
tertiaryContainer: T(90),
|
|
196
|
+
onTertiaryContainer: T(30),
|
|
197
|
+
error: E(40),
|
|
198
|
+
onError: E(100),
|
|
199
|
+
errorContainer: E(90),
|
|
200
|
+
onErrorContainer: E(30),
|
|
201
|
+
background: N(98),
|
|
202
|
+
onBackground: N(10),
|
|
203
|
+
surface: N(98),
|
|
204
|
+
onSurface: N(10),
|
|
205
|
+
surfaceVariant: V(90),
|
|
206
|
+
onSurfaceVariant: V(30),
|
|
207
|
+
surfaceDim: N(87),
|
|
208
|
+
surfaceBright: N(98),
|
|
209
|
+
surfaceContainerLowest: N(100),
|
|
210
|
+
surfaceContainerLow: N(96),
|
|
211
|
+
surfaceContainer: N(94),
|
|
212
|
+
surfaceContainerHigh: N(92),
|
|
213
|
+
surfaceContainerHighest: N(90),
|
|
214
|
+
outline: V(50),
|
|
215
|
+
outlineVariant: V(80),
|
|
216
|
+
inverseSurface: N(20),
|
|
217
|
+
inverseOnSurface: N(95),
|
|
218
|
+
inversePrimary: P(80),
|
|
219
|
+
scrim: N(0),
|
|
220
|
+
shadow: N(0)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
__name(scheme, "scheme");
|
|
224
|
+
var SHAPE = {
|
|
225
|
+
none: 0,
|
|
226
|
+
extraSmall: 4,
|
|
227
|
+
small: 8,
|
|
228
|
+
medium: 12,
|
|
229
|
+
large: 16,
|
|
230
|
+
largeIncreased: 20,
|
|
231
|
+
extraLarge: 28,
|
|
232
|
+
extraLargeIncreased: 32,
|
|
233
|
+
extraExtraLarge: 48,
|
|
234
|
+
full: 9999
|
|
235
|
+
};
|
|
236
|
+
var FONT_STACK = '"Roboto Flex", "Roboto", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif';
|
|
237
|
+
var MEDAL = {
|
|
238
|
+
gold: lch(58, 52, 85),
|
|
239
|
+
silver: lch(66, 5, 260),
|
|
240
|
+
bronze: lch(48, 36, 48)
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// src/index.ts
|
|
41
244
|
var path = __toESM(require("path"));
|
|
42
245
|
var fs = __toESM(require("fs"));
|
|
43
246
|
var name = "cchess";
|
|
@@ -54,23 +257,23 @@ var usage = `## 使用
|
|
|
54
257
|
| \`cchess.开始 [红/黑] [人人/人机]\` | 入座并开局,双方就位后自动开战 |
|
|
55
258
|
| \`cchess.开始 <FEN>\` | 摆谱,导入局面后再 \`cchess.开始\` 即可 |
|
|
56
259
|
| \`cchess.悔棋 [同意/拒绝]\` | 请求悔棋,也可直接回复同意或拒绝表决 |
|
|
57
|
-
| \`cchess.认输\` |
|
|
58
|
-
| \`cchess.结束\` |
|
|
59
|
-
| \`cchess.棋绩 [@某人/榜] [胜场/输场] [人数]\` |
|
|
60
|
-
| \`cchess.查看云库残局 [DTM/DTC]\` |
|
|
260
|
+
| \`cchess.认输\` | 认输并结束对局 |
|
|
261
|
+
| \`cchess.结束\` | 结束当前对局 |
|
|
262
|
+
| \`cchess.棋绩 [@某人/榜] [胜场/输场] [人数]\` | 查询战绩或排行榜 |
|
|
263
|
+
| \`cchess.查看云库残局 [DTM/DTC]\` | 查询云库残局统计 |`;
|
|
61
264
|
var inject = ["database", "canvas"];
|
|
62
265
|
var pieceSkins = ["棋弈无限图形棋子", "云库木制棋子", "刘炳森红黑牛角隶书棋子", "木制棋子", "本纹隶书棋子", "银灰将军体棋子", "棋弈无限红绿正棋子", "棋弈无限红绿棋子", "棋天大圣棋子", "棋者象棋棋子", "楷书玉石棋子", "水墨青瓷棋子", "牛皮纸华康金文棋子", "皮卡鱼棋子", "红蓝祥隶棋子", "红黑精典无阴影棋子", "红黑精典棋子", "行书玉石棋子", "象甲棋子", "金属棋子篆体棋子", "镌刻华彩棋子", "鹏飞红黑棋子", "鹏飞经典棋子", "鹏飞绿龙棋子", "龙腾四海棋子"];
|
|
63
266
|
var boardSkins = ["棋弈无限红绿棋盘", "一鸣惊人棋盘", "三星堆棋盘", "云库木制棋盘", "云心鹤眼棋盘", "兰亭集序无字棋盘", "兰亭集序棋盘", "凤舞九天棋盘", "卯兔添福棋盘", "叱咤风云棋盘", "君临天下棋盘", "壁画古梦棋盘", "大闹天宫棋盘", "天山共色棋盘", "女神之约棋盘", "小吕飞刀棋盘", "山海绘卷棋盘", "护眼绿棋盘", "星河璀璨棋盘", "木制棋盘", "本纹隶书白棋盘", "本纹隶书黑棋盘", "桃花源记棋盘", "棋天大圣棋盘", "棋天无大圣棋盘", "武侠江湖棋盘", "水墨青瓷棋盘", "清悠茶道棋盘", "游园惊梦棋盘", "牛转乾坤棋盘", "玉石太极棋盘", "皓月无痕棋盘", "皮卡鱼棋盘", "盲棋神迹棋盘", "空城计棋盘", "竹波烟雨棋盘", "经典木棋盘棋盘", "绿色棋盘", "象甲2023棋盘", "象甲征程棋盘", "象甲重燃棋盘", "金牛降世棋盘", "金虎贺岁棋盘", "金虎贺岁(王天一签名版)棋盘", "鎏金岁月棋盘", "霸王别姬棋盘", "鸿门宴棋盘", "鹏飞红黑棋盘", "鹏飞经典棋盘", "鹏飞绿龙棋盘", "龙腾天坛棋盘"];
|
|
64
267
|
var Config = import_koishi.Schema.object({
|
|
65
268
|
boardSkin: import_koishi.Schema.union(boardSkins).default("象甲2023棋盘").description(`棋盘皮肤。`),
|
|
66
269
|
pieceSkin: import_koishi.Schema.union(pieceSkins).default("象甲棋子").description(`棋子皮肤。`),
|
|
67
|
-
allowFreePieceMovementInHumanMachineMode: import_koishi.Schema.boolean().default(false).description(
|
|
270
|
+
allowFreePieceMovementInHumanMachineMode: import_koishi.Schema.boolean().default(false).description(`人机模式下,允许所有人自由移动棋子,开启后可以不入座直接开始人机对局。`),
|
|
68
271
|
defaultEngineThinkingDepth: import_koishi.Schema.number().min(0).max(100).default(10).description(`默认引擎思考深度,越高 AI 棋力越强,耗时也越长(小于 1 时按 1 计算)。由于 Nodejs 不支持 SIMD,所以不建议设置过高。`),
|
|
69
|
-
defaultMaxLeaderboardEntries: import_koishi.Schema.number().min(0).default(10).description(
|
|
70
|
-
retractDelay: import_koishi.Schema.number().min(0).default(0).description(
|
|
272
|
+
defaultMaxLeaderboardEntries: import_koishi.Schema.number().min(0).default(10).description(`排行榜默认显示的人数。`),
|
|
273
|
+
retractDelay: import_koishi.Schema.number().min(0).default(0).description(`自动撤回延迟(秒),0 表示不撤回。`),
|
|
71
274
|
imgScale: import_koishi.Schema.number().min(1).default(1).description(`图片分辨率倍率。`),
|
|
72
|
-
imageType: import_koishi.Schema.union(["png", "jpeg", "webp"]).default("png").description(
|
|
73
|
-
isChessImageWithOutlineEnabled: import_koishi.Schema.boolean().default(true).description(
|
|
275
|
+
imageType: import_koishi.Schema.union(["png", "jpeg", "webp"]).default("png").description(`发送的图片格式。`),
|
|
276
|
+
isChessImageWithOutlineEnabled: import_koishi.Schema.boolean().default(true).description(`给棋盘图片加上坐标外框。关闭后出图明显更快,但没有外框,玩起来可能会比较累。`)
|
|
74
277
|
});
|
|
75
278
|
var RULE = "━━━━━━━━━━━━━━";
|
|
76
279
|
var SIDE_ICONS = { 红方: "🔴", 黑方: "⚫" };
|
|
@@ -115,6 +318,22 @@ function apply(ctx, config) {
|
|
|
115
318
|
}
|
|
116
319
|
});
|
|
117
320
|
});
|
|
321
|
+
const FRAME = scheme(60);
|
|
322
|
+
function roundRect(context, x, y, width, height, radius) {
|
|
323
|
+
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
324
|
+
context.beginPath();
|
|
325
|
+
context.moveTo(x + r, y);
|
|
326
|
+
context.lineTo(x + width - r, y);
|
|
327
|
+
context.arcTo(x + width, y, x + width, y + r, r);
|
|
328
|
+
context.lineTo(x + width, y + height - r);
|
|
329
|
+
context.arcTo(x + width, y + height, x + width - r, y + height, r);
|
|
330
|
+
context.lineTo(x + r, y + height);
|
|
331
|
+
context.arcTo(x, y + height, x, y + height - r, r);
|
|
332
|
+
context.lineTo(x, y + r);
|
|
333
|
+
context.arcTo(x, y, x + r, y, r);
|
|
334
|
+
context.closePath();
|
|
335
|
+
}
|
|
336
|
+
__name(roundRect, "roundRect");
|
|
118
337
|
const CELL_WIDTH = 54;
|
|
119
338
|
const ARROW_OFFSET = 33;
|
|
120
339
|
const BOARD_PADDING = 33;
|
|
@@ -132,8 +351,14 @@ function apply(ctx, config) {
|
|
|
132
351
|
const thinkingDepth = Math.max(1, Math.round(config.defaultEngineThinkingDepth) || 1);
|
|
133
352
|
const ENGINE_TIMEOUT = 120 * 1e3;
|
|
134
353
|
const piecesImgResources = loadPiecesImageResources(config.pieceSkin);
|
|
135
|
-
const outerFrameImg = fs.readFileSync(path.join(__dirname, "assets", "棋盘皮肤", `外框.png`));
|
|
136
354
|
const boardSkinImg = fs.readFileSync(path.join(__dirname, "assets", "棋盘皮肤", `${config.boardSkin}.webp`));
|
|
355
|
+
const FRAME_WIDTH = 620;
|
|
356
|
+
const FRAME_HEIGHT = 780;
|
|
357
|
+
const FRAME_BOARD = { x: 36.5, y: 90, width: 550, height: 605 };
|
|
358
|
+
const FRAME_ZOOM = FRAME_BOARD.width / BOARD_WIDTH;
|
|
359
|
+
const FILES = ["a", "b", "c", "d", "e", "f", "g", "h", "i"];
|
|
360
|
+
const RED_FILES = ["九", "八", "七", "六", "五", "四", "三", "二", "一"];
|
|
361
|
+
const ARROW_COLOR = harmonize("#80ab45", 58, 56);
|
|
137
362
|
const possibleFigureNames = ["将", "士", "象", "车", "马", "炮", "卒", "帅", "仕", "相", "兵"];
|
|
138
363
|
ctx.model.extend("cchess_game_records", {
|
|
139
364
|
id: "unsigned",
|
|
@@ -234,10 +459,10 @@ function apply(ctx, config) {
|
|
|
234
459
|
}
|
|
235
460
|
await handleMove(session, moveOperation);
|
|
236
461
|
});
|
|
237
|
-
ctx.command("cchess", "
|
|
462
|
+
ctx.command("cchess", "中国象棋 · 楚河汉界").action(async ({ session }) => {
|
|
238
463
|
await session.execute(`cchess -h`);
|
|
239
464
|
});
|
|
240
|
-
ctx.command("cchess.开始 [args:text]", "
|
|
465
|
+
ctx.command("cchess.开始 [args:text]", "入座并开局").usage("可选阵营「红」「黑」与对手「人人」「人机」;直接粘贴 FEN 串则按摆谱处理。").example("cchess.开始 红 人机").action(async ({ session }, args) => {
|
|
241
466
|
const { username, userId, channelId } = session;
|
|
242
467
|
await updateNameInPlayerRecord(userId, username);
|
|
243
468
|
const gameRecord = await getGameRecord(channelId);
|
|
@@ -320,7 +545,7 @@ function apply(ctx, config) {
|
|
|
320
545
|
image: await renderBoard(channelId)
|
|
321
546
|
}));
|
|
322
547
|
});
|
|
323
|
-
ctx.command("cchess.结束", "
|
|
548
|
+
ctx.command("cchess.结束", "结束当前对局").action(async ({ session }) => {
|
|
324
549
|
const { username, userId, channelId } = session;
|
|
325
550
|
await updateNameInPlayerRecord(userId, username);
|
|
326
551
|
const gameRecord = await getGameRecord(channelId);
|
|
@@ -354,7 +579,7 @@ function apply(ctx, config) {
|
|
|
354
579
|
icon: "⏳",
|
|
355
580
|
title: "棋局正在推演",
|
|
356
581
|
at: username,
|
|
357
|
-
body: ["
|
|
582
|
+
body: ["上一着棋尚未结算,稍候片刻。"]
|
|
358
583
|
}));
|
|
359
584
|
}
|
|
360
585
|
busyChannels.add(channelId);
|
|
@@ -466,7 +691,7 @@ function apply(ctx, config) {
|
|
|
466
691
|
}
|
|
467
692
|
}
|
|
468
693
|
__name(handleMove, "handleMove");
|
|
469
|
-
ctx.command("cchess.悔棋 [decision:string]", "
|
|
694
|
+
ctx.command("cchess.悔棋 [decision:string]", "请求悔棋或答复对方").usage("请求送出后,对方直接回复「同意」或「拒绝」即可表决,无需指令前缀。").action(async ({ session }, decision) => {
|
|
470
695
|
const { username, userId, channelId } = session;
|
|
471
696
|
await updateNameInPlayerRecord(userId, username);
|
|
472
697
|
if (decision) {
|
|
@@ -538,7 +763,7 @@ function apply(ctx, config) {
|
|
|
538
763
|
tips: ["对方回复「同意」或「拒绝」即可表决"]
|
|
539
764
|
}));
|
|
540
765
|
});
|
|
541
|
-
ctx.command("cchess.认输", "
|
|
766
|
+
ctx.command("cchess.认输", "认输并结束对局").action(async ({ session }) => {
|
|
542
767
|
const { username, userId, channelId } = session;
|
|
543
768
|
await updateNameInPlayerRecord(userId, username);
|
|
544
769
|
const gameRecord = await getGameRecord(channelId);
|
|
@@ -570,7 +795,7 @@ function apply(ctx, config) {
|
|
|
570
795
|
});
|
|
571
796
|
return await sendMessage(session, message);
|
|
572
797
|
});
|
|
573
|
-
ctx.command("cchess.查看云库残局 [type:string]", "
|
|
798
|
+
ctx.command("cchess.查看云库残局 [type:string]", "查询云库残局统计").usage("参数可填「DTM」或「DTC」,缺省为 DTM。").action(async ({ session }, type) => {
|
|
574
799
|
const { username, userId } = session;
|
|
575
800
|
await updateNameInPlayerRecord(userId, username);
|
|
576
801
|
const isDtc = /dtc/i.test(type ?? "");
|
|
@@ -581,7 +806,7 @@ function apply(ctx, config) {
|
|
|
581
806
|
body: isDtc ? ["DTC:距吃子的步数统计。", "https://www.chessdb.cn/egtb_info.html"] : ["DTM:距将死的步数统计。", "https://www.chessdb.cn/egtb_info_dtm.html"]
|
|
582
807
|
}));
|
|
583
808
|
});
|
|
584
|
-
ctx.command("cchess.棋绩 [args:text]", "
|
|
809
|
+
ctx.command("cchess.棋绩 [args:text]", "查询战绩或排行榜").usage("带「榜」看排行榜,@ 某人可查看对方战绩。").action(async ({ session }, args) => {
|
|
585
810
|
let { userId, username } = session;
|
|
586
811
|
await updateNameInPlayerRecord(userId, username);
|
|
587
812
|
const text = (args ?? "").trim();
|
|
@@ -665,7 +890,7 @@ function apply(ctx, config) {
|
|
|
665
890
|
icon: "⚠️",
|
|
666
891
|
title: "你尚未入座",
|
|
667
892
|
at: username,
|
|
668
|
-
body: ["
|
|
893
|
+
body: ["先入座,才好落子。"],
|
|
669
894
|
tips: ["发送「cchess.开始」入座"]
|
|
670
895
|
});
|
|
671
896
|
}
|
|
@@ -675,7 +900,7 @@ function apply(ctx, config) {
|
|
|
675
900
|
icon: "⏳",
|
|
676
901
|
title: "皮卡鱼正在推演",
|
|
677
902
|
at: username,
|
|
678
|
-
body: ["
|
|
903
|
+
body: ["引擎正在计算局面,稍候再试。"]
|
|
679
904
|
});
|
|
680
905
|
}
|
|
681
906
|
__name(analyzingPanel, "analyzingPanel");
|
|
@@ -1389,12 +1614,42 @@ function apply(ctx, config) {
|
|
|
1389
1614
|
}
|
|
1390
1615
|
__name(convertTurnToString, "convertTurnToString");
|
|
1391
1616
|
async function createImage(buffer) {
|
|
1392
|
-
const canvas = await ctx.canvas.createCanvas(
|
|
1617
|
+
const canvas = await ctx.canvas.createCanvas(FRAME_WIDTH * scale, FRAME_HEIGHT * scale);
|
|
1393
1618
|
const context = canvas.getContext("2d");
|
|
1394
|
-
|
|
1395
|
-
context.
|
|
1619
|
+
context.scale(scale, scale);
|
|
1620
|
+
context.fillStyle = FRAME.surfaceContainer;
|
|
1621
|
+
roundRect(context, 0, 0, FRAME_WIDTH, FRAME_HEIGHT, SHAPE.extraLarge);
|
|
1622
|
+
context.fill();
|
|
1396
1623
|
const boardImg = await ctx.canvas.loadImage(buffer);
|
|
1397
|
-
context.drawImage(
|
|
1624
|
+
context.drawImage(
|
|
1625
|
+
boardImg,
|
|
1626
|
+
FRAME_BOARD.x,
|
|
1627
|
+
FRAME_BOARD.y,
|
|
1628
|
+
FRAME_BOARD.width,
|
|
1629
|
+
FRAME_BOARD.height
|
|
1630
|
+
);
|
|
1631
|
+
const columnAt = /* @__PURE__ */ __name((col) => FRAME_BOARD.x + (col * CELL_WIDTH + BOARD_PADDING) * FRAME_ZOOM, "columnAt");
|
|
1632
|
+
const rowAt = /* @__PURE__ */ __name((row) => FRAME_BOARD.y + (row * CELL_WIDTH + BOARD_PADDING) * FRAME_ZOOM, "rowAt");
|
|
1633
|
+
context.textAlign = "center";
|
|
1634
|
+
context.textBaseline = "middle";
|
|
1635
|
+
const label = /* @__PURE__ */ __name((text, x, y, size, color) => {
|
|
1636
|
+
context.font = `600 ${size}px ${FONT_STACK}`;
|
|
1637
|
+
context.fillStyle = color;
|
|
1638
|
+
context.fillText(text, x, y);
|
|
1639
|
+
}, "label");
|
|
1640
|
+
for (let col = 0; col < 9; col++) {
|
|
1641
|
+
const x = columnAt(isFlipBoard ? 8 - col : col);
|
|
1642
|
+
label(FILES[col], x, 30, 22, FRAME.onSurfaceVariant);
|
|
1643
|
+
label(String(col + 1), x, 64, 22, FRAME.outline);
|
|
1644
|
+
label(RED_FILES[col], x, FRAME_HEIGHT - 62, 24, FRAME.onSurfaceVariant);
|
|
1645
|
+
label(FILES[col], x, FRAME_HEIGHT - 26, 22, FRAME.outline);
|
|
1646
|
+
}
|
|
1647
|
+
for (let row = 0; row < 10; row++) {
|
|
1648
|
+
const y = rowAt(isFlipBoard ? 9 - row : row);
|
|
1649
|
+
const text = String(9 - row);
|
|
1650
|
+
label(text, 19, y, 22, FRAME.outline);
|
|
1651
|
+
label(text, FRAME_WIDTH - 19, y, 22, FRAME.outline);
|
|
1652
|
+
}
|
|
1398
1653
|
return canvas.toBuffer(imageMimeType);
|
|
1399
1654
|
}
|
|
1400
1655
|
__name(createImage, "createImage");
|
|
@@ -1864,7 +2119,7 @@ function apply(ctx, config) {
|
|
|
1864
2119
|
let dist = Math.sqrt((startX - endX) ** 2 + (startY - endY) ** 2);
|
|
1865
2120
|
let adjustedEndX = startX + (endX - startX) * (dist - 30) / dist;
|
|
1866
2121
|
let adjustedEndY = startY + (endY - startY) * (dist - 30) / dist;
|
|
1867
|
-
await drawLineArrow(context, startX * scale, startY * scale, adjustedEndX * scale, adjustedEndY * scale,
|
|
2122
|
+
await drawLineArrow(context, startX * scale, startY * scale, adjustedEndX * scale, adjustedEndY * scale, ARROW_COLOR + "b3", 15 * scale);
|
|
1868
2123
|
}
|
|
1869
2124
|
if (moveList.length > 0) {
|
|
1870
2125
|
const currentMoveId = moveList[moveList.length - 1].moveId;
|
package/lib/m3.d.ts
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Material 3 Expressive 设计系统。
|
|
3
|
+
*
|
|
4
|
+
* 只依赖标准库,输出纯 CSS 变量与常量,任何渲染后端(puppeteer / canvas)都能用。
|
|
5
|
+
* 色板按 M3 的做法从一个源色推出六套色调板,再按角色映射成明暗两套配色。
|
|
6
|
+
*/
|
|
7
|
+
/** M3 的「色调」就是 CIE L*,0 为黑、100 为白。 */
|
|
8
|
+
export type Tone = number;
|
|
9
|
+
/** LCh -> #rrggbb。超出 sRGB 色域时按二分法降低彩度,色调与色相保持不变。 */
|
|
10
|
+
export declare function lch(tone: Tone, chroma: number, hue: number): string;
|
|
11
|
+
/** `#rrggbb` -> LCh,`lch()` 的逆运算。 */
|
|
12
|
+
export declare function lchOf(hex: string): {
|
|
13
|
+
tone: number;
|
|
14
|
+
chroma: number;
|
|
15
|
+
hue: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* 把一个任意来源的颜色(头像主色、用户自选色)收进本设计系统。
|
|
19
|
+
*
|
|
20
|
+
* 只保留它的色相,色调与彩度一律换成设计系统里的取值——于是每个人都还有
|
|
21
|
+
* 自己的颜色,整张图的明度节奏却是齐的,不会因为某个头像特别暗就糊成一团。
|
|
22
|
+
* 彩度太低的灰色头像没有可用的色相,退回主色。
|
|
23
|
+
*/
|
|
24
|
+
export declare function harmonize(hex: string, tone: Tone, chroma?: number, fallbackHue?: number): string;
|
|
25
|
+
/** 一套色调板:固定色相与彩度,按色调取色。 */
|
|
26
|
+
export type Palette = (tone: Tone) => string;
|
|
27
|
+
export declare function palette(hue: number, chroma: number): Palette;
|
|
28
|
+
export interface Palettes {
|
|
29
|
+
primary: Palette;
|
|
30
|
+
secondary: Palette;
|
|
31
|
+
tertiary: Palette;
|
|
32
|
+
neutral: Palette;
|
|
33
|
+
neutralVariant: Palette;
|
|
34
|
+
error: Palette;
|
|
35
|
+
}
|
|
36
|
+
export interface SourceOptions {
|
|
37
|
+
/** 主色彩度,默认 56,够鲜艳又不至于在浅色调上大面积溢出色域。 */
|
|
38
|
+
chroma?: number;
|
|
39
|
+
/**
|
|
40
|
+
* 第三色相对主色的相位差,默认 +60°。
|
|
41
|
+
* 这个值规范里是个经验值,并非永远合适:暖橙 +60° 会落到发闷的橄榄绿,
|
|
42
|
+
* 这种时候改成 -60° 取玫红,强调色才跳得出来。
|
|
43
|
+
*/
|
|
44
|
+
tertiaryShift?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 按 M3 的推导规则从源色相生成六套色调板。
|
|
48
|
+
*
|
|
49
|
+
* Expressive 相比基础风格更敢用彩度:第三色比规范里的保守取值更高,
|
|
50
|
+
* 中性色也留了一点源色的味道,成片的表面不会灰得发死。
|
|
51
|
+
*/
|
|
52
|
+
export declare function palettesOf(hue: number, options?: SourceOptions): Palettes;
|
|
53
|
+
export interface Scheme {
|
|
54
|
+
primary: string;
|
|
55
|
+
onPrimary: string;
|
|
56
|
+
primaryContainer: string;
|
|
57
|
+
onPrimaryContainer: string;
|
|
58
|
+
secondary: string;
|
|
59
|
+
onSecondary: string;
|
|
60
|
+
secondaryContainer: string;
|
|
61
|
+
onSecondaryContainer: string;
|
|
62
|
+
tertiary: string;
|
|
63
|
+
onTertiary: string;
|
|
64
|
+
tertiaryContainer: string;
|
|
65
|
+
onTertiaryContainer: string;
|
|
66
|
+
error: string;
|
|
67
|
+
onError: string;
|
|
68
|
+
errorContainer: string;
|
|
69
|
+
onErrorContainer: string;
|
|
70
|
+
background: string;
|
|
71
|
+
onBackground: string;
|
|
72
|
+
surface: string;
|
|
73
|
+
onSurface: string;
|
|
74
|
+
surfaceVariant: string;
|
|
75
|
+
onSurfaceVariant: string;
|
|
76
|
+
surfaceDim: string;
|
|
77
|
+
surfaceBright: string;
|
|
78
|
+
surfaceContainerLowest: string;
|
|
79
|
+
surfaceContainerLow: string;
|
|
80
|
+
surfaceContainer: string;
|
|
81
|
+
surfaceContainerHigh: string;
|
|
82
|
+
surfaceContainerHighest: string;
|
|
83
|
+
outline: string;
|
|
84
|
+
outlineVariant: string;
|
|
85
|
+
inverseSurface: string;
|
|
86
|
+
inverseOnSurface: string;
|
|
87
|
+
inversePrimary: string;
|
|
88
|
+
scrim: string;
|
|
89
|
+
shadow: string;
|
|
90
|
+
}
|
|
91
|
+
/** 生成一套完整的角色配色。`dark` 为真时返回暗色方案。 */
|
|
92
|
+
export declare function scheme(hue: number, dark?: boolean, options?: SourceOptions): Scheme;
|
|
93
|
+
/**
|
|
94
|
+
* M3 Expressive 形状刻度(px)。
|
|
95
|
+
* Expressive 把圆角整体推大了一档,容器之间靠「圆角差」而不是分隔线来分层。
|
|
96
|
+
*/
|
|
97
|
+
export declare const SHAPE: {
|
|
98
|
+
readonly none: 0;
|
|
99
|
+
readonly extraSmall: 4;
|
|
100
|
+
readonly small: 8;
|
|
101
|
+
readonly medium: 12;
|
|
102
|
+
readonly large: 16;
|
|
103
|
+
readonly largeIncreased: 20;
|
|
104
|
+
readonly extraLarge: 28;
|
|
105
|
+
readonly extraLargeIncreased: 32;
|
|
106
|
+
readonly extraExtraLarge: 48;
|
|
107
|
+
readonly full: 9999;
|
|
108
|
+
};
|
|
109
|
+
/** 正文与标题字体栈,覆盖 Windows / macOS / Linux 与随包字体三种情况。 */
|
|
110
|
+
export declare const FONT_STACK = "\"Roboto Flex\", \"Roboto\", \"Noto Sans SC\", \"PingFang SC\", \"Microsoft YaHei\", \"Source Han Sans SC\", system-ui, sans-serif";
|
|
111
|
+
/** 等宽字体栈,用于比分、倒计时这类需要对齐的数字。 */
|
|
112
|
+
export declare const MONO_STACK = "\"Roboto Mono\", \"JetBrains Mono\", \"SF Mono\", \"Cascadia Mono\", Consolas, \"Noto Sans Mono\", monospace";
|
|
113
|
+
export interface TypeStyle {
|
|
114
|
+
size: number;
|
|
115
|
+
line: number;
|
|
116
|
+
weight: number;
|
|
117
|
+
tracking: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* M3 Expressive 字阶。`emphasized` 档提高字重,用在需要被一眼看到的地方,
|
|
121
|
+
* 这是 Expressive 与基础风格最直观的差别之一。
|
|
122
|
+
*/
|
|
123
|
+
export declare const TYPE: {
|
|
124
|
+
displayLarge: {
|
|
125
|
+
size: number;
|
|
126
|
+
line: number;
|
|
127
|
+
weight: number;
|
|
128
|
+
tracking: number;
|
|
129
|
+
};
|
|
130
|
+
displayMedium: {
|
|
131
|
+
size: number;
|
|
132
|
+
line: number;
|
|
133
|
+
weight: number;
|
|
134
|
+
tracking: number;
|
|
135
|
+
};
|
|
136
|
+
displaySmall: {
|
|
137
|
+
size: number;
|
|
138
|
+
line: number;
|
|
139
|
+
weight: number;
|
|
140
|
+
tracking: number;
|
|
141
|
+
};
|
|
142
|
+
headlineLarge: {
|
|
143
|
+
size: number;
|
|
144
|
+
line: number;
|
|
145
|
+
weight: number;
|
|
146
|
+
tracking: number;
|
|
147
|
+
};
|
|
148
|
+
headlineMedium: {
|
|
149
|
+
size: number;
|
|
150
|
+
line: number;
|
|
151
|
+
weight: number;
|
|
152
|
+
tracking: number;
|
|
153
|
+
};
|
|
154
|
+
headlineSmall: {
|
|
155
|
+
size: number;
|
|
156
|
+
line: number;
|
|
157
|
+
weight: number;
|
|
158
|
+
tracking: number;
|
|
159
|
+
};
|
|
160
|
+
titleLarge: {
|
|
161
|
+
size: number;
|
|
162
|
+
line: number;
|
|
163
|
+
weight: number;
|
|
164
|
+
tracking: number;
|
|
165
|
+
};
|
|
166
|
+
titleMedium: {
|
|
167
|
+
size: number;
|
|
168
|
+
line: number;
|
|
169
|
+
weight: number;
|
|
170
|
+
tracking: number;
|
|
171
|
+
};
|
|
172
|
+
titleSmall: {
|
|
173
|
+
size: number;
|
|
174
|
+
line: number;
|
|
175
|
+
weight: number;
|
|
176
|
+
tracking: number;
|
|
177
|
+
};
|
|
178
|
+
bodyLarge: {
|
|
179
|
+
size: number;
|
|
180
|
+
line: number;
|
|
181
|
+
weight: number;
|
|
182
|
+
tracking: number;
|
|
183
|
+
};
|
|
184
|
+
bodyMedium: {
|
|
185
|
+
size: number;
|
|
186
|
+
line: number;
|
|
187
|
+
weight: number;
|
|
188
|
+
tracking: number;
|
|
189
|
+
};
|
|
190
|
+
bodySmall: {
|
|
191
|
+
size: number;
|
|
192
|
+
line: number;
|
|
193
|
+
weight: number;
|
|
194
|
+
tracking: number;
|
|
195
|
+
};
|
|
196
|
+
labelLarge: {
|
|
197
|
+
size: number;
|
|
198
|
+
line: number;
|
|
199
|
+
weight: number;
|
|
200
|
+
tracking: number;
|
|
201
|
+
};
|
|
202
|
+
labelMedium: {
|
|
203
|
+
size: number;
|
|
204
|
+
line: number;
|
|
205
|
+
weight: number;
|
|
206
|
+
tracking: number;
|
|
207
|
+
};
|
|
208
|
+
labelSmall: {
|
|
209
|
+
size: number;
|
|
210
|
+
line: number;
|
|
211
|
+
weight: number;
|
|
212
|
+
tracking: number;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Expressive 的强调字重。取 600 而非规范里的 500:很多机器上只装了 400 / 700 两档,
|
|
217
|
+
* 500 会回落成常规字重,强调就白做了;600 在这种字体集下会匹配到 700,效果才稳定。
|
|
218
|
+
* 正文维持 400,字重拉高反而伤可读性。
|
|
219
|
+
*/
|
|
220
|
+
export declare const EMPHASIZED_WEIGHT: {
|
|
221
|
+
readonly display: 600;
|
|
222
|
+
readonly headline: 600;
|
|
223
|
+
readonly title: 600;
|
|
224
|
+
readonly label: 600;
|
|
225
|
+
};
|
|
226
|
+
/** 阴影高度(dp -> box-shadow),M3 只有 0 ~ 5 六档。 */
|
|
227
|
+
export declare const ELEVATION: readonly ["none", "0 1px 2px 0 rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15)", "0 1px 2px 0 rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15)", "0 1px 3px 0 rgba(0,0,0,.30), 0 4px 8px 3px rgba(0,0,0,.15)", "0 2px 3px 0 rgba(0,0,0,.30), 0 6px 10px 4px rgba(0,0,0,.15)", "0 4px 4px 0 rgba(0,0,0,.30), 0 8px 12px 6px rgba(0,0,0,.15)"];
|
|
228
|
+
/** 把配色方案铺成 `--md-sys-color-*` 变量。 */
|
|
229
|
+
export declare function colorVars(s: Scheme): string;
|
|
230
|
+
/** 形状、字阶、高度的变量,与配色一起构成完整的令牌集。 */
|
|
231
|
+
export declare function systemVars(): string;
|
|
232
|
+
/** 一段可直接塞进 `<style>` 的基础样式:令牌 + 排版重置。 */
|
|
233
|
+
export declare function baseline(s: Scheme): string;
|
|
234
|
+
/**
|
|
235
|
+
* 通用组件样式。各插件按需挑用,命名统一为 `m3-` 前缀。
|
|
236
|
+
*
|
|
237
|
+
* Expressive 的取向体现在三处:圆角整体偏大且同一张图里刻意拉开层次、
|
|
238
|
+
* 强调元素用高彩度的容器色而不是描边、以及成组元素之间用间距而不是分隔线来断句。
|
|
239
|
+
*/
|
|
240
|
+
/** 金银铜。色调依次 58 / 66 / 48,深浅本身就排出了名次。 */
|
|
241
|
+
export declare const MEDAL: {
|
|
242
|
+
readonly gold: string;
|
|
243
|
+
readonly silver: string;
|
|
244
|
+
readonly bronze: string;
|
|
245
|
+
};
|
|
246
|
+
export declare function components(): string;
|
|
247
|
+
/**
|
|
248
|
+
* 浏览器端的配色小库,序列化进页面脚本用。
|
|
249
|
+
*
|
|
250
|
+
* 有些图是在页面里用 canvas 画的,那边拿不到这个模块。与其在客户端另写一套
|
|
251
|
+
* HSL 近似,不如把同一套 LCh 运算原样送过去——服务端与浏览器端算出来的颜色
|
|
252
|
+
* 必须一致,否则「同一支色相」的承诺在两边会对不上。
|
|
253
|
+
*
|
|
254
|
+
* 暴露的接口与本模块同名:`M3.lch` / `M3.lchOf` / `M3.harmonize`。
|
|
255
|
+
*/
|
|
256
|
+
export declare function clientColorScript(): string;
|
package/package.json
CHANGED