koishi-plugin-wordle-game 2.9.0 → 2.10.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.js +267 -24
- package/lib/m3.d.ts +256 -0
- package/lib/services/renderer.d.ts +7 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -12362,6 +12362,252 @@ __name(generateLetterTilesHtmlForHandle, "generateLetterTilesHtmlForHandle");
|
|
|
12362
12362
|
var path = __toESM(require("path"));
|
|
12363
12363
|
var import_url = require("url");
|
|
12364
12364
|
|
|
12365
|
+
// src/m3.ts
|
|
12366
|
+
var WHITE_X = 95.047;
|
|
12367
|
+
var WHITE_Y = 100;
|
|
12368
|
+
var WHITE_Z = 108.883;
|
|
12369
|
+
function labToXyz(l, a, b) {
|
|
12370
|
+
const fy = (l + 16) / 116;
|
|
12371
|
+
const fx = fy + a / 500;
|
|
12372
|
+
const fz = fy - b / 200;
|
|
12373
|
+
const f = /* @__PURE__ */ __name((t) => t > 6 / 29 ? t * t * t : 3 * (6 / 29) ** 2 * (t - 4 / 29), "f");
|
|
12374
|
+
return [f(fx) * WHITE_X, f(fy) * WHITE_Y, f(fz) * WHITE_Z];
|
|
12375
|
+
}
|
|
12376
|
+
__name(labToXyz, "labToXyz");
|
|
12377
|
+
function gamma(value) {
|
|
12378
|
+
return value <= 31308e-7 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
12379
|
+
}
|
|
12380
|
+
__name(gamma, "gamma");
|
|
12381
|
+
function xyzToRgb(x, y, z) {
|
|
12382
|
+
x /= 100;
|
|
12383
|
+
y /= 100;
|
|
12384
|
+
z /= 100;
|
|
12385
|
+
return [
|
|
12386
|
+
gamma(3.2406 * x - 1.5372 * y - 0.4986 * z),
|
|
12387
|
+
gamma(-0.9689 * x + 1.8758 * y + 0.0415 * z),
|
|
12388
|
+
gamma(0.0557 * x - 0.204 * y + 1.057 * z)
|
|
12389
|
+
];
|
|
12390
|
+
}
|
|
12391
|
+
__name(xyzToRgb, "xyzToRgb");
|
|
12392
|
+
var EPSILON = 1 / 512;
|
|
12393
|
+
function lch(tone, chroma, hue) {
|
|
12394
|
+
const radian = hue * Math.PI / 180;
|
|
12395
|
+
const at = /* @__PURE__ */ __name((c) => xyzToRgb(...labToXyz(tone, Math.cos(radian) * c, Math.sin(radian) * c)), "at");
|
|
12396
|
+
const inGamut = /* @__PURE__ */ __name((rgb2) => rgb2.every((value) => value >= -EPSILON && value <= 1 + EPSILON), "inGamut");
|
|
12397
|
+
let rgb = at(chroma);
|
|
12398
|
+
if (!inGamut(rgb)) {
|
|
12399
|
+
let low = 0;
|
|
12400
|
+
let high = chroma;
|
|
12401
|
+
while (high - low > 0.05) {
|
|
12402
|
+
const mid = (low + high) / 2;
|
|
12403
|
+
if (inGamut(at(mid))) low = mid;
|
|
12404
|
+
else high = mid;
|
|
12405
|
+
}
|
|
12406
|
+
rgb = at(low);
|
|
12407
|
+
}
|
|
12408
|
+
return "#" + rgb.map((value) => Math.round(Math.min(1, Math.max(0, value)) * 255).toString(16).padStart(2, "0")).join("");
|
|
12409
|
+
}
|
|
12410
|
+
__name(lch, "lch");
|
|
12411
|
+
function palette(hue, chroma) {
|
|
12412
|
+
const cache = /* @__PURE__ */ new Map();
|
|
12413
|
+
return (tone) => {
|
|
12414
|
+
const hit = cache.get(tone);
|
|
12415
|
+
if (hit) return hit;
|
|
12416
|
+
const value = lch(tone, chroma, hue);
|
|
12417
|
+
cache.set(tone, value);
|
|
12418
|
+
return value;
|
|
12419
|
+
};
|
|
12420
|
+
}
|
|
12421
|
+
__name(palette, "palette");
|
|
12422
|
+
function palettesOf(hue, options = {}) {
|
|
12423
|
+
const { chroma = 56, tertiaryShift = 60 } = options;
|
|
12424
|
+
return {
|
|
12425
|
+
primary: palette(hue, chroma),
|
|
12426
|
+
secondary: palette(hue, Math.max(16, chroma / 3.2)),
|
|
12427
|
+
tertiary: palette(hue + tertiaryShift, Math.max(28, chroma / 1.8)),
|
|
12428
|
+
neutral: palette(hue, 4),
|
|
12429
|
+
neutralVariant: palette(hue, 9),
|
|
12430
|
+
error: palette(36, 68)
|
|
12431
|
+
};
|
|
12432
|
+
}
|
|
12433
|
+
__name(palettesOf, "palettesOf");
|
|
12434
|
+
function scheme(hue, dark = false, options = {}) {
|
|
12435
|
+
const p = palettesOf(hue, options);
|
|
12436
|
+
const { primary: P, secondary: S, tertiary: T, neutral: N, neutralVariant: V, error: E } = p;
|
|
12437
|
+
if (dark) {
|
|
12438
|
+
return {
|
|
12439
|
+
primary: P(80),
|
|
12440
|
+
onPrimary: P(20),
|
|
12441
|
+
primaryContainer: P(30),
|
|
12442
|
+
onPrimaryContainer: P(90),
|
|
12443
|
+
secondary: S(80),
|
|
12444
|
+
onSecondary: S(20),
|
|
12445
|
+
secondaryContainer: S(30),
|
|
12446
|
+
onSecondaryContainer: S(90),
|
|
12447
|
+
tertiary: T(80),
|
|
12448
|
+
onTertiary: T(20),
|
|
12449
|
+
tertiaryContainer: T(30),
|
|
12450
|
+
onTertiaryContainer: T(90),
|
|
12451
|
+
error: E(80),
|
|
12452
|
+
onError: E(20),
|
|
12453
|
+
errorContainer: E(30),
|
|
12454
|
+
onErrorContainer: E(90),
|
|
12455
|
+
background: N(6),
|
|
12456
|
+
onBackground: N(90),
|
|
12457
|
+
surface: N(6),
|
|
12458
|
+
onSurface: N(90),
|
|
12459
|
+
surfaceVariant: V(30),
|
|
12460
|
+
onSurfaceVariant: V(80),
|
|
12461
|
+
surfaceDim: N(6),
|
|
12462
|
+
surfaceBright: N(24),
|
|
12463
|
+
surfaceContainerLowest: N(4),
|
|
12464
|
+
surfaceContainerLow: N(10),
|
|
12465
|
+
surfaceContainer: N(12),
|
|
12466
|
+
surfaceContainerHigh: N(17),
|
|
12467
|
+
surfaceContainerHighest: N(22),
|
|
12468
|
+
outline: V(60),
|
|
12469
|
+
outlineVariant: V(30),
|
|
12470
|
+
inverseSurface: N(90),
|
|
12471
|
+
inverseOnSurface: N(20),
|
|
12472
|
+
inversePrimary: P(40),
|
|
12473
|
+
scrim: N(0),
|
|
12474
|
+
shadow: N(0)
|
|
12475
|
+
};
|
|
12476
|
+
}
|
|
12477
|
+
return {
|
|
12478
|
+
primary: P(40),
|
|
12479
|
+
onPrimary: P(100),
|
|
12480
|
+
primaryContainer: P(90),
|
|
12481
|
+
onPrimaryContainer: P(30),
|
|
12482
|
+
secondary: S(40),
|
|
12483
|
+
onSecondary: S(100),
|
|
12484
|
+
secondaryContainer: S(90),
|
|
12485
|
+
onSecondaryContainer: S(30),
|
|
12486
|
+
tertiary: T(40),
|
|
12487
|
+
onTertiary: T(100),
|
|
12488
|
+
tertiaryContainer: T(90),
|
|
12489
|
+
onTertiaryContainer: T(30),
|
|
12490
|
+
error: E(40),
|
|
12491
|
+
onError: E(100),
|
|
12492
|
+
errorContainer: E(90),
|
|
12493
|
+
onErrorContainer: E(30),
|
|
12494
|
+
background: N(98),
|
|
12495
|
+
onBackground: N(10),
|
|
12496
|
+
surface: N(98),
|
|
12497
|
+
onSurface: N(10),
|
|
12498
|
+
surfaceVariant: V(90),
|
|
12499
|
+
onSurfaceVariant: V(30),
|
|
12500
|
+
surfaceDim: N(87),
|
|
12501
|
+
surfaceBright: N(98),
|
|
12502
|
+
surfaceContainerLowest: N(100),
|
|
12503
|
+
surfaceContainerLow: N(96),
|
|
12504
|
+
surfaceContainer: N(94),
|
|
12505
|
+
surfaceContainerHigh: N(92),
|
|
12506
|
+
surfaceContainerHighest: N(90),
|
|
12507
|
+
outline: V(50),
|
|
12508
|
+
outlineVariant: V(80),
|
|
12509
|
+
inverseSurface: N(20),
|
|
12510
|
+
inverseOnSurface: N(95),
|
|
12511
|
+
inversePrimary: P(80),
|
|
12512
|
+
scrim: N(0),
|
|
12513
|
+
shadow: N(0)
|
|
12514
|
+
};
|
|
12515
|
+
}
|
|
12516
|
+
__name(scheme, "scheme");
|
|
12517
|
+
var SHAPE = {
|
|
12518
|
+
none: 0,
|
|
12519
|
+
extraSmall: 4,
|
|
12520
|
+
small: 8,
|
|
12521
|
+
medium: 12,
|
|
12522
|
+
large: 16,
|
|
12523
|
+
largeIncreased: 20,
|
|
12524
|
+
extraLarge: 28,
|
|
12525
|
+
extraLargeIncreased: 32,
|
|
12526
|
+
extraExtraLarge: 48,
|
|
12527
|
+
full: 9999
|
|
12528
|
+
};
|
|
12529
|
+
var FONT_STACK = '"Roboto Flex", "Roboto", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Source Han Sans SC", system-ui, sans-serif';
|
|
12530
|
+
var MONO_STACK = '"Roboto Mono", "JetBrains Mono", "SF Mono", "Cascadia Mono", Consolas, "Noto Sans Mono", monospace';
|
|
12531
|
+
var TYPE = {
|
|
12532
|
+
displayLarge: { size: 57, line: 64, weight: 400, tracking: -0.25 },
|
|
12533
|
+
displayMedium: { size: 45, line: 52, weight: 400, tracking: 0 },
|
|
12534
|
+
displaySmall: { size: 36, line: 44, weight: 400, tracking: 0 },
|
|
12535
|
+
headlineLarge: { size: 32, line: 40, weight: 400, tracking: 0 },
|
|
12536
|
+
headlineMedium: { size: 28, line: 36, weight: 400, tracking: 0 },
|
|
12537
|
+
headlineSmall: { size: 24, line: 32, weight: 400, tracking: 0 },
|
|
12538
|
+
titleLarge: { size: 22, line: 28, weight: 400, tracking: 0 },
|
|
12539
|
+
titleMedium: { size: 16, line: 24, weight: 500, tracking: 0.15 },
|
|
12540
|
+
titleSmall: { size: 14, line: 20, weight: 500, tracking: 0.1 },
|
|
12541
|
+
bodyLarge: { size: 16, line: 24, weight: 400, tracking: 0.5 },
|
|
12542
|
+
bodyMedium: { size: 14, line: 20, weight: 400, tracking: 0.25 },
|
|
12543
|
+
bodySmall: { size: 12, line: 16, weight: 400, tracking: 0.4 },
|
|
12544
|
+
labelLarge: { size: 14, line: 20, weight: 500, tracking: 0.1 },
|
|
12545
|
+
labelMedium: { size: 12, line: 16, weight: 500, tracking: 0.5 },
|
|
12546
|
+
labelSmall: { size: 11, line: 16, weight: 500, tracking: 0.5 }
|
|
12547
|
+
};
|
|
12548
|
+
var ELEVATION = [
|
|
12549
|
+
"none",
|
|
12550
|
+
"0 1px 2px 0 rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15)",
|
|
12551
|
+
"0 1px 2px 0 rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15)",
|
|
12552
|
+
"0 1px 3px 0 rgba(0,0,0,.30), 0 4px 8px 3px rgba(0,0,0,.15)",
|
|
12553
|
+
"0 2px 3px 0 rgba(0,0,0,.30), 0 6px 10px 4px rgba(0,0,0,.15)",
|
|
12554
|
+
"0 4px 4px 0 rgba(0,0,0,.30), 0 8px 12px 6px rgba(0,0,0,.15)"
|
|
12555
|
+
];
|
|
12556
|
+
var kebab = /* @__PURE__ */ __name((name2) => name2.replace(/[A-Z]/g, (c) => "-" + c.toLowerCase()), "kebab");
|
|
12557
|
+
function colorVars(s) {
|
|
12558
|
+
return Object.entries(s).map(([role, value]) => `--md-sys-color-${kebab(role)}:${value}`).join(";");
|
|
12559
|
+
}
|
|
12560
|
+
__name(colorVars, "colorVars");
|
|
12561
|
+
function systemVars() {
|
|
12562
|
+
const shape = Object.entries(SHAPE).map(([name2, value]) => `--md-sys-shape-corner-${kebab(name2)}:${value}px`);
|
|
12563
|
+
const elevation = ELEVATION.map((value, level) => `--md-sys-elevation-level${level}:${value}`);
|
|
12564
|
+
const type = Object.entries(TYPE).flatMap(([name2, style]) => [
|
|
12565
|
+
`--md-sys-typescale-${kebab(name2)}-size:${style.size}px`,
|
|
12566
|
+
`--md-sys-typescale-${kebab(name2)}-line-height:${style.line}px`,
|
|
12567
|
+
`--md-sys-typescale-${kebab(name2)}-weight:${style.weight}`,
|
|
12568
|
+
`--md-sys-typescale-${kebab(name2)}-tracking:${style.tracking}px`
|
|
12569
|
+
]);
|
|
12570
|
+
return [...shape, ...elevation, ...type, `--md-sys-typescale-font:${FONT_STACK}`, `--md-sys-typescale-font-mono:${MONO_STACK}`].join(";");
|
|
12571
|
+
}
|
|
12572
|
+
__name(systemVars, "systemVars");
|
|
12573
|
+
function baseline(s) {
|
|
12574
|
+
return `
|
|
12575
|
+
:root{${colorVars(s)};${systemVars()}}
|
|
12576
|
+
*,*::before,*::after{box-sizing:border-box}
|
|
12577
|
+
html,body{margin:0;padding:0}
|
|
12578
|
+
body{
|
|
12579
|
+
background:var(--md-sys-color-background);
|
|
12580
|
+
color:var(--md-sys-color-on-surface);
|
|
12581
|
+
font-family:var(--md-sys-typescale-font);
|
|
12582
|
+
font-synthesis-weight:none;
|
|
12583
|
+
-webkit-font-smoothing:antialiased;
|
|
12584
|
+
text-rendering:optimizeLegibility;
|
|
12585
|
+
font-variant-numeric:tabular-nums;
|
|
12586
|
+
}
|
|
12587
|
+
.m3-display-large{font-size:57px;line-height:64px;font-weight:600;letter-spacing:-.25px}
|
|
12588
|
+
.m3-display-medium{font-size:45px;line-height:52px;font-weight:600;letter-spacing:0}
|
|
12589
|
+
.m3-display-small{font-size:36px;line-height:44px;font-weight:600;letter-spacing:0}
|
|
12590
|
+
.m3-headline-large{font-size:32px;line-height:40px;font-weight:600;letter-spacing:0}
|
|
12591
|
+
.m3-headline-medium{font-size:28px;line-height:36px;font-weight:600;letter-spacing:0}
|
|
12592
|
+
.m3-headline-small{font-size:24px;line-height:32px;font-weight:600;letter-spacing:0}
|
|
12593
|
+
.m3-title-large{font-size:22px;line-height:28px;font-weight:600;letter-spacing:0}
|
|
12594
|
+
.m3-title-medium{font-size:16px;line-height:24px;font-weight:600;letter-spacing:.15px}
|
|
12595
|
+
.m3-title-small{font-size:14px;line-height:20px;font-weight:600;letter-spacing:.1px}
|
|
12596
|
+
.m3-body-large{font-size:16px;line-height:24px;font-weight:400;letter-spacing:.5px}
|
|
12597
|
+
.m3-body-medium{font-size:14px;line-height:20px;font-weight:400;letter-spacing:.25px}
|
|
12598
|
+
.m3-body-small{font-size:12px;line-height:16px;font-weight:400;letter-spacing:.4px}
|
|
12599
|
+
.m3-label-large{font-size:14px;line-height:20px;font-weight:600;letter-spacing:.1px}
|
|
12600
|
+
.m3-label-medium{font-size:12px;line-height:16px;font-weight:600;letter-spacing:.5px}
|
|
12601
|
+
.m3-label-small{font-size:11px;line-height:16px;font-weight:600;letter-spacing:.5px}
|
|
12602
|
+
`;
|
|
12603
|
+
}
|
|
12604
|
+
__name(baseline, "baseline");
|
|
12605
|
+
var MEDAL = {
|
|
12606
|
+
gold: lch(58, 52, 85),
|
|
12607
|
+
silver: lch(66, 5, 260),
|
|
12608
|
+
bronze: lch(48, 36, 48)
|
|
12609
|
+
};
|
|
12610
|
+
|
|
12365
12611
|
// src/html/template.ts
|
|
12366
12612
|
var htmlSuffix = `</div>
|
|
12367
12613
|
</main>
|
|
@@ -13286,6 +13532,7 @@ var defaultPinyinsHtml = ` <div grid="~ cols-2 gap-3" h-min="
|
|
|
13286
13532
|
</div>`;
|
|
13287
13533
|
|
|
13288
13534
|
// src/services/renderer.ts
|
|
13535
|
+
var HUE = 142;
|
|
13289
13536
|
async function capture(g, html, viewport, fileOrigin = false) {
|
|
13290
13537
|
const page = await g.ctx.puppeteer.page();
|
|
13291
13538
|
try {
|
|
@@ -13409,40 +13656,36 @@ async function generateHandlePinyinsImage(g, pinyinsHtml) {
|
|
|
13409
13656
|
}
|
|
13410
13657
|
__name(generateHandlePinyinsImage, "generateHandlePinyinsImage");
|
|
13411
13658
|
async function generateWordlesImage(g, htmlImgString) {
|
|
13659
|
+
const s = scheme(HUE, g.config.isDarkThemeEnabled);
|
|
13412
13660
|
const html = `<!DOCTYPE html>
|
|
13413
|
-
<html lang="
|
|
13661
|
+
<html lang="zh">
|
|
13414
13662
|
<head>
|
|
13663
|
+
<meta charset="UTF-8">
|
|
13415
13664
|
<style>
|
|
13665
|
+
${baseline(s)}
|
|
13666
|
+
body {
|
|
13667
|
+
padding: 24px;
|
|
13668
|
+
background: ${s.surface};
|
|
13669
|
+
}
|
|
13416
13670
|
.image-container {
|
|
13417
|
-
display:
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
justify-content: space-between;
|
|
13421
|
-
align-items: center;
|
|
13671
|
+
display: grid;
|
|
13672
|
+
gap: 16px;
|
|
13673
|
+
align-items: start;
|
|
13422
13674
|
}
|
|
13675
|
+
/* 四张以内两列,再多就四列——和原先按张数换宽度是同一个规则,
|
|
13676
|
+
只是交给 grid 去算,不必等 onload 再逐张改样式 */
|
|
13677
|
+
.image-container[data-dense="false"] { grid-template-columns: repeat(2, 1fr); }
|
|
13678
|
+
.image-container[data-dense="true"] { grid-template-columns: repeat(4, 1fr); }
|
|
13423
13679
|
.image-container img {
|
|
13424
|
-
|
|
13680
|
+
display: block;
|
|
13681
|
+
width: 100%;
|
|
13682
|
+
border-radius: ${SHAPE.large}px;
|
|
13683
|
+
background: ${s.surfaceContainerLow};
|
|
13425
13684
|
}
|
|
13426
13685
|
</style>
|
|
13427
|
-
<script>
|
|
13428
|
-
window.onload = function() {
|
|
13429
|
-
var imageContainer = document.querySelector('.image-container');
|
|
13430
|
-
var images = imageContainer.getElementsByTagName('img');
|
|
13431
|
-
|
|
13432
|
-
if (images.length > 4) {
|
|
13433
|
-
for (var i = 0; i < images.length; i++) {
|
|
13434
|
-
images[i].style.width = "calc(25% - 15px)";
|
|
13435
|
-
}
|
|
13436
|
-
} else {
|
|
13437
|
-
for (var i = 0; i < images.length; i++) {
|
|
13438
|
-
images[i].style.width = "calc(50% - 10px)";
|
|
13439
|
-
}
|
|
13440
|
-
}
|
|
13441
|
-
};
|
|
13442
|
-
</script>
|
|
13443
13686
|
</head>
|
|
13444
13687
|
<body>
|
|
13445
|
-
<div class="image-container">
|
|
13688
|
+
<div class="image-container" data-dense="${(htmlImgString.match(/<img/g) ?? []).length > 4}">
|
|
13446
13689
|
${htmlImgString}
|
|
13447
13690
|
</div>
|
|
13448
13691
|
</body>
|
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;
|
|
@@ -3,4 +3,11 @@ export declare function generateImage(g: GameContext, styledHtml: string, gridHt
|
|
|
3
3
|
export declare function generateImageForCiying(g: GameContext, gridHtml: string, rowNum: number): Promise<Buffer>;
|
|
4
4
|
export declare function generateImageForHandle(g: GameContext, gridHtml: string): Promise<Buffer>;
|
|
5
5
|
export declare function generateHandlePinyinsImage(g: GameContext, pinyinsHtml: string): Promise<Buffer<ArrayBufferLike>>;
|
|
6
|
+
/**
|
|
7
|
+
* 生成多词(wordles)模式的合成图。
|
|
8
|
+
*
|
|
9
|
+
* 这张页面是本插件自己的容器——里面那几张盘面分别复刻 Wordle / 汉兜 / 词影,
|
|
10
|
+
* 那是玩家要的样子,一个像素都不该改;但把它们摆在一起的这层外壳归我们,
|
|
11
|
+
* 所以走设计系统:表面色打底、盘面各自嵌进圆角容器、间距落在 4dp 栅格上。
|
|
12
|
+
*/
|
|
6
13
|
export declare function generateWordlesImage(g: GameContext, htmlImgString: string): Promise<Buffer<ArrayBufferLike>>;
|