@cardenelabs/cdl 0.75.0 → 0.77.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardenelabs/cdl",
3
- "version": "0.75.0",
3
+ "version": "0.77.0",
4
4
  "description": "CDL (Chainome Diagram Language). Mermaid-like declarative DSL that compiles to animated SVG diagrams. Built for blockchain / Solidity flows, generic enough for sequence / flow / state / ER / topology diagrams.",
5
5
  "license": "MIT",
6
6
  "author": "cardene777",
@@ -5,7 +5,22 @@ import { resolveChartData, type ResolvedChartDatum } from "../render/payload-bin
5
5
  import { 進みを畳む } from "./draw-progress";
6
6
  import { 名札の段をほどく } from "./label-stack";
7
7
  import { 扇形の切り抜き } from "./draw-arc";
8
- import { textWidth } from "./text-width";
8
+ import { textWidth, 縮んだ絵の字の下限 } from "./text-width";
9
+
10
+ /** 字の上下に残す余白の割合。 帯に字を収める時と同じ値を使う */
11
+ const 穴に対する上限 = 0.8;
12
+
13
+ /**
14
+ * 輪の中央に置く字の大きさ。
15
+ *
16
+ * 半径に比例させると小さい図で字が読めなくなる (実測 = 120x110 の箱で 3.00 world)。
17
+ * 下限まで戻し、**穴に入らない時だけ下限を割る** = 入らない大きさで描くと数字が輪へ
18
+ * 重なる (#891)。
19
+ */
20
+ function 中央の字(比例した大きさ: number, 穴の半径: number, 文: string): number {
21
+ const 入る大きさ = (穴の半径 * 2 * 穴に対する上限) / Math.max(textWidth(文, 1), 1e-6);
22
+ return Math.min(Math.max(比例した大きさ, 縮んだ絵の字の下限), 入る大きさ);
23
+ }
9
24
  import { 実値表記, 割合表記 } from "./chart-number";
10
25
 
11
26
  /**
@@ -182,6 +197,15 @@ export function ChartPieNode({
182
197
  const cy = PAD_TOP + chartAreaH / 2;
183
198
 
184
199
  const 前のslices = 前あり ? 輪を組む(data, cx, cy, 前の外半径, 前の内半径, 前の割合) : [];
200
+ /*
201
+ * 中央の 2 行。 字は穴に入る範囲で下限まで戻し、2 行目の位置は **字の大きさから出す**
202
+ * (#891)。 半径に比例させたままだと、下限まで戻した 1 行目と 2 行目が重なる。
203
+ */
204
+ const 穴 = 前あり ? 前の内半径 : 外の内半径;
205
+ const 合計の文 = 実値表記(Math.round(前あり ? 今の合計 : total));
206
+ const 合計の字 = 中央の字(Math.round(radius * 0.26), 穴, 合計の文);
207
+ const 見出しの字 = 中央の字(Math.round(radius * 0.12), 穴, "合計");
208
+ const 合計の下 = Math.max(Math.round(radius * 0.2), 合計の字 * 0.25 + 見出しの字 * 0.8);
185
209
  const slices = 輪を組む(data, cx, cy, radius, 外の内半径, 今の割合);
186
210
 
187
211
  /** 円がどこまで開いたか (0..1、 cdl#516)。 畳み方は `draw-progress.ts` が持つ */
@@ -301,17 +325,17 @@ export function ChartPieNode({
301
325
  x={cx}
302
326
  y={cy - 2}
303
327
  textAnchor="middle"
304
- fontSize={Math.round(radius * 0.26)}
328
+ fontSize={合計の字}
305
329
  fontWeight={600}
306
330
  fill="var(--cdl-text, #1a1f2a)"
307
331
  >
308
- {実値表記(Math.round(前あり ? 今の合計 : total))}
332
+ {合計の文}
309
333
  </text>
310
334
  <text
311
335
  x={cx}
312
- y={cy + Math.round(radius * 0.2)}
336
+ y={cy + 合計の下}
313
337
  textAnchor="middle"
314
- fontSize={Math.round(radius * 0.12)}
338
+ fontSize={見出しの字}
315
339
  fill="var(--cdl-text-dim, #5a6270)"
316
340
  >
317
341
  合計
@@ -593,6 +617,11 @@ function 表の形({ node, active, data, 割合, x0, y0, drawing, progress, inst
593
617
  const 内半径 = R * 0.58;
594
618
  const cx = PAD + R;
595
619
  const cy = node.h / 2;
620
+ // 中央の 2 行。 輪の layout と同じ決め方 (#891)
621
+ const 合計の文 = 実値表記(Math.round(data.reduce((acc, d) => acc + d.value, 0)));
622
+ const 合計の字 = 中央の字(Math.round(R * 0.26), 内半径, 合計の文);
623
+ const 見出しの字 = 中央の字(Math.round(R * 0.12), 内半径, "合計");
624
+ const 合計の下 = Math.max(Math.round(R * 0.2), 合計の字 * 0.25 + 見出しの字 * 0.8);
596
625
 
597
626
  const 表左 = node.w - PAD - 表幅;
598
627
  const 右端 = node.w - PAD;
@@ -643,17 +672,17 @@ function 表の形({ node, active, data, 割合, x0, y0, drawing, progress, inst
643
672
  x={cx}
644
673
  y={cy - 2}
645
674
  textAnchor="middle"
646
- fontSize={Math.round(R * 0.26)}
675
+ fontSize={合計の字}
647
676
  fontWeight={600}
648
677
  fill="var(--cdl-text, #1a1f2a)"
649
678
  >
650
- {実値表記(Math.round(data.reduce((acc, d) => acc + d.value, 0)))}
679
+ {合計の文}
651
680
  </text>
652
681
  <text
653
682
  x={cx}
654
- y={cy + Math.round(R * 0.2)}
683
+ y={cy + 合計の下}
655
684
  textAnchor="middle"
656
- fontSize={Math.round(R * 0.12)}
685
+ fontSize={見出しの字}
657
686
  fill="var(--cdl-text-dim, #5a6270)"
658
687
  >
659
688
  合計
@@ -39,7 +39,7 @@ const BLOCK_W = 240;
39
39
  const BLOCK_H = 220;
40
40
  /** `shape-blockchain-block` の字の指定 (#871 で打ち消しの計算に使うため定数へ出した) */
41
41
  const 見出しの字 = 13;
42
- const 名の字 = 10.5;
42
+ const 名の字 = 11;
43
43
  const 値の字 = 11;
44
44
  /** 5 行を並べる間隔と、見出しが乗る帯の高さ。 打ち消しの上限をここから出す (#871) */
45
45
  const 行の間隔 = 22;
@@ -63,12 +63,12 @@ const CHAIN_TEXT_W = CHAIN_BLOCK_W - 8;
63
63
  /** 箱の中の 2 行 (中央の記号と下の字) の baseline の間隔 */
64
64
  const CHAIN_ROW_GAP = 14;
65
65
  /** 連鎖の箱の中の字の指定 (#887 で打ち消しの計算に使うため定数へ出した) */
66
- const CHAIN_NO_SIZE = 10;
66
+ const CHAIN_NO_SIZE = 11;
67
67
  const CONTRACT_CALL_SIZE = 11;
68
68
  const NFT_ID_SIZE = 15;
69
- const CHAIN_HASH_SIZE = 7;
70
- const BTC_NO_SIZE = 9;
71
- const ETH_NO_SIZE = 9;
69
+ const CHAIN_HASH_SIZE = 11;
70
+ const BTC_NO_SIZE = 11;
71
+ const ETH_NO_SIZE = 11;
72
72
 
73
73
  const NODE_HEX_R = 44;
74
74
  const NODE_PEER_R = 12;
@@ -583,15 +583,20 @@ export function ShapeEthereumChainNode({ node, active }: ShapeProps): JSX.Elemen
583
583
  const totalW = blockCount * blockW + (blockCount - 1) * linkW;
584
584
  const startX = cx - totalW / 2;
585
585
  /*
586
- * **番号は打ち消さない** (#887)。 6 桁の番号は指定 9 でも幅の見積りが 46 になり、
587
- * 箱の中で字が使える幅 42 (`CHAIN_TEXT_W`) を縮む前から超えている = 打ち消す余地が無い
588
- * (`textWidth` は等幅の指定を無視して比例の書体で測る。 dragon の `cdl-theme.css` が
589
- * `--d-body` を `!important` で当てるため、描かれるのは比例の書体になる)。
586
+ * 打ち消しの上限を出す帯 (#888)。 番号は箱の下半分に置き、ロゴとの間隔 20 に収まる。
590
587
  *
591
- * 4 桁の `shape-bitcoin-chain` は同じ帯に収まるので打ち消しに乗っている。
592
- * 縮む前から帯を超えていること自体は別の課題 (cardene777/cdl#885 と同じ形)。
588
+ * **ロゴは打ち消さない** (絵で、字ではない)。
589
+ *
590
+ * #887 では 6 桁 (`#21400`) の幅 56.8 が帯 42 を縮む前から超えていたため打ち消しに
591
+ * 乗せられなかった。 番号を 3 桁に揃えて 37.8 に収めたので、他の 2 つの連鎖と同じ
592
+ * 扱いに戻した。
593
593
  */
594
- const art = (
594
+ const 打ち消す字ら: 打ち消す字[] = [
595
+ { text: "#214", size: ETH_NO_SIZE, 帯: { 幅: CHAIN_TEXT_W, 高さ: 20 } },
596
+ ];
597
+ const art = (倍率: number): JSX.Element => {
598
+ const 倍 = 打ち消しの倍率(倍率, 打ち消す字ら);
599
+ return (
595
600
  <g>
596
601
  {Array.from({ length: blockCount }, (_, i) => i).map((i) => {
597
602
  const bx = startX + i * (blockW + linkW);
@@ -616,14 +621,15 @@ export function ShapeEthereumChainNode({ node, active }: ShapeProps): JSX.Elemen
616
621
  />
617
622
  {/* Ethereum Diamond ロゴ */}
618
623
  <EthereumDiamond cx={bx + blockW / 2} cy={cy - 6} h={16} colors={iconColors} />
619
- <text data-cdl-counter-scaled="0" x={bx + blockW / 2} y={cy + 22} fontSize={ETH_NO_SIZE} fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontWeight={700} textAnchor="middle" fill={isCurrent ? "#ffffff" : "var(--cdl-text-dim, #5a6270)"}>
620
- #{21_400 + i}
624
+ <text data-cdl-counter-scaled="1" x={bx + blockW / 2} y={cy + 22} fontSize={ETH_NO_SIZE * 倍} fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace" fontWeight={700} textAnchor="middle" fill={isCurrent ? "#ffffff" : "var(--cdl-text-dim, #5a6270)"}>
625
+ #{214 + i}
621
626
  </text>
622
627
  </g>
623
628
  );
624
629
  })}
625
630
  </g>
626
- );
631
+ );
632
+ };
627
633
  return (
628
634
  <g>
629
635
  {fitArt(r, chainExtent(), art)}
@@ -215,6 +215,8 @@ export function ShapeStorefrontNode({ node, active, lang }: ShapeProps): JSX.Ele
215
215
  const doorH = facadeH - 30;
216
216
  const doorX = x + bw - doorW - 12;
217
217
  const doorY = facadeY + 20;
218
+ // 営業中の札。 扉より広げない = 扉の外へ貼り出すと店の絵が壊れる
219
+ const 札幅 = Math.min(doorW - 6, 50);
218
220
  return (
219
221
  <g>
220
222
  {/* drop shadow */}
@@ -239,9 +241,9 @@ export function ShapeStorefrontNode({ node, active, lang }: ShapeProps): JSX.Ele
239
241
  {/* door の水平 line 装飾 */}
240
242
  <line x1={doorX + 4} y1={doorY + doorH * 0.38} x2={doorX + doorW - 4} y2={doorY + doorH * 0.38} stroke={accentDarker} strokeWidth={1} />
241
243
  <line x1={doorX + 4} y1={doorY + doorH * 0.72} x2={doorX + doorW - 4} y2={doorY + doorH * 0.72} stroke={accentDarker} strokeWidth={1} />
242
- {/* OPEN sign (door 下部に貼付) */}
243
- <rect x={doorX + doorW / 2 - 20} y={doorY + doorH * 0.85} width={40} height={12} fill="#e5c07b" stroke="#a67c00" strokeWidth={1.5} />
244
- <text x={doorX + doorW / 2} y={doorY + doorH * 0.85 + 9} fontSize={8} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#5a3a10">{字引("storefront.open")}</text>
244
+ {/* OPEN sign (door 下部に貼付)。 札は字に合わせる = 指定 11 の `OPEN` は字間 1 で幅 41.8 (#888) */}
245
+ <rect x={doorX + doorW / 2 - 札幅 / 2} y={doorY + doorH * 0.85} width={札幅} height={16} fill="#e5c07b" stroke="#a67c00" strokeWidth={1.5} />
246
+ <text x={doorX + doorW / 2} y={doorY + doorH * 0.85 + 11} fontSize={11} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#5a3a10">{字引("storefront.open")}</text>
245
247
  {/* door handle (小さな dot) */}
246
248
  <circle cx={doorX + 6} cy={doorY + doorH * 0.55} r={1.5} fill="#c15a4a" />
247
249
  {/* base 床 (前 storefront 直下のみ) */}
@@ -344,7 +344,7 @@ export function ShapePaymentProviderNode({ node, active, lang }: ShapeProps): JS
344
344
  <text x={cx} y={cy + 9} fontSize={13} fontWeight={700} textAnchor="middle" fill={accentDarker} fontFamily="Georgia, serif">$</text>
345
345
  </g>
346
346
  {/* PROCESSING label */}
347
- <text x={cx} y={y + boxH - 16} fontSize={9} fontWeight={700} letterSpacing={2} textAnchor="middle" fill="#a4b5f2">{字引("paymentProvider.status")}</text>
347
+ <text x={cx} y={y + boxH - 16} fontSize={11} fontWeight={700} letterSpacing={2} textAnchor="middle" fill="#a4b5f2">{字引("paymentProvider.status")}</text>
348
348
  {bottomLabel(node, r.cx, r.label)}
349
349
  </g>
350
350
  );
@@ -398,15 +398,20 @@ export function ShapeCreditCardNode({ node, active }: ShapeProps): JSX.Element {
398
398
  *
399
399
  * 影と床帯はビルの外へ出る。 出る量は箱の高さに依らないので、 描ける帯を先に狭める。
400
400
  */
401
- const BROKERAGE_TICK_H = 12;
401
+ const BROKERAGE_TICK_H = 18;
402
402
  const BROKERAGE_LOGO_H = 26;
403
- /** 電光掲示板の内側の帯と、そこに流れる相場の字の指定。 */
404
- const BROKERAGE_TICK_INNER_H = 8;
405
- const BROKERAGE_TICKER_SIZE = 5.5;
403
+ /**
404
+ * 電光掲示板の内側の帯と、そこに流れる相場の字の指定。
405
+ *
406
+ * 帯の高さは **字の指定から決める** (#888)。 打ち消しの上限は `帯の高さ x 0.8 / 指定` なので、
407
+ * 帯が `指定 x 0.8` を下回ると上限が 1 を切り、打ち消しが 1 度も効かなくなる。
408
+ */
409
+ const BROKERAGE_TICKER_SIZE = 11;
410
+ const BROKERAGE_TICK_INNER_H = 14;
406
411
  /** ロゴ帯の看板の字の指定。 */
407
412
  const BROKERAGE_SIGN_SIZE = 12;
408
413
  /** 窓の格子。 上端はロゴ帯の下、 下端は基壇の上。 */
409
- const BROKERAGE_GRID_TOP = 62;
414
+ const BROKERAGE_GRID_TOP = 68;
410
415
  const BROKERAGE_CELL_W = 14;
411
416
  const BROKERAGE_CELL_H = 18;
412
417
  const BROKERAGE_GAP_X = 8;
@@ -490,13 +495,13 @@ export function ShapeBrokerageNode({ node, active, lang }: ShapeProps): JSX.Elem
490
495
  <rect x={x - BROKERAGE_SHADE_OUT} y={y} width={BROKERAGE_SHADE_OUT * 2} height={h} fill={accentDarker} />
491
496
  {/* 上部電光掲示板 tick */}
492
497
  <rect x={x} y={y} width={w} height={BROKERAGE_TICK_H} fill="#0f1830" stroke="none" />
493
- <rect x={x + 2} y={y + 2} width={w - 4} height={8} fill="#1a2340" stroke="none" />
494
- <text data-cdl-counter-scaled="1" x={cx} y={y + 9} fontSize={BROKERAGE_TICKER_SIZE * 倍} fontWeight={700} textAnchor="middle" fill="#4ea36a" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace">
498
+ <rect x={x + 2} y={y + 2} width={w - 4} height={BROKERAGE_TICK_INNER_H} fill="#1a2340" stroke="none" />
499
+ <text data-cdl-counter-scaled="1" x={cx} y={y + 12} fontSize={BROKERAGE_TICKER_SIZE * 倍} fontWeight={700} textAnchor="middle" fill="#4ea36a" fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace">
495
500
  {字引("brokerage.ticker")}
496
501
  </text>
497
502
  {/* $ SECURITIES ロゴ帯 */}
498
503
  <rect x={x} y={y + BROKERAGE_TICK_H} width={w} height={BROKERAGE_LOGO_H} fill="#e5c07b" stroke="none" />
499
- <text data-cdl-counter-scaled="0" x={cx} y={y + 30} fontSize={BROKERAGE_SIGN_SIZE} fontWeight={700} letterSpacing={2.5} textAnchor="middle" fill="#0f1830">
504
+ <text data-cdl-counter-scaled="0" x={cx} y={y + BROKERAGE_TICK_H + 18} fontSize={BROKERAGE_SIGN_SIZE} fontWeight={700} letterSpacing={2.5} textAnchor="middle" fill="#0f1830">
500
505
  {字引("brokerage.sign")}
501
506
  </text>
502
507
  {/* window grid (段数は高さ次第、 列は 6 固定) */}
@@ -529,8 +534,10 @@ export function ShapeBrokerageNode({ node, active, lang }: ShapeProps): JSX.Elem
529
534
  }
530
535
 
531
536
  /** shape-exchange = E2-A 中央 clearing house (hexagon EXCHANGE + 放射 8 node + 双方向 tx dots) */
532
- /** 六角形の下に置く清算の字の指定。 */
533
- const EXCHANGE_SUB_SIZE = 8;
537
+ /** 六角形の中に置く清算の字の指定。 */
538
+ const EXCHANGE_SUB_SIZE = 11;
539
+ /** 中央の六角形の外接半径。 看板の字 (指定 11、 字間 1 で幅 83.7) が入る大きさから決めた (#888)。 */
540
+ const EXCHANGE_HEX_R = 52;
534
541
 
535
542
  export function ShapeExchangeNode({ node, active, lang }: ShapeProps): JSX.Element {
536
543
  const 字引 = 字引きを作る(lang);
@@ -553,7 +560,15 @@ export function ShapeExchangeNode({ node, active, lang }: ShapeProps): JSX.Eleme
553
560
  };
554
561
  });
555
562
  // 中央 hexagon = 縦向き正六角形 (上下に頂点、 30° 回転)
556
- const hexR = 45;
563
+ const hexR = EXCHANGE_HEX_R;
564
+ /**
565
+ * 六角形の中で、中心から縦に `d` 離れた高さに引ける横幅。
566
+ *
567
+ * 上下の頂点へ向かって細るので、字の帯を `hexR * 2` で見積もると入らない字を入ると
568
+ * 判定する。 **字の下端の高さで測る** = そこが字の占める範囲でいちばん狭い (#888)。
569
+ */
570
+ const 六角の横幅 = (d: number): number =>
571
+ hexR * Math.sqrt(3) * Math.min(1, Math.max(0, (hexR - Math.abs(d)) / (hexR / 2)));
557
572
  const hexPoints = [-90, -30, 30, 90, 150, 210].map((deg) => {
558
573
  const rad = (deg * Math.PI) / 180;
559
574
  return { x: cx + Math.cos(rad) * hexR, y: cy + Math.sin(rad) * hexR };
@@ -570,7 +585,7 @@ export function ShapeExchangeNode({ node, active, lang }: ShapeProps): JSX.Eleme
570
585
  */
571
586
  const 節点 = Math.max(0, nodeR) + 8 + 1.5 / 2;
572
587
  const 六角 = hexR + frame.strokeWidth / 2;
573
- const 字下 = 26 + EXCHANGE_SUB_SIZE * 0.25;
588
+ const 字下 = 28 + EXCHANGE_SUB_SIZE * 0.25;
574
589
  const 外 = Math.max(節点, 六角);
575
590
  const ずれ = cy - r.cy;
576
591
  const 広がり = {
@@ -580,14 +595,19 @@ export function ShapeExchangeNode({ node, active, lang }: ShapeProps): JSX.Eleme
580
595
  右: 外,
581
596
  };
582
597
  /*
583
- * 打ち消しの上限を出す帯 (#887)。 清算の字は六角形の下の空いた所に置くので、幅は絵の横幅を
584
- * そのまま使える。 高さは字の下の余り (`字下`) に合わせて 14 を採る。
598
+ * 打ち消しの上限を出す帯 (#887)。 清算の字は六角形の下寄りに置くので、幅はその高さで
599
+ * 引ける横幅を採る (#888 で `外 * 2` から改めた。 絵の横幅は六角形の外まで含むため、
600
+ * 入らない字を入ると判定していた)。 高さは記号との間隔に合わせて 14 を採る。
585
601
  *
586
- * **看板 `EXCHANGE` と記号 `⇄` は打ち消さない**。 前者は字間 2 を持ち幅が字数に比例し、
602
+ * **看板 `EXCHANGE` と記号 `⇄` は打ち消さない**。 前者は字間 1 を持ち幅が字数に比例し、
587
603
  * 後者は六角形の中に余白を持たない。
588
604
  */
589
605
  const 打ち消す字ら: 打ち消す字[] = [
590
- { text: 字引("exchange.sub"), size: EXCHANGE_SUB_SIZE, 帯: { 幅: 外 * 2, 高さ: 14 } },
606
+ {
607
+ text: 字引("exchange.sub"),
608
+ size: EXCHANGE_SUB_SIZE,
609
+ 帯: { 幅: 六角の横幅(字下), 高さ: 14 },
610
+ },
591
611
  ];
592
612
  const 絵 = (倍率: number): JSX.Element => {
593
613
  const 倍 = 打ち消しの倍率(倍率, 打ち消す字ら);
@@ -609,11 +629,11 @@ export function ShapeExchangeNode({ node, active, lang }: ShapeProps): JSX.Eleme
609
629
  })}
610
630
  {/* 中央 hexagon EXCHANGE (単色 #255a7a、 縦向き正六角形) */}
611
631
  <path d={hexPath} fill="#255a7a" stroke={accentDarker} strokeWidth={frame.strokeWidth} strokeLinejoin="round" />
612
- <text data-cdl-counter-scaled="0" x={cx} y={cy - 8} fontSize={10} fontWeight={700} letterSpacing={2} textAnchor="middle" fill="#e5c07b">{字引("exchange.sign")}</text>
632
+ <text data-cdl-counter-scaled="0" x={cx} y={cy - 10} fontSize={11} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#e5c07b">{字引("exchange.sign")}</text>
613
633
  {/* swap 記号 */}
614
634
  <text data-cdl-counter-scaled="0" data-cdl-role="node-body" x={cx} y={cy + 12} fontSize={22} fontWeight={700} textAnchor="middle" fill="#e5c07b">⇄</text>
615
635
  {/* clearing label */}
616
- <text data-cdl-counter-scaled="1" x={cx} y={cy + 26} fontSize={EXCHANGE_SUB_SIZE * 倍} fontWeight={700} textAnchor="middle" fill="#a4b5f2">{字引("exchange.sub")}</text>
636
+ <text data-cdl-counter-scaled="1" x={cx} y={cy + 28} fontSize={EXCHANGE_SUB_SIZE * 倍} fontWeight={700} textAnchor="middle" fill="#a4b5f2">{字引("exchange.sub")}</text>
617
637
  {/* 8 外周 node (buyer/seller) */}
618
638
  {nodes.map((n, i) => (
619
639
  <circle key={`n${i}`} cx={n.cx} cy={n.cy} r={8} fill={n.fill} stroke={accentDarker} strokeWidth={1.5} />
@@ -650,12 +670,22 @@ const ATM_SHADOW_RX_RATIO = 0.6;
650
670
  const ATM_FLOOR_UP = 6;
651
671
  const ATM_FLOOR_H = 10;
652
672
  const ATM_FLOOR_RESERVE = 12;
653
- /** 操作面の自然な大きさ。 これより本体が小さければ丸ごと縮める。 */
654
- const ATM_PANEL_W = 140;
673
+ /**
674
+ * 操作面の自然な大きさ。 これより本体が小さければ丸ごと縮める。
675
+ *
676
+ * 幅は **画面の字から決める** (#888)。 画面でいちばん長い `SELECT AMOUNT` は指定 11 で
677
+ * 幅 119.6 になり、画面の内側 (`ATM_PANEL_W - 16`) から左右 4 ずつ空ける分を足すと 136 要る。
678
+ */
679
+ const ATM_PANEL_W = 152;
655
680
  const ATM_PANEL_H = 146;
656
- /** 全体の幅。 上限は今までと同じ 140。 */
681
+ /**
682
+ * 全体の幅。
683
+ *
684
+ * 上限を操作面と同じにする = 上限が操作面より狭いと `面` が 1 を切り、操作面の字が
685
+ * どんな箱でも指定より小さく描かれる (#888)。
686
+ */
657
687
  const ATM_W_MIN = 100;
658
- const ATM_W_MAX = 140;
688
+ const ATM_W_MAX = ATM_PANEL_W;
659
689
  /** 全体の高さの下限。 看板 + 間 + 本体 30 + 床帯。 */
660
690
  const ATM_H_MIN = ATM_SIGN_H + ATM_SIGN_GAP + 30 + ATM_FLOOR_RESERVE;
661
691
 
@@ -698,15 +728,13 @@ export function ShapeAtmNode({ node, active, lang }: ShapeProps): JSX.Element {
698
728
  const 面 = Math.min(1, atmW / ATM_PANEL_W, atmH / ATM_PANEL_H);
699
729
  const 面左 = -ATM_PANEL_W / 2;
700
730
  /*
701
- * **操作面の字は打ち消さない** (#887)。 画面は高さ 52 に 3 行 (指定 10 / 8 / 10) を詰めており、
702
- * 行の間隔が 12 から 14 しか無い = 指定 10 の字に対して行の間隔の 8 割を割る
703
- * (12 * 0.8 / 10 = 0.96)。 打ち消すと上下の行か画面の枠に触れる。
704
- *
705
- * 1 行だけ除いて残りを戻す形も採らない = 画面の 3 行は 1 つのまとまりなので、`¥ 20,000` だけ
706
- * 戻さないと金額が見出しより小さくなる。 鍵盤の数字 (18x10 の鍵に入る絵) と天井看板
707
- * (字間 2 を持ち幅が字数に比例する) も据え置く。
731
+ * **操作面の字は打ち消さない** (#887 / #888)。 打ち消しの倍率は絵に 1 つで、いちばん余白の
732
+ * 無い字が全体の上限を決める。 鍵盤は 18x10 の鍵に数字を載せるため余白が無く
733
+ * (10 * 0.8 / 7 = 1.14 に対し幅は 18 / 字の幅)、鍵を含む操作面では上限が 1 前後に張り付く。
734
+ * 乗せても倍率が動かないので、印だけ付けて空回りさせない。
708
735
  *
709
- * 縮む前から画面の字が読める大きさに届かないこと自体は別の課題 (cardene777/cdl#888)。
736
+ * 画面の 3 行とカード投入口の札は #888 で指定 11 に上げた。 行の間隔は 14 で、
737
+ * 指定 11 の字 (上 7.9 / 下 2.8) が上下の行にも画面の枠にも触れない。
710
738
  */
711
739
  const 絵 = (
712
740
  <g>
@@ -720,9 +748,9 @@ export function ShapeAtmNode({ node, active, lang }: ShapeProps): JSX.Element {
720
748
  <g transform={`translate(${centerX} ${atmY}) scale(${面})`}>
721
749
  {/* screen */}
722
750
  <rect x={面左 + 8} y={10} width={ATM_PANEL_W - 16} height={52} rx={3} fill="#0f1830" stroke="#000" strokeWidth={1.5} />
723
- <text data-cdl-counter-scaled="0" x={0} y={30} fontSize={10} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#e5c07b">お引出し</text>
724
- <text data-cdl-counter-scaled="0" x={0} y={44} fontSize={8} fontWeight={700} textAnchor="middle" fill="#a4b5f2">{字引("atm.screen")}</text>
725
- <text data-cdl-counter-scaled="0" x={0} y={56} fontSize={10} fontWeight={700} textAnchor="middle" fill="#4ea36a">¥ 20,000</text>
751
+ <text data-cdl-counter-scaled="0" x={0} y={28} fontSize={11} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#e5c07b">お引出し</text>
752
+ <text data-cdl-counter-scaled="0" x={0} y={42} fontSize={11} fontWeight={700} textAnchor="middle" fill="#a4b5f2">{字引("atm.screen")}</text>
753
+ <text data-cdl-counter-scaled="0" x={0} y={56} fontSize={11} fontWeight={700} textAnchor="middle" fill="#4ea36a">¥ 20,000</text>
726
754
  {/* keypad 5x2 */}
727
755
  <rect x={面左 + 8} y={68} width={ATM_PANEL_W - 16} height={42} rx={2} fill="#8b949e" stroke="#5a6270" strokeWidth={1} />
728
756
  {(() => {
@@ -733,7 +761,7 @@ export function ShapeAtmNode({ node, active, lang }: ShapeProps): JSX.Element {
733
761
  const keyW = 18;
734
762
  const keyH = 10;
735
763
  const keyGap = 4;
736
- const startX = 面左 + 14;
764
+ const startX = 面左 + (ATM_PANEL_W - (5 * keyW + 4 * keyGap)) / 2;
737
765
  return keys.map((k, i) => {
738
766
  const row = Math.floor(i / 5);
739
767
  const col = i % 5;
@@ -750,7 +778,7 @@ export function ShapeAtmNode({ node, active, lang }: ShapeProps): JSX.Element {
750
778
  {/* card slot */}
751
779
  <rect x={面左 + 12} y={116} width={ATM_PANEL_W - 24} height={8} rx={1.5} fill="#0f1830" stroke={accentDarker} strokeWidth={1} />
752
780
  <rect x={面左 + 15} y={118} width={ATM_PANEL_W - 30} height={4} rx={0.5} fill="#e5c07b" />
753
- <text data-cdl-counter-scaled="0" x={0} y={132} fontSize={6} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#e5c07b">{字引("atm.cardSlot")}</text>
781
+ <text data-cdl-counter-scaled="0" x={0} y={132} fontSize={11} fontWeight={700} letterSpacing={1} textAnchor="middle" fill="#e5c07b">{字引("atm.cardSlot")}</text>
754
782
  {/* cash slot */}
755
783
  <rect x={面左 + 12} y={136} width={ATM_PANEL_W - 24} height={4} rx={1} fill="#0f1830" />
756
784
  </g>
@@ -1,6 +1,7 @@
1
1
  import type { JSX } from "react";
2
2
  import type { LaidNode } from "../types";
3
3
  import { 字引きを作る, type CdlLang } from "../lang";
4
+ import { 打ち消しの倍率, type 打ち消す字 } from "./shape-region";
4
5
 
5
6
  /**
6
7
  * Shape-driven software 6 kinds (CAR-1111 Phase 2-B)。
@@ -217,6 +218,8 @@ export function ShapeTerminalNode({ node, active, lang }: ShapeProps): JSX.Eleme
217
218
  const lineFont = "ui-monospace, SFMono-Regular, Menlo, monospace";
218
219
  const 余白 = 16;
219
220
  const 帯 = 28;
221
+ // 帯の名札の指定。 中の行と揃える = 1 つだけ小さいと縮んだ箱で真っ先に読めなくなる (#891)
222
+ const 帯の字 = 12.5;
220
223
  const 角 = 10;
221
224
  const 先頭 = 26;
222
225
  const 行間 = 22;
@@ -226,7 +229,7 @@ export function ShapeTerminalNode({ node, active, lang }: ShapeProps): JSX.Eleme
226
229
  { 左: 16, 字: 12.5, 色: "#7cd88f", 文: "$" },
227
230
  { 左: 30, 字: 12.5, 色: "#e6edf3", 文: "pnpm build" },
228
231
  ],
229
- [{ 左: 16, 字: 12, 色: "#8b95a5", 文: 字引("terminal.output") }],
232
+ [{ 左: 16, 字: 12.5, 色: "#8b95a5", 文: 字引("terminal.output") }],
230
233
  [{ 左: 16, 字: 12.5, 色: "#7cd88f", 文: "$" }],
231
234
  ];
232
235
  // 中身は自分の座標で描くため、 本体に入る倍率を出せるよう最長行から自然幅を求める。
@@ -266,7 +269,7 @@ export function ShapeTerminalNode({ node, active, lang }: ShapeProps): JSX.Eleme
266
269
  <text
267
270
  x={x + w / 2}
268
271
  y={y + barH / 2 + 4 * 倍}
269
- fontSize={11 * 倍}
272
+ fontSize={帯の字 * 倍}
270
273
  fontFamily={lineFont}
271
274
  textAnchor="middle"
272
275
  fill="#7a8290"
@@ -355,6 +358,8 @@ export function ShapeCodeBlockNode({ node, active, lang }: ShapeProps): JSX.Elem
355
358
  const 太さ = 9;
356
359
  const 隙間 = 6;
357
360
  const 持ち上げ = 8;
361
+ // 行番号の指定。 溝 (幅 24) に 9.46、行の間隔 (20) に 10.7 で収まる (#891 で 10.5 から)
362
+ const 行番号の字 = 11;
358
363
  const lines = [
359
364
  [
360
365
  { c: "#c678dd", w: 40 },
@@ -377,20 +382,30 @@ export function ShapeCodeBlockNode({ node, active, lang }: ShapeProps): JSX.Elem
377
382
  { c: "#e6edf3", w: 40 },
378
383
  ],
379
384
  ];
380
- const 最長 = Math.max(
381
- ...lines.map(
382
- (tokens) => tokens.reduce((sum, token) => sum + token.w, 0) + 隙間 * (tokens.length - 1),
383
- ),
384
- );
385
- // 中身は自分の座標で描くため、 本体に入る倍率を出せるよう最長行から自然幅を求める。
386
- const 自然幅 = 溝 + 字下げ + 最長 + 余白;
387
385
  // 最終行の token と行番号まで入る自然高を使い、 縦にも同じ倍率を適用できるようにする。
388
386
  const 自然高 =
389
- タブ高 + 行頭 + 行間 * (lines.length - 1) + Math.max(太さ - 持ち上げ, 10.5 * DESCENT);
390
- // 右 132 のはみ出しは、 中の行を本体へ縦横同率で収めて直す。
391
- // fitArt で絵ごと縮めると tab の字と行番号が読めなくなるため使わない。
392
- // 幅 300・高さ 200 では倍率が 1 のままなので、 従来値を保つ。
393
- const 倍 = Math.min(1, w / 自然幅, bodyH / 自然高);
387
+ タブ高 + 行頭 + 行間 * (lines.length - 1) + Math.max(太さ - 持ち上げ, 行番号の字 * DESCENT);
388
+ /*
389
+ * 倍率は **高さだけから出す** (#891)。
390
+ *
391
+ * 行の帯は code の見た目を作る飾りで、 いちばん長い行は 228 ある。 幅も倍率に入れると
392
+ * 飾りの長さが字の大きさを決めてしまい、 120x110 の箱で行番号が 4.33 world まで落ちた。
393
+ * 狭い箱では帯を縮めず **本体の右端で切る** = 実際の editor も長い行を切って見せる。
394
+ *
395
+ * 幅 300・高さ 200 では倍率が 1 のままなので、 従来値を保つ。
396
+ */
397
+ const 倍 = Math.min(1, bodyH / 自然高);
398
+ /*
399
+ * 縮んだ分を字の指定で打ち消す (#891、 仕組みは #886 と同じ)。
400
+ *
401
+ * 帯は tab の札 (幅 `タブ幅` / 高さ `タブ高`) と、行番号が乗る溝 (幅 `溝 - 持ち上げ` /
402
+ * 高さ `行間`)。 絵に 1 つの倍率なので、狭い方が全体の上限になる。
403
+ */
404
+ const 打ち消す字ら: 打ち消す字[] = [
405
+ { text: 字引("codeBlock.fileName"), size: 11, 帯: { 幅: タブ幅, 高さ: タブ高 } },
406
+ { text: "1", size: 行番号の字, 帯: { 幅: 溝 - 持ち上げ, 高さ: 行間 } },
407
+ ];
408
+ const 倍返し = 打ち消しの倍率(倍, 打ち消す字ら);
394
409
  const tabW = タブ幅 * 倍;
395
410
  const tabH = タブ高 * 倍;
396
411
  const 丸 = 角 * 倍;
@@ -421,9 +436,10 @@ export function ShapeCodeBlockNode({ node, active, lang }: ShapeProps): JSX.Elem
421
436
  />
422
437
  <path d={`M ${x} ${y + tabH} L ${x + w} ${y + tabH}`} stroke="#2a3140" strokeWidth={1} />
423
438
  <text
439
+ data-cdl-counter-scaled="1"
424
440
  x={x + tabW / 2}
425
441
  y={y + tabH / 2 + 4 * 倍}
426
- fontSize={11 * 倍}
442
+ fontSize={11 * 倍 * 倍返し}
427
443
  fontFamily={lineFont}
428
444
  textAnchor="middle"
429
445
  fill="#e6edf3"
@@ -441,9 +457,10 @@ export function ShapeCodeBlockNode({ node, active, lang }: ShapeProps): JSX.Elem
441
457
  return (
442
458
  <g key={i}>
443
459
  <text
460
+ data-cdl-counter-scaled="1"
444
461
  x={x + gutterW - 持ち上げ * 倍}
445
462
  y={codeY0 + i * lineH}
446
- fontSize={10.5 * 倍}
463
+ fontSize={行番号の字 * 倍 * 倍返し}
447
464
  fontFamily={lineFont}
448
465
  textAnchor="end"
449
466
  fill="#4a5266"
@@ -451,19 +468,22 @@ export function ShapeCodeBlockNode({ node, active, lang }: ShapeProps): JSX.Elem
451
468
  {i + 1}
452
469
  </text>
453
470
  {toks.map((t, j) => {
454
- const rect = (
455
- <rect
456
- key={j}
457
- x={cursor}
458
- y={codeY0 + i * lineH - 持ち上げ * 倍}
459
- width={t.w * 倍}
460
- height={太さ * 倍}
461
- rx={2 * 倍}
462
- fill={t.c}
463
- fillOpacity={0.85}
464
- stroke="none"
465
- />
466
- );
471
+ // 本体の右端で切る。 端から出る帯は幅を詰め、端の外から始まる帯は描かない
472
+ const 描く幅 = Math.min(t.w * 倍, x + w - 余白 * 倍 - cursor);
473
+ const rect =
474
+ 描く幅 > 0 ? (
475
+ <rect
476
+ key={j}
477
+ x={cursor}
478
+ y={codeY0 + i * lineH - 持ち上げ * 倍}
479
+ width={描く幅}
480
+ height={太さ * 倍}
481
+ rx={2 * 倍}
482
+ fill={t.c}
483
+ fillOpacity={0.85}
484
+ stroke="none"
485
+ />
486
+ ) : null;
467
487
  cursor += (t.w + 隙間) * 倍;
468
488
  return rect;
469
489
  })}
@@ -512,21 +532,38 @@ export function ShapeKanbanCardNode({ node, active, lang }: ShapeProps): JSX.Ele
512
532
  const w = Math.max(0, node.w - 線 * 2 - 影);
513
533
  const h = Math.max(0, node.h - 線 * 2 - 影);
514
534
  const 帯間余白 = 4;
515
- const 左右余白 = 14;
516
- const 上段隙間 = 8;
535
+ /*
536
+ * 上段 (`ID` と状態の札) の寸法は **字の下限から逆算する** (#891)。
537
+ *
538
+ * 札の中身は縦横まとめて `倍` で縮むので、字の大きさは `指定 x 倍` になる。
539
+ * 120x110 の箱では描ける幅が 112.8 しか無く、指定 11 の字を 8 world に保つには
540
+ * 上段の自然幅を 155 以下に収める必要がある (112.8 / (8 / 11) = 155.1)。
541
+ *
542
+ * 変更前は 166.8 で、字が 7.44 world まで落ちていた。
543
+ */
544
+ const 左右余白 = 12;
545
+ const 上段隙間 = 6;
517
546
  const 優先帯高 = 10;
518
547
  const ID文 = 字引("kanbanCard.id");
519
548
  const ID基準 = 30;
520
549
  const ID字 = 11;
521
550
  const ID字間 = 1;
522
551
  const PILL上 = 20;
523
- const PILL幅 = 54;
552
+ // 札の幅は状態の字から決める = 指定 11 の `IN PROG` は幅 55.4、丸い端に触れない余白を足す (#888)
553
+ const PILL幅 = 62;
524
554
  const PILL高 = 16;
525
- const PILL字 = 9;
555
+ const PILL字 = 11;
556
+ /*
557
+ * 状態の字に字間を置かない (#891)。 字間は幅を字数に比例して伸ばすため、札を 8 広げないと
558
+ * 収まらない。 その 8 は上段の自然幅に乗り、120x110 の箱で全部の字を 0.4 world 下げる。
559
+ */
560
+ const PILL字間 = 0;
526
561
  const FOOTER下 = 22;
527
562
  const AVATAR中心Y = 4;
528
563
  const AVATAR半径 = 9;
529
564
  const AVATAR枠 = 1.5;
565
+ // 頭文字の指定。 半径 9 の丸の内側 (一辺 12.7) に 9.46 x 10.7 で収まる (#891 で 10 から)
566
+ const AVATAR字 = 11;
530
567
  const 名前字 = 17;
531
568
  const 説明基準比 = 20 / 17;
532
569
  const 説明字比 = 12 / 17;
@@ -608,7 +645,7 @@ export function ShapeKanbanCardNode({ node, active, lang }: ShapeProps): JSX.Ele
608
645
  y={pillY + 12 * 倍}
609
646
  fontSize={PILL字 * 倍}
610
647
  fontWeight={700}
611
- letterSpacing={1 * 倍}
648
+ letterSpacing={PILL字間 * 倍}
612
649
  textAnchor="middle"
613
650
  fill="#5a4a1a"
614
651
  fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace"
@@ -650,7 +687,7 @@ export function ShapeKanbanCardNode({ node, active, lang }: ShapeProps): JSX.Ele
650
687
  <text
651
688
  x={9 * 倍}
652
689
  y={8 * 倍}
653
- fontSize={10 * 倍}
690
+ fontSize={AVATAR字 * 倍}
654
691
  fontWeight={700}
655
692
  textAnchor="middle"
656
693
  fill="#ffffff"
@@ -669,7 +706,7 @@ export function ShapeKanbanCardNode({ node, active, lang }: ShapeProps): JSX.Ele
669
706
  <text
670
707
  x={23 * 倍}
671
708
  y={8 * 倍}
672
- fontSize={10 * 倍}
709
+ fontSize={AVATAR字 * 倍}
673
710
  fontWeight={700}
674
711
  textAnchor="middle"
675
712
  fill="#ffffff"
@@ -71,3 +71,15 @@ export function textWidth(s: string, size: number, 字送り = 0): number {
71
71
  }
72
72
  return 幅 * size + 字送り * 字数;
73
73
  }
74
+
75
+ /**
76
+ * 縮んだ絵の中の字の下限 (world 座標、 #891)。
77
+ *
78
+ * 箱に合わせて中身を縮める種別は、倍率をそのまま字へ掛けると読めない大きさまで落ちる
79
+ * (実測 = 120x110 の箱で 3.00 world)。 **入れ物に入る限りはここまでで止める**。
80
+ *
81
+ * 絵が縮まない箱の下限 (11) とは別の値で、そちらは検査側
82
+ * (`test/art-text-declarations.ts` の `絵の中の字の下限`) が持つ。 縮んだ箱では帯が
83
+ * 上限を決めるため 11 に届かないことがあり、2 つを同じ値にはできない。
84
+ */
85
+ export const 縮んだ絵の字の下限 = 8;