koishi-plugin-vsinger-gacha 1.5.0 → 1.5.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/lib/handbook.js +5 -2
- package/lib/render/kit.js +11 -8
- package/package.json +1 -1
package/lib/handbook.js
CHANGED
|
@@ -207,7 +207,10 @@ async function render({ game, store, uid, displayName, outDir, tagsDir, thumbsDi
|
|
|
207
207
|
for (let pi = 0; pi < parts.length; pi++) {
|
|
208
208
|
const part = parts[pi];
|
|
209
209
|
const W = PAD * 2 + part.length * COLW + (part.length - 1) * GAP * 2;
|
|
210
|
-
|
|
210
|
+
// 头部高度随图标自适应(避免标题压到第一个系列条)
|
|
211
|
+
const _R = Math.max(26, Math.min(72, Math.round(W * 0.017)));
|
|
212
|
+
const HEADY = Math.max(HEAD, 34 + _R * 2 + 40);
|
|
213
|
+
const H = HEADY + Math.max(...part.map((c) => c.reduce((a, b) => a + b.h, 0))) + 70;
|
|
211
214
|
const canvas = Canvas.createCanvas(W, H);
|
|
212
215
|
const g = canvas.getContext('2d');
|
|
213
216
|
|
|
@@ -235,7 +238,7 @@ async function render({ game, store, uid, displayName, outDir, tagsDir, thumbsDi
|
|
|
235
238
|
for (let ci = 0; ci < part.length; ci++) {
|
|
236
239
|
const grp = part[ci];
|
|
237
240
|
const x0 = PAD + ci * (COLW + GAP * 2);
|
|
238
|
-
let y =
|
|
241
|
+
let y = HEADY;
|
|
239
242
|
let prevAct = null;
|
|
240
243
|
for (const blk of grp) {
|
|
241
244
|
if (blk.act !== prevAct) {
|
package/lib/render/kit.js
CHANGED
|
@@ -75,32 +75,35 @@ function header(g, o) {
|
|
|
75
75
|
const y = o.y;
|
|
76
76
|
const W = o.W;
|
|
77
77
|
|
|
78
|
-
//
|
|
79
|
-
const R =
|
|
78
|
+
// 圆形图标(按画布宽度自适应,图鉴这种大图不至于看着小)
|
|
79
|
+
const R = Math.max(26, Math.min(64, Math.round(W * 0.015)));
|
|
80
80
|
const cx = x + R;
|
|
81
|
-
const cy = y + R;
|
|
81
|
+
const cy = y + R + 2;
|
|
82
82
|
g.save();
|
|
83
83
|
g.beginPath();
|
|
84
84
|
g.arc(cx, cy, R, 0, Math.PI * 2);
|
|
85
85
|
g.fillStyle = COLOR.accent;
|
|
86
86
|
g.fill();
|
|
87
87
|
g.fillStyle = '#fff';
|
|
88
|
-
g.font = `bold
|
|
88
|
+
g.font = `bold ${Math.round(R * 1.15)}px ${FONT}`;
|
|
89
89
|
g.textAlign = 'center';
|
|
90
90
|
g.textBaseline = 'middle';
|
|
91
|
-
g.fillText('♪', cx, cy +
|
|
91
|
+
g.fillText('♪', cx, cy + Math.round(R * 0.04));
|
|
92
92
|
g.textAlign = 'left';
|
|
93
93
|
g.restore();
|
|
94
94
|
|
|
95
95
|
g.textBaseline = 'top';
|
|
96
96
|
g.fillStyle = COLOR.text;
|
|
97
97
|
g.font = `bold ${FONT_SIZE.h1}px ${FONT}`;
|
|
98
|
-
|
|
98
|
+
const titleSize = Math.max(FONT_SIZE.h1, Math.round(R * 1.0));
|
|
99
|
+
g.font = `bold ${titleSize}px ${FONT}`;
|
|
100
|
+
g.fillText(fit(g, o.title, `bold ${titleSize}px ${FONT}`, W - 300), x + R * 2 + 18, y + Math.max(0, R - 24));
|
|
99
101
|
|
|
100
102
|
if (o.subtitle) {
|
|
103
|
+
const subSize = Math.max(FONT_SIZE.body, Math.round(R * 0.62));
|
|
101
104
|
g.fillStyle = COLOR.textSub;
|
|
102
|
-
g.font = `${
|
|
103
|
-
g.fillText(o.subtitle, x + R * 2 +
|
|
105
|
+
g.font = `${subSize}px ${FONT}`;
|
|
106
|
+
g.fillText(o.subtitle, x + R * 2 + 18, y + Math.max(40, R * 2 - 8));
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
// 右侧徽章
|