koishi-plugin-ciyi 1.2.0 → 1.2.2
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 +39 -30
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -417,30 +417,38 @@ function measureBoard(opts) {
|
|
|
417
417
|
return { innerW, innerH, rowH };
|
|
418
418
|
}
|
|
419
419
|
function drawBoardTable(ctx, x, y, w, opts, rowH) {
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
nb: s(74),
|
|
423
|
-
gw: s(90),
|
|
424
|
-
rk: s(86),
|
|
425
|
-
mt: s(150)
|
|
426
|
-
};
|
|
420
|
+
const accentW = s(3);
|
|
421
|
+
const gutter = s(10);
|
|
427
422
|
const tableW = w - s(44);
|
|
428
423
|
const cx = x + s(22);
|
|
424
|
+
const usable = Math.max(tableW - gutter, s(1));
|
|
425
|
+
const natural = [32, 72, 88, 72, 72, 148];
|
|
426
|
+
const naturalSum = natural.reduce((a, b) => a + b, 0);
|
|
427
|
+
const scale = usable / naturalSum;
|
|
428
|
+
const cols = {
|
|
429
|
+
no: natural[0] * scale,
|
|
430
|
+
nb: natural[1] * scale,
|
|
431
|
+
gw: natural[2] * scale,
|
|
432
|
+
rk: natural[4] * scale,
|
|
433
|
+
mt: natural[5] * scale
|
|
434
|
+
};
|
|
435
|
+
const bx = cx + gutter;
|
|
436
|
+
const nb0 = bx + cols.no;
|
|
437
|
+
const gw0 = nb0 + cols.nb;
|
|
438
|
+
const nb1 = gw0 + cols.gw;
|
|
439
|
+
const rk0 = nb1 + cols.nb;
|
|
440
|
+
const mt0 = rk0 + cols.rk;
|
|
441
|
+
const noX = bx + s(2);
|
|
442
|
+
const meterBlockW = s(88) + s(9) + textWidth("咫尺", s(12.5));
|
|
443
|
+
const mtX = mt0 + Math.max(0, (cols.mt - meterBlockW) / 2);
|
|
429
444
|
const headY = y;
|
|
430
445
|
const fs = s(10.5);
|
|
431
|
-
textLeft(ctx, "
|
|
432
|
-
textCenter(ctx, "
|
|
433
|
-
textCenter(ctx, "
|
|
434
|
-
textCenter(
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
cx + cols.no + cols.nb + cols.gw + cols.nb / 2,
|
|
438
|
-
headY,
|
|
439
|
-
`${fs}px ${FONT_SERIF}`,
|
|
440
|
-
C.ink3
|
|
441
|
-
);
|
|
442
|
-
textRight(ctx, "\u6392\u540D", cx + cols.no + cols.nb + cols.gw + cols.nb + cols.rk, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
443
|
-
textRight(ctx, "\u4EB2\u758F", cx + tableW, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
446
|
+
textLeft(ctx, "序", noX, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
447
|
+
textCenter(ctx, "更近 ◀", nb0 + cols.nb / 2, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
448
|
+
textCenter(ctx, "猜测", gw0 + cols.gw / 2, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
449
|
+
textCenter(ctx, "▶ 更远", nb1 + cols.nb / 2, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
450
|
+
textCenter(ctx, "排名", rk0 + cols.rk / 2, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
451
|
+
textCenter(ctx, "亲疏", mt0 + cols.mt / 2, headY, `${fs}px ${FONT_SERIF}`, C.ink3);
|
|
444
452
|
let ry = y + s(22);
|
|
445
453
|
let ordinal = 0;
|
|
446
454
|
for (const row of opts.rows) {
|
|
@@ -448,7 +456,7 @@ function drawBoardTable(ctx, x, y, w, opts, rowH) {
|
|
|
448
456
|
ry += s(8);
|
|
449
457
|
textCenter(
|
|
450
458
|
ctx,
|
|
451
|
-
|
|
459
|
+
`⋯ 另有 ${row.gapBefore} 词未列 ⋯`,
|
|
452
460
|
cx + tableW / 2,
|
|
453
461
|
ry + s(10),
|
|
454
462
|
`${s(11.5)}px ${FONT_SERIF}`,
|
|
@@ -470,7 +478,7 @@ function drawBoardTable(ctx, x, y, w, opts, rowH) {
|
|
|
470
478
|
ctx.fillStyle = C.fresh;
|
|
471
479
|
ctx.fillRect(cx, ry, tableW, rowH);
|
|
472
480
|
ctx.fillStyle = C.seal;
|
|
473
|
-
ctx.fillRect(cx, ry,
|
|
481
|
+
ctx.fillRect(cx, ry, accentW, rowH);
|
|
474
482
|
}
|
|
475
483
|
ctx.strokeStyle = ordinal === 1 ? C.ruleDark : C.rule;
|
|
476
484
|
ctx.lineWidth = s(1);
|
|
@@ -481,24 +489,25 @@ function drawBoardTable(ctx, x, y, w, opts, rowH) {
|
|
|
481
489
|
textLeft(
|
|
482
490
|
ctx,
|
|
483
491
|
String(ordinal).padStart(2, "0"),
|
|
484
|
-
|
|
492
|
+
noX,
|
|
485
493
|
midY,
|
|
486
494
|
`${s(13)}px ${FONT_NUM}`,
|
|
487
495
|
C.ink3
|
|
488
496
|
);
|
|
489
|
-
const nbX =
|
|
497
|
+
const nbX = nb0 + (cols.nb - gridWidth(history.leftHint, "sm")) / 2;
|
|
490
498
|
drawWordGrid(ctx, nbX, midY - s(13), history.leftHint, "sm", 0);
|
|
491
|
-
const gwX =
|
|
499
|
+
const gwX = gw0 + (cols.gw - gridWidth(history.guess, "md")) / 2;
|
|
492
500
|
drawWordGrid(ctx, gwX, midY - s(17), history.guess, "md");
|
|
493
|
-
const rbX =
|
|
501
|
+
const rbX = nb1 + (cols.nb - gridWidth(history.rightHint, "sm")) / 2;
|
|
494
502
|
drawWordGrid(ctx, rbX, midY - s(13), history.rightHint, "sm", 1);
|
|
495
|
-
const rkX = cx + cols.no + cols.nb + cols.gw + cols.nb + cols.rk;
|
|
496
503
|
const rankText = String(history.rank);
|
|
497
504
|
const rankFont = `700 ${s(21)}px ${FONT_NUM}`;
|
|
498
505
|
const rankWidth = textWidth(rankText, s(21));
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
const
|
|
506
|
+
const hashW = textWidth("#", s(13));
|
|
507
|
+
const rankBlock = hashW + s(3) + rankWidth;
|
|
508
|
+
const rankLeft = rk0 + (cols.rk - rankBlock) / 2;
|
|
509
|
+
textLeft(ctx, "#", rankLeft, midY, `${s(13)}px ${FONT_NUM}`, C.ink3);
|
|
510
|
+
textLeft(ctx, rankText, rankLeft + hashW + s(3), midY, rankFont, tier.color);
|
|
502
511
|
drawNearBar(ctx, mtX, midY, pct, tier);
|
|
503
512
|
ry += rowH;
|
|
504
513
|
}
|