egatari 0.6.10 → 0.6.11-rc.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.
Files changed (124) hide show
  1. package/README.ja.md +22 -22
  2. package/README.md +1 -1
  3. package/bin/egatari.mjs +1 -1
  4. package/components.lock.json +288 -144
  5. package/components2.lock.json +657 -1
  6. package/kit/build.mjs +3 -2
  7. package/kit/check-messages.mjs +46 -12
  8. package/kit/check.mjs +54 -19
  9. package/kit/core/article-messages.mjs +5 -4
  10. package/kit/core/attachments.mjs +2 -1
  11. package/kit/core/build-core.mjs +2 -1
  12. package/kit/core/check-parity.mjs +3 -1
  13. package/kit/core/check-result.mjs +2 -1
  14. package/kit/core/check-rules.mjs +132 -0
  15. package/kit/core/colab-core.mjs +2 -2
  16. package/kit/core/geometry-check.mjs +302 -0
  17. package/kit/core/layout-scan.mjs +9 -2
  18. package/kit/core/live-results.mjs +1 -1
  19. package/kit/core/llm-fix.mjs +3 -2
  20. package/kit/core/llm-outline.mjs +3 -2
  21. package/kit/core/llm-pack-data.mjs +114 -114
  22. package/kit/core/narration-lint.mjs +37 -0
  23. package/kit/core/new-deck-pack.mjs +2 -1
  24. package/kit/core/new-deck.mjs +1 -1
  25. package/kit/core/plural.mjs +5 -0
  26. package/kit/core/portable.mjs +6 -5
  27. package/kit/core/sample-layout.mjs +14 -0
  28. package/kit/core/text-band.mjs +37 -0
  29. package/kit/core/tier-a.mjs +2 -1
  30. package/kit/instruction-version.json +1 -1
  31. package/kit/player.json +1 -1
  32. package/kit/player.lock.json +2 -2
  33. package/kit/render-compare.mjs +5 -4
  34. package/kit/tools.js +2 -2
  35. package/package.json +3 -2
  36. package/server/editor-ui.js +2 -2
  37. package/vendor/components/CATALOG.md +12 -12
  38. package/vendor/components/sha256/00d9072cb279a1a68166787f53395c747072388971d916c082a106844dbf888f/index.js +315 -0
  39. package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/README.en.md +23 -0
  40. package/vendor/components/sha256/03e20fb6803de0d94e93de7c01d7d00cede57b0b2604b449daa4cb156367500d/index.js +289 -0
  41. package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/README.en.md +40 -0
  42. package/vendor/components/sha256/0e5458deb63e32aefdbf8722fa156fd44cd90d5d8f9d6a25a636007b4b599450/index.js +341 -0
  43. package/vendor/components/sha256/1073e03374f0fe65d2691f160bfd8c092986c168d0bd6a6094ebd444d4b89c27/index.js +592 -0
  44. package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/README.en.md +48 -0
  45. package/vendor/components/sha256/12b1b32eb3a75e9f11eff407b7876473674ae996d7ce276e2ab6ffaf41ad4376/index.js +384 -0
  46. package/vendor/components/sha256/147987bd84722249dab609293d4fafa93f0a2aac25b8517fda1710840b575d00/index.js +341 -0
  47. package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/README.en.md +23 -0
  48. package/vendor/components/sha256/170e9072285213a2b4e79d7c2e4ddb882d1501e60b5da63c59b1679643163005/index.js +120 -0
  49. package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/README.en.md +32 -0
  50. package/vendor/components/sha256/17da8ef5ce58354df54ebb52c8a9b0726e69d06ac28cc8e78f807ec338002782/index.js +222 -0
  51. package/vendor/components/sha256/1b30dfd9b366ff07556024eb8ce75cca2eac8001fa392eed4e1232047001ec74/index.js +404 -0
  52. package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/README.en.md +66 -0
  53. package/vendor/components/sha256/37846655693f8dd869d11d3d4cddb43be57f848037d0e49564b2250401448ab5/index.js +920 -0
  54. package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/README.en.md +50 -0
  55. package/vendor/components/sha256/3fdd15756f779a16362dd854f143ca4343154059882d88d44adf64745c7876e3/index.js +171 -0
  56. package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/README.en.md +31 -0
  57. package/vendor/components/sha256/435c3f8e0c0abc123866e57ae2c7f3409e19d14a2eb67b1fde84c4da5d95f14c/index.js +232 -0
  58. package/vendor/components/sha256/43740da51de85c1b7ec1eaf688f93fd9ea25b15977ab075e6abac196f08643a6/index.js +122 -0
  59. package/vendor/components/sha256/4817f77bd021ec5c77d5a15ee56e2e34d31d1d98630e86225eb20f2f9bf095e9/index.js +812 -0
  60. package/vendor/components/sha256/4e4bf3b2968c36a334dc997e32e36f22ecbc4f5dfe1c76bb7a5beef002fe8899/index.js +228 -0
  61. package/vendor/components/sha256/553e132d1f84caad648bb7175a206d4c5d18c005b5ca17989f5e8a5e3f5cdfa1/index.js +75 -0
  62. package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/README.en.md +34 -0
  63. package/vendor/components/sha256/5b02d8a81a41f4d1658f1972f3fc91de3cc431b2c71bb6b92601d58f734de9ec/index.js +244 -0
  64. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/LICENSE-tabler.txt +21 -0
  65. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/index.js +4868 -0
  66. package/vendor/components/sha256/5c72414df5a948a7cbb882be1e5bdd4113d188e357d4a0f01fabda15781417eb/names.txt +4808 -0
  67. package/vendor/components/sha256/636f47e955f5550f046cfc7a3de8de70c4b97aa77771bde2ee0e31d706bb032e/index.js +278 -0
  68. package/vendor/components/sha256/65ddc34bd9c75e073f4c2cd283369417fe88769521809670c6b8730852d4f647/index.js +97 -0
  69. package/vendor/components/sha256/6b0c75b0f697fe451197301de82a113f1c2548b67f7a8d2b56576d2bae8e240c/index.js +607 -0
  70. package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/README.en.md +33 -0
  71. package/vendor/components/sha256/6cdf432d3e61be3ff15e80910369324ac7ea0e8b9f62c32ef37bf09a5bfe93b9/index.js +390 -0
  72. package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/README.en.md +31 -0
  73. package/vendor/components/sha256/6d648d0e5c96ec680c04a14b7c3d672010d3b9f101197689e9672ec00174383d/index.js +267 -0
  74. package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/README.en.md +22 -0
  75. package/vendor/components/sha256/71208afc5c8ea1ed6d2180f46de7385e43990cfb046ba350eefb917eca5d92fe/index.js +145 -0
  76. package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/README.en.md +44 -0
  77. package/vendor/components/sha256/7552a029f30f9c2f2ec8c5af4f144b63eeffc9172b53e35a925821f69a738b64/index.js +203 -0
  78. package/vendor/components/sha256/781a45d97f1325cfb40aa98d00e1db9600949158fdb2749b0223b019c67a80f2/index.js +919 -0
  79. package/vendor/components/sha256/850944419734168be3dc202057de128131869c471cb8ab3baec2cfe789d56493/index.js +465 -0
  80. package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/README.en.md +37 -0
  81. package/vendor/components/sha256/863d4d42075fbae1084089730f10da943c88d3e3e655235f28c24b9a3cf95c88/index.js +424 -0
  82. package/vendor/components/sha256/8a892d25d0bb6105ba31ea690b465876ce3af1fbaf18e2a9ce44ad2fee81260e/index.js +162 -0
  83. package/vendor/components/sha256/8acec8f299510287fbad6a69311ec58a39b0e99647dd03609c818e053b3b6087/index.js +484 -0
  84. package/vendor/components/sha256/8ef66bd1e800bcbedef436585469d308665aaa1ab6011aee699544302d0a8ad0/index.js +312 -0
  85. package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/README.en.md +40 -0
  86. package/vendor/components/sha256/8fa5ed6ab12a27542e077ff965bea626ff9450b330609304dc1148fc8dbb68b0/index.js +348 -0
  87. package/vendor/components/sha256/a0c71874d83045baaef70285bd00d87a7c6c43219fa5630dfff60d5cb08509be/index.js +250 -0
  88. package/vendor/components/sha256/a31f39625d7d1087d06a72b644cec417372f98add940288257ef07f812d8395a/index.js +747 -0
  89. package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/README.en.md +38 -0
  90. package/vendor/components/sha256/ae04a57be4a26b7443796a93c58adcf1cbcf746120eba619bf9c2bcdce53c640/index.js +289 -0
  91. package/vendor/components/sha256/ae06622a328da2a01260bc68b28bb632c391e8d62a4e8387638e5a944525a418/index.js +521 -0
  92. package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/README.en.md +24 -0
  93. package/vendor/components/sha256/b490139e9afa84164054738532d5ec4985bf071e40791d903012fe3b850bae43/index.js +103 -0
  94. package/vendor/components/sha256/b756c66d5c6e6ace90912ab467dea3031f2c9b291d8b2a786ca660faa0e8ac84/index.js +121 -0
  95. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ABCJS-ADAPTER.md +101 -0
  96. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/LICENSE-abcjs.txt +21 -0
  97. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/chords.json +89 -0
  98. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/doremi.json +261 -0
  99. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/extras.json +192 -0
  100. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/kaeru.json +521 -0
  101. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/rhythm.json +248 -0
  102. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/fixtures/ties.json +360 -0
  103. package/vendor/components/sha256/babd98da50ea334b63f79c66be436d092e8aea32654e011a6444667abb882e77/index.js +508 -0
  104. package/vendor/components/sha256/bea7cb344f55677d5756c9711b90cc971126830ec5f66a03f71f13dbfadc401e/index.js +351 -0
  105. package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/README.en.md +42 -0
  106. package/vendor/components/sha256/c08b25a2f7be68c36634cdee180aa617fd018d80b7ddf2a484a2edb4acffdbe0/index.js +268 -0
  107. package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/README.en.md +51 -0
  108. package/vendor/components/sha256/cbe8bb4b2fd0845a9333bc2064d86758ea6465992ad86a99167ba17f57f3e382/index.js +228 -0
  109. package/vendor/components/sha256/d2df3d70fc7c6e07e3cad7332a7e5501e84abeb24653786e567f57046adebcba/index.js +268 -0
  110. package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/README.en.md +35 -0
  111. package/vendor/components/sha256/d386f2b94cd9fbed765ad301aa7009228599edb2859efe7f37a98d7aaa44b9bb/index.js +179 -0
  112. package/vendor/components/sha256/e6d219f67d241fdf00a40d4cec261d9dd3c09ad3110d3418d4e843d0f2b8c196/index.js +429 -0
  113. package/vendor/components/sha256/ef60e6c089f5f6e909f439af8fc0c9c0a2d7a1aafad5e65be6328ba993b990a0/index.js +354 -0
  114. package/vendor/components/sha256/f6f47601c90f0195353e94b76d57499591d6330a7e35714958a2c41229f70da2/index.js +198 -0
  115. package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/README.en.md +44 -0
  116. package/vendor/components/sha256/f9159c87fa998487787f738fdfab52aa2483f52f170fc258840b127f6ed06051/index.js +304 -0
  117. package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/README.en.md +42 -0
  118. package/vendor/components/sha256/fb482cbe2ca1da07d08f41880e03fe75ff3f1d29842ff40946541e63030219b8/index.js +481 -0
  119. package/vendor/components/sha256/fdcea28e27638d8bfe234016672375e14de8bb97c32f7b6840d1b7b10ac4b1cd/index.js +233 -0
  120. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/LICENSE-strokesvg.txt +115 -0
  121. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/OFL.txt +93 -0
  122. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/index.js +749 -0
  123. package/vendor/components/sha256/ff5eaa083a46db6aefc13d97b27c9487f9fc318805f5c89b05a12e63703b7a72/strokes-CHANGES.md +20 -0
  124. package/vendor/components-2/manifest-2.7.0.json +2118 -0
@@ -0,0 +1,304 @@
1
+ // m-scatter:散布図。点の組(系列)を段階ごとに出し、そのあと傾向の線を引く
2
+ // <m-scatter xr="[20,36]" yr="[0,800]" xl="最高気温(℃)" yl="売上(個)" style="height:420px">
3
+ // <script type="application/json">{"series": [{"label": "晴れ", "points": [[24, 210], [31, 560]]}], "trend": "linear"}
4
+ // (JSON の終わり)</m-scatter>
5
+ // 段階:既定は系列 1 つ = 1 段階、そのあと傾向の線(全部で 1 段階)。系列・線の step で直接
6
+ // 軸の属性(xr yr xt yt xf yf xl yl)は m-curves と同じ名前と意味。xr / yr を書かなければデータから切りのよい範囲を決め、
7
+ // xt / yt を書かなければ目盛りも決める
8
+ // 見せ方(docs/conventions.md §1):fade(点がフェードして現れる、既定)・sweep(左から右へ順に現れる)・grow(点が小さい点から
9
+ // 大きくなる)。傾向の線は fade では薄く現れ、sweep では左から引き、grow では真ん中から両側へ伸びる。段階の数・長さ・最後の中身は同じ
10
+ // 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・variant・previewOpacity と plot の Plot を使い、
11
+ // プレイヤーのグローバルは使わない。名前の置き場がない・傾向の線が軸の外・上の名前が図より広い、は ctx.report で知らせる
12
+ // (1.x は console.warn)
13
+ egatariParts.define({name: "scatter", version: "2.0.5", requires: {base: "1.2.0", plot: "1.1.2"}, element: "m-scatter"}, function(deps){
14
+ "use strict";
15
+ var base = deps.base, plot = deps.plot;
16
+ return class extends base.MotionElement {
17
+ static partName = "scatter"; // the registry name (define meta name), for report prefixes
18
+ static variants = ["fade", "sweep", "grow"];
19
+ // データの形(kit/shape.js)
20
+ static shape = (function(){
21
+ // 傾向の線の 2 点:ちょうど 2 つの [x, y]
22
+ var PTS = {type: "array", minItems: 2, maxItems: 2, items: {type: "array", minItems: 2, maxItems: 2, items: {type: "number"}}};
23
+ return {
24
+ schema: {type: "object", additionalProperties: false, required: ["series"], properties: {
25
+ series: {type: "array", minItems: 1, items: {type: "object", additionalProperties: false, required: ["points"], properties: {
26
+ label: {type: "string"}, tone: {type: "string"}, step: {type: "integer"}, at: {type: "number"},
27
+ points: {type: "array", items: {type: ["array", "object"], items: {type: "number"}, minItems: 2, maxItems: 2, required: ["x", "y"],
28
+ properties: {x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, anchor: {enum: ["right", "left", "above", "below", "top", "bottom"]}, tone: {type: "string"}}}}}}},
29
+ trend: {type: ["string", "object", "array"], properties: {fit: {enum: ["linear"]}, pts: PTS, series: {type: ["integer", "array"]},
30
+ label: {type: "string"}, tone: {type: "string"}, dash: {type: "boolean"}, step: {type: "integer"}, at: {type: "number"}, digits: {type: "integer"}},
31
+ items: {type: "object", properties: {fit: {enum: ["linear"]}, pts: PTS, series: {type: ["integer", "array"]},
32
+ label: {type: "string"}, tone: {type: "string"}, dash: {type: "boolean"}, step: {type: "integer"}, at: {type: "number"}, digits: {type: "integer"}}}}}},
33
+ example: {series: [{label: "晴れ", points: [[24, 210], [28, 380], [31, 560], {x: 34, y: 690, label: "猛暑日"}]}], trend: "linear"},
34
+ note: {en: "points are [x, y] or {\"x\", \"y\", \"label\"}; axes go in attributes (xr=\"[0,10]\" xl=\"…\"); trend is \"linear\" or {\"fit\": \"linear\", \"label\": \"…\"} or {\"pts\": [[x0, y0], [x1, y1]]}",
35
+ ja: "点は [x, y] か {\"x\", \"y\", \"label\"}。軸は属性に書く(xr=\"[0,10]\" xl=\"…\")。trend は \"linear\" か {\"fit\": \"linear\", \"label\": \"…\"} か {\"pts\": [[x0, y0], [x1, y1]]}"},
36
+ };
37
+ })();
38
+ static props = {
39
+ xr: {type: "json", default: null, doc: "横軸の範囲(書かなければデータから)"}, yr: {type: "json", default: null, doc: "縦軸の範囲(書かなければデータから)"},
40
+ xt: {type: "json", default: null, doc: "横軸の目盛り(書かなければ自動)"}, yt: {type: "json", default: null, doc: "縦軸の目盛り(書かなければ自動)"},
41
+ xf: {type: "number", default: undefined, doc: "横軸の目盛りの小数桁"}, yf: {type: "number", default: undefined, doc: "縦軸の目盛りの小数桁"},
42
+ xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
43
+ r: {type: "number", default: 9, doc: "点の半径(px)"},
44
+ dur: {type: "number", default: 1.0, doc: "1 ステップの動きの秒数"},
45
+ };
46
+ get steps(){
47
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
48
+ var m = 0, pl = this.plan();
49
+ pl.series.forEach(function(s){ m = Math.max(m, s.step); });
50
+ pl.trends.forEach(function(s){ m = Math.max(m, s.step); });
51
+ return m;
52
+ }
53
+ // 系列と傾向の線の段階(mount の前にも steps が要るので、データだけから決める)
54
+ plan(){
55
+ if (this._plan) return this._plan;
56
+ var d = this.data || {}, last = 0;
57
+ var series = (d.series || []).map(function(s, i){
58
+ var step = s.step !== undefined ? s.step : i + 1;
59
+ last = Math.max(last, step);
60
+ return {s: s, i: i, step: step, at: s.at || 0};
61
+ });
62
+ var tr = d.trend === undefined || d.trend === null || d.trend === false ? [] : Array.isArray(d.trend) ? d.trend : [d.trend];
63
+ var trends = tr.map(function(t, i){
64
+ if (typeof t === "string") t = {fit: t}; // "linear" のほかは mount で知らせる(steps の計算では投げない)
65
+ return {t: t, i: i, step: t.step !== undefined ? t.step : last + 1, at: t.at || 0};
66
+ });
67
+ return (this._plan = {series: series, trends: trends});
68
+ }
69
+ mount(ctx){
70
+ var P = this.props, D = base, self = this, pl = this.plan();
71
+ this.variant = base.variant(this);
72
+ this.classList.add("plot"); this.style.display = "block";
73
+ // 字の幅(base の textWidth:テーマの字で測った幅。mtext の *_^ は数えない)
74
+ var est = function(s, size){ return D.textWidth(s, size, {font: self, mark: true}); };
75
+ var colorOf = function(c, i){
76
+ if (!c) return "var(--series-" + (i % 4 + 1) + ")";
77
+ return /^(term|emph|muted|accent2|fg|series-[1-4])$/.test(c) ? "var(--" + c + ")" : "var(--series-" + (i % 4 + 1) + ")";
78
+ };
79
+ // 点を {x, y, label, anchor, tone} にそろえる
80
+ var all = [];
81
+ pl.series.forEach(function(o){
82
+ o.pts = (o.s.points || []).map(function(q){ var p = Array.isArray(q) ? {x: +q[0], y: +q[1]} : {x: +q.x, y: +q.y, label: q.label, anchor: q.anchor, tone: q.tone}; all.push(p); return p; });
83
+ });
84
+ // 軸の範囲と目盛り:書かれていなければデータから切りのよい数に
85
+ var auto = function(vals, pad){
86
+ var lo = Math.min.apply(null, vals), hi = Math.max.apply(null, vals);
87
+ if (!isFinite(lo)) return [0, 1];
88
+ if (hi === lo){ hi += 1; lo -= 1; }
89
+ var st = tickStep((hi - lo) * (1 + 2 * pad)), a = Math.floor((lo - (hi - lo) * pad) / st) * st, b = Math.ceil((hi + (hi - lo) * pad) / st) * st;
90
+ if (lo >= 0 && a < 0) a = 0;
91
+ return [+a.toFixed(10), +b.toFixed(10)];
92
+ };
93
+ // 書かれた範囲は [小, 大] の 2 つの数のときだけ使う(1 つの数・逆向き・数でない、は知らせてデータから決める)
94
+ var range = function(name){
95
+ var v = P[name];
96
+ if (v === null || v === undefined) return null;
97
+ if (Array.isArray(v) && v.length === 2 && v.every(function(x){ return typeof x === "number" && isFinite(x); }) && v[0] < v[1]) return v;
98
+ ctx.report("attr", "[scatter] " + name + "=\"" + self.getAttribute(name) + "\" is not a range [low, high] of two numbers with low < high (the range is taken from the data)");
99
+ return null;
100
+ };
101
+ var xr = range("xr") || auto(all.map(function(p){ return p.x; }), 0.04), yr = range("yr") || auto(all.map(function(p){ return p.y; }), 0.06);
102
+ // 範囲の外の点は描かない(軸の外や枠の外に出さない)。系列ごとにまとめて知らせる
103
+ pl.series.forEach(function(o){
104
+ var outs = o.pts.filter(function(q){ return !(q.x >= xr[0] && q.x <= xr[1] && q.y >= yr[0] && q.y <= yr[1]); });
105
+ outs.forEach(function(q){ q.out = true; });
106
+ if (outs.length) ctx.report("data", "[scatter] " + outs.length + " point" + (outs.length > 1 ? "s" : "") + (o.s.label ? " of \"" + o.s.label + "\"" : " of series " + (o.i + 1)) + " lie outside xr/yr and are not drawn: " +
107
+ outs.slice(0, 3).map(function(q){ return "(" + q.x + ", " + q.y + ")"; }).join(", ") + (outs.length > 3 ? ", …" : "") + " (widen xr/yr or leave them out)");
108
+ });
109
+ var ticks = function(r){ var st = tickStep(r[1] - r[0]), out = []; for (var v = Math.ceil(r[0] / st - 1e-9) * st; v <= r[1] + st * 1e-6; v += st) out.push(+v.toFixed(10)); return out; };
110
+ var xt = P.xt || ticks(xr), yt = P.yt || ticks(yr);
111
+ var fmt = function(v, f){ return f !== undefined ? v.toFixed(f) : String(v); };
112
+ var named = pl.series.some(function(o){ return o.s.label; }) || pl.trends.some(function(o){ return o.t.label; });
113
+ var yw = Math.max.apply(null, yt.map(function(v){ return est(fmt(v, P.yf), 24); }).concat([0]));
114
+ var m = {l: Math.max(64, yw + 22 + (P.yl ? 40 : 0)), r: 24, t: named ? 72 : 20, b: P.xl ? 66 : 42};
115
+ var p = this.p = plot.Plot(this, {xr: xr, yr: yr, xt: xt, yt: yt, xf: P.xf, yf: P.yf, xl: P.xl, yl: P.yl, m: m});
116
+ p.svg.setAttribute("aria-hidden", "true");
117
+ // 軸の線(横軸と縦軸。目盛りの短い線は除く)に印を付ける(tools/test-components.mjs が字との交差を見る)
118
+ var axl = p.svg.querySelectorAll("g.axes > line");
119
+ for (var a = 0; a < Math.min(2, axl.length); a++) axl[a].setAttribute("class", "axis");
120
+ var W = p.W, H = p.H, x0 = m.l, x1 = W - m.r, y0 = m.t, y1 = H - m.b;
121
+ var gT = D.el("g", {}, p.svg), gP = D.el("g", {}, p.svg), gL = D.el("g", {}, p.svg);
122
+ var R = P.r;
123
+ if (!(typeof R === "number" && isFinite(R) && R > 0)){
124
+ ctx.report("attr", "[scatter] r=\"" + this.getAttribute("r") + "\" is not a positive number (the default radius 9 is used)");
125
+ R = 9;
126
+ }
127
+ // 系列の印の形:丸・四角・三角・ひし形(色だけに頼らない)
128
+ var shapes = [
129
+ function(r){ return "M" + r + ",0A" + r + "," + r + " 0 1,1 " + (-r) + ",0A" + r + "," + r + " 0 1,1 " + r + ",0Z"; },
130
+ function(r){ var s = r * 0.86; return "M" + (-s) + "," + (-s) + "H" + s + "V" + s + "H" + (-s) + "Z"; },
131
+ function(r){ var s = r * 1.2; return "M0," + (-s) + "L" + (s * 0.95).toFixed(2) + "," + (s * 0.62).toFixed(2) + "H" + (-s * 0.95).toFixed(2) + "Z"; },
132
+ function(r){ var s = r * 1.2; return "M0," + (-s) + "L" + s + ",0L0," + s + "L" + (-s) + ",0Z"; }];
133
+ // 置いた字と点の箱(重なりを避ける)
134
+ var boxes = [];
135
+ all.forEach(function(q){ if (!q.out) boxes.push({l: p.x(q.x) - R - 2, r: p.x(q.x) + R + 2, t: p.y(q.y) - R - 2, b: p.y(q.y) + R + 2, pt: q}); });
136
+ var hits = function(b, self2){ return boxes.some(function(o){ return o.pt !== self2 && b.l < o.r && o.l < b.r && b.t < o.b && o.t < b.b; }); };
137
+ this.series = pl.series.map(function(o){
138
+ var col = colorOf(o.s.tone, o.i), path = shapes[o.i % 4](R);
139
+ var marks = o.pts.filter(function(q){ return !q.out; }).map(function(q){
140
+ var g = D.el("g", {transform: "translate(" + p.x(q.x).toFixed(1) + " " + p.y(q.y).toFixed(1) + ")", opacity: 0}, gP);
141
+ var c = q.tone ? colorOf(q.tone, o.i) : col;
142
+ var sh = D.el("path", {d: path, fill: c, "fill-opacity": 0.85, stroke: "var(--bg)", "stroke-width": 1.5}, g);
143
+ return {q: q, g: g, sh: sh, cx: p.x(q.x), cy: p.y(q.y)};
144
+ });
145
+ // 左から右の順(sweep)
146
+ var order = marks.slice().sort(function(u, v){ return u.cx - v.cx; });
147
+ order.forEach(function(mk, j){ mk.rank = order.length > 1 ? j / (order.length - 1) : 0; });
148
+ // 名前のある点:右 → 左 → 上 → 下(anchor があればそれを先に)の順に、点・字・軸と重ならず枠に収まる所へ
149
+ var labels = marks.filter(function(mk){ return mk.q.label; }).map(function(mk){
150
+ var w = est(mk.q.label, 24), cands = {
151
+ right: {x: mk.cx + R + 8, y: mk.cy + 8, a: "start", b: {l: mk.cx + R + 6, r: mk.cx + R + 10 + w, t: mk.cy - 14, b: mk.cy + 12}},
152
+ left: {x: mk.cx - R - 8, y: mk.cy + 8, a: "end", b: {l: mk.cx - R - 10 - w, r: mk.cx - R - 6, t: mk.cy - 14, b: mk.cy + 12}},
153
+ above: {x: mk.cx, y: mk.cy - R - 10, a: "middle", b: {l: mk.cx - w / 2 - 2, r: mk.cx + w / 2 + 2, t: mk.cy - R - 34, b: mk.cy - R - 4}},
154
+ below: {x: mk.cx, y: mk.cy + R + 28, a: "middle", b: {l: mk.cx - w / 2 - 2, r: mk.cx + w / 2 + 2, t: mk.cy + R + 4, b: mk.cy + R + 34}}};
155
+ var pref = ["right", "left", "above", "below"];
156
+ var an = {top: "above", bottom: "below"}[mk.q.anchor] || mk.q.anchor; // top / bottom は above / below の別名
157
+ if (an) pref = [an].concat(pref.filter(function(x){ return x !== an; }));
158
+ var inPlot = function(b){ return b.l >= x0 + 4 && b.r <= x1 && b.t >= y0 && b.b <= y1 - 4; };
159
+ var inBox = function(b){ return b.l >= 0 && b.r <= W && b.t >= 0 && b.b <= H; };
160
+ var pick = pref.filter(function(k){ return inPlot(cands[k].b) && !hits(cands[k].b, mk.q); })[0]
161
+ || pref.filter(function(k){ return inBox(cands[k].b) && !hits(cands[k].b, mk.q); })[0];
162
+ if (!pick){ pick = pref.filter(function(k){ return inBox(cands[k].b); })[0] || pref[0]; ctx.report("layout", "[scatter] the label \"" + mk.q.label + "\" has no free place (it may overlap)"); }
163
+ var c = cands[pick];
164
+ boxes.push({l: c.b.l, r: c.b.r, t: c.b.t, b: c.b.b, pt: mk.q});
165
+ return D.mtext(gL, c.x, c.y, mk.q.label, {"text-anchor": c.a, "font-size": 24, fill: mk.q.tone ? colorOf(mk.q.tone, o.i) : "var(--fg)", opacity: 0});
166
+ });
167
+ return {o: o, col: col, path: path, marks: marks, labels: labels};
168
+ });
169
+ // 傾向の線:最小二乗の直線(fit: "linear")か、2 点(pts)
170
+ this.trends = pl.trends.map(function(o){
171
+ var t = o.t, a, b, r = null, xa, xb;
172
+ var ya, yb;
173
+ if (t.pts){
174
+ if (t.pts.length !== 2 || !t.pts.every(function(q){ return Array.isArray(q) && q.length === 2 && q.every(isFinite); }))
175
+ throw new Error("trend.pts: write two points [[x0, y0], [x1, y1]]");
176
+ xa = +t.pts[0][0]; xb = +t.pts[1][0]; ya = +t.pts[0][1]; yb = +t.pts[1][1];
177
+ if (xa === xb && ya === yb) throw new Error("trend.pts: the two points are the same (write two different points)");
178
+ // 書いた 2 点をそのまま端にする(縦の線なら傾きと切片はない)
179
+ if (xb !== xa){ a = (yb - ya) / (xb - xa); b = ya - a * xa; } else { a = null; b = null; }
180
+ } else {
181
+ if (t.fit !== undefined && t.fit !== "linear") throw new Error('trend: "' + t.fit + '" is not "linear" (write "linear", {"fit": "linear"} or {"pts": [[x0, y0], [x1, y1]]})');
182
+ var use = t.series === undefined ? pl.series : [].concat(t.series).map(function(i){ return pl.series[i]; }).filter(Boolean);
183
+ var q = [].concat.apply([], use.map(function(s){ return s.pts; }));
184
+ if (q.length < 2) throw new Error("trend: a linear fit needs two or more points");
185
+ var n = q.length, sx = 0, sy = 0;
186
+ q.forEach(function(v){ sx += v.x; sy += v.y; });
187
+ var mx = sx / n, my = sy / n, sxx = 0, sxy = 0, syy = 0;
188
+ q.forEach(function(v){ sxx += (v.x - mx) * (v.x - mx); sxy += (v.x - mx) * (v.y - my); syy += (v.y - my) * (v.y - my); });
189
+ a = sxx ? sxy / sxx : 0; b = my - a * mx;
190
+ r = sxx && syy ? sxy / Math.sqrt(sxx * syy) : 0;
191
+ xa = Math.min.apply(null, q.map(function(v){ return v.x; })); xb = Math.max.apply(null, q.map(function(v){ return v.x; }));
192
+ ya = a * xa + b; yb = a * xb + b;
193
+ }
194
+ var col = t.tone ? colorOf(t.tone, 0) : "var(--fg)";
195
+ var A = [p.x(xa), p.y(ya)], B = [p.x(xb), p.y(yb)], out = false;
196
+ // 図の枠の中に切る(Liang–Barsky。clip-path は使わない)
197
+ var u0 = 0, u1 = 1, dx = B[0] - A[0], dy = B[1] - A[1];
198
+ [[-dx, A[0] - x0], [dx, x1 - A[0]], [-dy, A[1] - y0], [dy, y1 - A[1]]].forEach(function(c){
199
+ if (c[0] === 0){ if (c[1] < 0) u1 = -1; return; }
200
+ var u = c[1] / c[0];
201
+ if (c[0] < 0) u0 = Math.max(u0, u); else u1 = Math.min(u1, u);
202
+ });
203
+ // 枠の外の線は描かない(名前も図の上に出さない)
204
+ if (u1 <= u0){ out = true; ctx.report("range", "[scatter] the trend line is outside the axes (it is not drawn)"); }
205
+ else { B = [A[0] + dx * u1, A[1] + dy * u1]; A = [A[0] + dx * u0, A[1] + dy * u0]; }
206
+ var line = D.el("path", {d: "M0,0", fill: "none", stroke: col, "stroke-width": 3.5, "stroke-linecap": "round", opacity: 0}, gT);
207
+ if (t.dash) line.setAttribute("stroke-dasharray", "12 9");
208
+ // 名前:{r} {a} {b} を相関係数・傾き・切片に置き換える(digits 桁、既定 2)
209
+ var dg = t.digits !== undefined ? t.digits : 2, num = function(v){ return v === null ? "" : (v < 0 ? "−" : "") + Math.abs(v).toFixed(dg); };
210
+ var text = String(t.label || "").replace(/\{r\}/g, num(r)).replace(/\{a\}/g, num(a)).replace(/\{b\}/g, num(b));
211
+ var len = Math.hypot(B[0] - A[0], B[1] - A[1]);
212
+ return {o: o, line: line, text: out ? "" : text, col: col, A: A, B: B, len: len, dash: !!t.dash, out: out, a: a};
213
+ });
214
+ // 系列と傾向の線の名前:図の上(右寄せ)に印と一緒に並べる(凡例の箱は作らない。点や線と重ならない)
215
+ var lx = x1, entries = this.series.filter(function(se){ return se.o.s.label; }).map(function(se){ return {it: se, text: se.o.s.label, col: se.col, path: se.path}; })
216
+ .concat(this.trends.filter(function(tr){ return tr.text; }).map(function(tr){ return {it: tr, text: tr.text, col: tr.col, line: true, dash: tr.dash}; }));
217
+ // 印を左、字をその右に置く(字の幅は見積もりなので、ずれは右端に出る)
218
+ entries.reverse().forEach(function(en){
219
+ var w = est(en.text, 24), sw = en.line ? 40 : 2 * R, sx = lx - w - 10 - sw;
220
+ var g = D.el("g", {opacity: 0}, gL);
221
+ if (en.line){
222
+ var ln = D.el("line", {x1: sx, x2: sx + sw, y1: 26, y2: 26, stroke: en.col, "stroke-width": 3.5, "stroke-linecap": "round"}, g);
223
+ if (en.dash) ln.setAttribute("stroke-dasharray", "10 7");
224
+ } else D.el("path", {d: en.path, fill: en.col, "fill-opacity": 0.85, transform: "translate(" + (sx + R).toFixed(1) + " 26)"}, g);
225
+ D.mtext(g, sx + sw + 10, 34, en.text, {"font-size": 24, "font-weight": 700, fill: en.col});
226
+ en.it.leg = g;
227
+ lx = sx - 32;
228
+ });
229
+ if (lx + 32 < 0) ctx.report("size", "[scatter] the names above the figure are wider than the figure");
230
+ // 読み上げ:最後の形(描いた点と傾向の線)を 1 文で。作者の aria-label があればそれを使う(上書きしない)
231
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
232
+ this.setAttribute("role", "img");
233
+ if (!this._aria) this.setAttribute("aria-label", this.summary(/^ja\b/i.test(ctx.lang || "ja")));
234
+ function tickStep(span){ var r = span / 5, e = Math.pow(10, Math.floor(Math.log10(r))), x = r / e;
235
+ return (x <= 1 ? 1 : x <= 2 ? 2 : x <= 2.5 ? 2.5 : x <= 5 ? 5 : 10) * e; }
236
+ }
237
+ // 最後の形を 1 文で(読み上げの名前):「散布図(横:最高気温、縦:売上):12 点(晴れ 8 点、雨 4 点)、横 24〜34、縦 210〜690、
238
+ // 猛暑日 (34, 690)、傾向の線は右上がり(r = 0.93)」。範囲の外で描かない点は数えない
239
+ summary(ja){
240
+ var P = this.props, self = this, one = function(s){ return String(s || "").replace(/\s*\n\s*/g, " ").replace(/[*_^]/g, ""); };
241
+ var ax = [P.xl ? (ja ? "横:" : "x: ") + one(P.xl) : "", P.yl ? (ja ? "縦:" : "y: ") + one(P.yl) : ""].filter(Boolean).join(ja ? "、" : ", ");
242
+ var pts = [], ss = this.series.map(function(se){ se.marks.forEach(function(mk){ pts.push(mk.q); }); return {l: se.o.s.label, n: se.marks.length}; });
243
+ var cnt = function(n){ return ja ? n + " 点" : n + (n === 1 ? " point" : " points"); };
244
+ var out = [cnt(pts.length) + (ss.length > 1 && ss.some(function(x){ return x.l; }) ? (ja ? "(" : " (") + ss.map(function(x){ return (x.l ? one(x.l) + " " : "") + cnt(x.n); }).join(ja ? "、" : ", ") + (ja ? ")" : ")") : "")];
245
+ if (pts.length){
246
+ var mm = function(f){ var v = pts.map(f), lo = Math.min.apply(null, v), hi = Math.max.apply(null, v); return lo === hi ? String(lo) : lo + (ja ? "〜" : " to ") + hi; };
247
+ out.push((ja ? "横 " : "x ") + mm(function(q){ return q.x; }), (ja ? "縦 " : "y ") + mm(function(q){ return q.y; }));
248
+ }
249
+ pts.filter(function(q){ return q.label; }).slice(0, 6).forEach(function(q){ out.push(one(q.label) + " (" + q.x + ", " + q.y + ")"); });
250
+ this.trends.forEach(function(tr){
251
+ if (tr.out) return;
252
+ var dir = tr.a === null ? (ja ? "垂直" : "vertical") : tr.a > 0 ? (ja ? "右上がり" : "rising") : tr.a < 0 ? (ja ? "右下がり" : "falling") : (ja ? "水平" : "flat");
253
+ var ts = tr.o.t.series, sn = !tr.o.t.pts && ts !== undefined && [].concat(ts).length === 1 && self.series[[].concat(ts)[0]] ? self.series[[].concat(ts)[0]].o.s.label : "";
254
+ out.push((sn ? one(sn) + (ja ? "の" : ": ") : "") + (ja ? "傾向の線は" : "the trend line is ") + dir + (tr.text ? (ja ? "(" : " (") + one(tr.text) + (ja ? ")" : ")") : ""));
255
+ });
256
+ return (ja ? "散布図" : "Scatter plot") + (ax ? (ja ? "(" + ax + ")" : " (" + ax + ")") : "") + (ja ? ":" : ": ") + out.join(ja ? "、" : ", ");
257
+ }
258
+ duration(k){
259
+ var P = this.props, d = 0, pl = this.plan();
260
+ pl.series.forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + P.dur); });
261
+ pl.trends.forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + P.dur); });
262
+ return d;
263
+ }
264
+ cues(k){
265
+ var c = [], pl = this.plan();
266
+ pl.series.concat(pl.trends).forEach(function(o){ if (o.step === k && o.at > 0 && c.indexOf(o.at) < 0) c.push(o.at); });
267
+ return c.length ? c.sort(function(a, b){ return a - b; }) : null;
268
+ }
269
+ render(k, t, ctx){
270
+ var P = this.props, D = base, vr = this.variant, dur = P.dur, lecture = !!ctx.preview, FAINT = 0.45;
271
+ if (lecture) FAINT = base.previewOpacity(this); // 先の段階の薄さ:テーマの --preview-opacity(ないときは 0.45)
272
+ // この部品の段階の中の時刻(-1 = まだ。授業の表示では先の段階を薄く見せる)
273
+ var local = function(o){ return o.step < k ? Infinity : o.step > k ? -1 : t - o.at; };
274
+ var faint = function(o){ return lecture && o.step > k; };
275
+ this.series.forEach(function(se){
276
+ var o = se.o, tt = local(o), f = faint(o), span = dur * 0.7;
277
+ se.marks.forEach(function(mk){
278
+ var op, sc = 1;
279
+ if (f){ op = FAINT; }
280
+ else if (tt < 0){ op = 0; }
281
+ else if (vr === "sweep"){ op = D.prog(tt, mk.rank * (span - 0.2), 0.2); }
282
+ else if (vr === "grow"){ sc = D.prog(tt, 0, span); op = sc > 0 ? Math.min(1, sc * 3) : 0; }
283
+ else { op = D.prog(tt, 0, span); }
284
+ mk.g.setAttribute("opacity", op.toFixed(3));
285
+ mk.g.setAttribute("transform", "translate(" + mk.cx.toFixed(1) + " " + mk.cy.toFixed(1) + ")" + (sc < 1 ? " scale(" + Math.max(0.001, sc).toFixed(4) + ")" : ""));
286
+ });
287
+ var lo = f ? FAINT : tt < 0 ? 0 : D.prog(tt, dur * 0.6, dur * 0.4);
288
+ se.labels.forEach(function(l){ l.setAttribute("opacity", lo.toFixed(3)); });
289
+ if (se.leg) se.leg.setAttribute("opacity", (f ? FAINT : tt < 0 ? 0 : D.prog(tt, 0, dur * 0.5)).toFixed(3));
290
+ });
291
+ this.trends.forEach(function(tr){
292
+ var o = tr.o, tt = local(o), f = faint(o), span = dur * 0.7, A = tr.A, B = tr.B, e = f ? 1 : tt < 0 ? 0 : D.prog(tt, 0, span);
293
+ var s0 = 0, s1 = 1, op = e > 0 ? 1 : 0;
294
+ if (!f && vr === "sweep"){ s1 = e; }
295
+ else if (!f && vr === "grow"){ s0 = 0.5 - e / 2; s1 = 0.5 + e / 2; }
296
+ else op = e;
297
+ tr.line.setAttribute("d", "M" + D.lerp(A[0], B[0], s0).toFixed(1) + "," + D.lerp(A[1], B[1], s0).toFixed(1) + "L" + D.lerp(A[0], B[0], s1).toFixed(1) + "," + D.lerp(A[1], B[1], s1).toFixed(1));
298
+ if (tr.dash) tr.line.setAttribute("stroke-dashoffset", (s0 * tr.len).toFixed(1));
299
+ tr.line.setAttribute("opacity", (tr.out ? 0 : f ? FAINT : op).toFixed(3));
300
+ if (tr.leg) tr.leg.setAttribute("opacity", (f ? FAINT : tt < 0 ? 0 : D.prog(tt, span, dur * 0.3)).toFixed(3));
301
+ });
302
+ }
303
+ };
304
+ });
@@ -0,0 +1,42 @@
1
+ ---
2
+ summary: Hierarchy tree (org chart, taxonomy), built level by level from the root; auto layout
3
+ steps: depth (by="level") or node count (by="node"); or the largest step
4
+ props:
5
+ orient: down (default) or right
6
+ by: level (default) or node (depth-first)
7
+ link: elbow (default) or straight
8
+ size: box text px (0 = 27, shrink to 24)
9
+ fade: box appear (s)
10
+ draw: line draw (s)
11
+ example: {"nodes": [{"id": "r", "label": "Animals"}, {"id": "a", "label": "Vertebrates", "parent": "r"}, {"id": "b", "label": "Invertebrates", "parent": "r"}]}
12
+ ---
13
+
14
+ Parent–child structures (org charts, taxonomies, outlines). No coordinates; laid out without overlaps.
15
+
16
+ Child JSON: `{"nodes": [...], "edges": [...]}` (`edges` optional).
17
+
18
+ - node: `id`, `label` (`\n`) or `tex` (KaTeX), `parent` (parent `id`; exactly one root without `parent`), `note` (small, **under** box), `tone` (`term` default, `emph`, `muted`, `accent2`, `series-1..4`), `step`, `at` (start s)
19
+ - Children in array order; parent centred over them
20
+ - edge: extra links (`from` `to` `label` `tone` `dash` `step`), dashed arrow outside the tree; best at same depth; step: later end
21
+ - Child `branch`: line text (e.g. probability). `path`: root-first `id`s highlighted in turn (default 1 step per line, after the tree; `pathStep`: in one step; `pathNote`: end note)
22
+ - `orient="right"` for wide taxonomies. `by="node"`: one at a time, depth-first (to follow a branch). Node `step` wins
23
+ - Lines `--muted`, 3 px; `tone: emph` box: `--emph-tint` fill
24
+ - Fit (~440 px high): ~8 four-character boxes per level (`down`), ~7 (`right`); ~5 levels. More leaves: 2 staggered rows (~16 / ~11), then 2-line names. Text ≥ 24 px; overflow spills, reported. Too many: split
25
+ - `variant`: `fade` (default), `draw` (lines first), `grow`
26
+ - Show later steps faintly (`ctx.preview`): later parts faint
27
+
28
+ The demo is `demo.html` (company and values fictional).
29
+
30
+ <!-- llm: omit -->
31
+ Notes
32
+
33
+ - Moves ≤ 12 px within `fade` time. Edge step default: later end; edges bulge outward (`down` below, `right` right)
34
+ - Layout: subtrees placed bottom-up and pushed together until level contours touch (Reingold–Tilford); small subtrees in between go left
35
+ - Text 27 → 24 px (`size` fixes it). Width estimated from characters (CJK 1, others 0.6)
36
+ - At 24 px, no smaller text (conventions §2.3); tries: stagger children of parents with ≥ 3 leaf children (not with `straight`) → wrap names (≥ 4 chars, no `\n` or `*_^`; at the middle space, or after a mid hiragana; single Latin words never). Else least-overflow layout; shortfall via `ctx.report("size", …)`
37
+ - Motion: `fade` from below; `draw`, `grow` from the parent's direction, 12 px (root always as `fade`). `grow` from 0.92×
38
+ - `branch`: 24 px, `--fg`. `elbow` bends 20 px from the parent, text on the child line; levels widen to fit (`right` +52 px, `down` ≥ 76 px); no staggering. `straight`: outside the line's middle (crowded at ≥ 3 children)
39
+ - `path`: must start at the root, each pair parent–child, else a data card. Default: one step per line after the tree's last step. `pathStep`: drawn in that step (`draw` s each). `--emph` 6 px over the line, `--emph` 4 px frame on reached boxes, `branch` in `--emph`. `pathNote` beyond the end box after the last line; may overlap if the end box is not at the deepest level
40
+ - Show later steps faintly: later path faint; `branch` colour changes only at its step
41
+ - Edges take room outside the tree (`down`: 56 px below, +36 with a label); across depths they may cross boxes
42
+ <!-- llm: end -->