koishi-plugin-ciyi 1.2.7 → 1.2.8

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.
Files changed (2) hide show
  1. package/lib/index.js +24 -15
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -735,7 +735,9 @@ function renderWinCard(service, opts) {
735
735
  }
736
736
  __name(renderWinCard, "renderWinCard");
737
737
  function renderRankCard(service, opts) {
738
- const innerW = s(620);
738
+ const innerW = s(640);
739
+ const rankPadX = s(32);
740
+ const rankInnerPad = s(20);
739
741
  const headerH = s(87);
740
742
  const contentGap = s(20);
741
743
  const rowH = s(52);
@@ -746,17 +748,21 @@ function renderRankCard(service, opts) {
746
748
  const contentH = opts.entries.length ? opts.entries.length * rowH + hiddenH : emptyH;
747
749
  const innerH = headerH + contentGap + contentH + footerGap + footerH;
748
750
  return toPng(service, innerW, innerH, (ctx, ix, iy, iw, ih) => {
751
+ const panelX = ix + rankPadX;
752
+ const panelW = iw - rankPadX * 2;
753
+ const contentLeft = panelX + rankInnerPad;
754
+ const contentRight = panelX + panelW - rankInnerPad;
749
755
  let y = iy + drawHeader(ctx, ix, iy, iw, "每日挑战 · 累计猜中", {
750
756
  big: String(opts.players),
751
757
  cap: "上榜人数"
752
758
  });
753
759
  y += s(20);
760
+ drawPanel(ctx, panelX, y, panelW, contentH);
754
761
  if (!opts.entries.length) {
755
- drawPanel(ctx, ix + s(22), y, iw - s(44), emptyH);
756
762
  textCenter(
757
763
  ctx,
758
764
  "榜上无名。",
759
- ix + iw / 2,
765
+ panelX + panelW / 2,
760
766
  y + s(31),
761
767
  `${s(13.5)}px ${FONT_SERIF}`,
762
768
  C.ink3
@@ -764,7 +770,7 @@ function renderRankCard(service, opts) {
764
770
  textCenter(
765
771
  ctx,
766
772
  "今日第一个猜中的人,会写在这里。",
767
- ix + iw / 2,
773
+ panelX + panelW / 2,
768
774
  y + s(61),
769
775
  `${s(13.5)}px ${FONT_SERIF}`,
770
776
  C.ink3
@@ -776,17 +782,17 @@ function renderRankCard(service, opts) {
776
782
  const midY = ry + rowH / 2;
777
783
  if (e.me) {
778
784
  ctx.fillStyle = "rgba(178,58,46,0.055)";
779
- ctx.fillRect(ix + s(22), ry, iw - s(44), rowH);
785
+ ctx.fillRect(panelX, ry, panelW, rowH);
780
786
  }
781
787
  if (i > 0) {
782
788
  ctx.strokeStyle = C.rule;
783
789
  ctx.beginPath();
784
- ctx.moveTo(ix + s(22), ry);
785
- ctx.lineTo(ix + iw - s(22), ry);
790
+ ctx.moveTo(contentLeft, ry);
791
+ ctx.lineTo(contentRight, ry);
786
792
  ctx.stroke();
787
793
  }
788
794
  const posSize = s(30);
789
- const px = ix + s(26);
795
+ const px = contentLeft;
790
796
  const py = midY - posSize / 2;
791
797
  const posColors = [
792
798
  { bg: C.seal, fg: "#F7F1E5", border: C.seal },
@@ -803,12 +809,15 @@ function renderRankCard(service, opts) {
803
809
  const nameX = px + posSize + s(14);
804
810
  const nameFont = `${s(15)}px ${FONT_SERIF}`;
805
811
  const score = String(e.score);
806
- const scoreRight = ix + iw - s(38);
807
- const scoreLeft = scoreRight - textWidth(score, s(19));
812
+ const unitFont = s(11.5);
813
+ const unitW = textWidth("次", unitFont);
814
+ const scoreFont = s(19);
815
+ const scoreRight = contentRight - unitW - s(8);
816
+ const scoreLeft = scoreRight - textWidth(score, scoreFont);
808
817
  const meWidth = e.me ? textWidth("我", s(10.5)) + s(18) : 0;
809
818
  const fittedName = ellipsize(
810
819
  name2,
811
- Math.max(0, scoreLeft - s(18) - nameX - meWidth),
820
+ Math.max(0, scoreLeft - s(16) - nameX - meWidth),
812
821
  s(15)
813
822
  );
814
823
  textLeft(ctx, fittedName, nameX, midY, nameFont, C.ink);
@@ -821,17 +830,17 @@ function renderRankCard(service, opts) {
821
830
  score,
822
831
  scoreRight,
823
832
  midY,
824
- `700 ${s(19)}px ${FONT_NUM}`,
833
+ `700 ${scoreFont}px ${FONT_NUM}`,
825
834
  C.ink
826
835
  );
827
- textRight(ctx, "次", ix + iw - s(22), midY, `${s(11.5)}px ${FONT_SERIF}`, C.ink3);
836
+ textRight(ctx, "次", contentRight, midY, `${unitFont}px ${FONT_SERIF}`, C.ink3);
828
837
  ry += rowH;
829
838
  }
830
839
  if (opts.hidden > 0) {
831
840
  textLeft(
832
841
  ctx,
833
842
  `⋯ 另有 ${opts.hidden} 人在榜`,
834
- ix + s(26),
843
+ contentLeft,
835
844
  ry + s(16),
836
845
  `${s(11.5)}px ${FONT_SERIF}`,
837
846
  C.ink3
@@ -849,7 +858,7 @@ function renderRankCard(service, opts) {
849
858
  textLeft(
850
859
  ctx,
851
860
  "每猜中一日之词,记一次",
852
- ix + s(22),
861
+ panelX,
853
862
  iy + ih - s(30),
854
863
  `${s(11.5)}px ${FONT_SERIF}`,
855
864
  C.ink3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-ciyi",
3
3
  "description": "Koishi 的词意猜词插件。",
4
- "version": "1.2.7",
4
+ "version": "1.2.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [