egatari 0.6.17 → 0.6.18

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 (137) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/README.ja.md +14 -13
  3. package/README.md +2 -1
  4. package/components.lock.json +119 -45
  5. package/components2.lock.json +639 -1
  6. package/kit/check-messages.mjs +5 -0
  7. package/kit/check.mjs +6 -0
  8. package/kit/core/bookmark.mjs +28 -0
  9. package/kit/core/build-core.mjs +4 -2
  10. package/kit/core/check-parity.mjs +4 -0
  11. package/kit/core/check-rules.mjs +3 -2
  12. package/kit/core/check-source.mjs +6 -0
  13. package/kit/core/llm-pack-assemble.mjs +37 -66
  14. package/kit/core/llm-pack-data.mjs +839 -45
  15. package/kit/core/llm-pack.mjs +6 -4
  16. package/kit/core/llm-request.mjs +2 -2
  17. package/kit/core/new-deck-pack.mjs +38 -44
  18. package/kit/core/new-deck.mjs +82 -74
  19. package/kit/core/part-labels.mjs +2 -0
  20. package/kit/core/purposes.mjs +9 -3
  21. package/kit/core/sample-info.mjs +17 -3
  22. package/kit/core/slide-ops.mjs +22 -0
  23. package/kit/core/tate-mix.mjs +25 -0
  24. package/kit/core/theme-derive.mjs +56 -17
  25. package/kit/core/theme-shapes.mjs +15 -1
  26. package/kit/deck.js +53 -2
  27. package/kit/instruction-version.json +1 -1
  28. package/kit/llm-pack.mjs +5 -7
  29. package/kit/player.json +1 -1
  30. package/kit/player.lock.json +2 -2
  31. package/kit/presenter.js +36 -4
  32. package/kit/tools.js +54 -2
  33. package/package.json +1 -1
  34. package/vendor/components/CATALOG.md +24 -22
  35. package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
  36. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
  37. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
  38. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
  39. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
  40. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
  41. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
  42. package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
  43. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
  44. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
  45. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
  46. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
  47. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
  48. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
  49. package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
  50. package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
  51. package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
  52. package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
  53. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
  54. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
  55. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
  56. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
  57. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
  58. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
  59. package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
  60. package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
  61. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
  62. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
  63. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
  64. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
  65. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
  66. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
  67. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
  68. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
  69. package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
  70. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
  71. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
  72. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
  73. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
  74. package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
  75. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
  76. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
  77. package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
  78. package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
  79. package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
  80. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
  81. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
  82. package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
  83. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
  84. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
  85. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
  86. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
  87. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
  88. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
  89. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
  90. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
  91. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
  92. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
  93. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
  94. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
  95. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
  96. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
  97. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
  98. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
  99. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
  100. package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
  101. package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
  102. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
  103. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
  104. package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
  105. package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
  106. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
  107. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
  108. package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
  109. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
  110. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
  111. package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
  112. package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
  113. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
  114. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
  115. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
  116. package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
  117. package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
  118. package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
  119. package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
  120. package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
  121. package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
  122. package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
  123. package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
  124. package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
  125. package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
  126. package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
  127. package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
  128. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
  129. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
  130. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
  131. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
  132. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
  133. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
  134. package/vendor/components-2/manifest-2.16.0.json +2919 -0
  135. package/vendor/components-2/manifest-2.17.0.json +2852 -0
  136. package/vendor/components-2/manifest-2.18.0.json +3182 -0
  137. package/vendor/egatari-spec/SOURCE.json +2 -2
@@ -0,0 +1,322 @@
1
+ // m-classify2d:2 次元の分類の図を、scikit-learn が出した値のとおりに描く。点・領域(格子の上の predict)・境界・
2
+ // 確率や決定関数の等高線(contour-core)・サポートベクトル・ボロノイ図(パーツが種の点から計算)・決定木の分割・k 平均法。
3
+ // 値は tools/sk2ega.py の出力を書く。パーツはモデルの計算をしない(k 平均法の割り当てと重心だけ確かめる)。
4
+ // <m-classify2d style="height:440px"><script type="application/json">
5
+ // {"axes": {"x": {"label": "x₁", "range": [-3, 3]}, "y": {"label": "x₂", "range": [-2, 2]}},
6
+ // "classes": [{"id": 0, "label": "A"}, {"id": 1, "label": "B"}], "points": [[0.4, 1.2, 1], [-1.1, 0.3, 0]],
7
+ // "grid": {"nx": 60, "ny": 40, "labels": "0*35 1*25 …"}}
8
+ // (JSON の終わり)</m-classify2d>
9
+ // 格子:x は range を nx 点、y は ny 点に等分した点(両端を含む。numpy の linspace と meshgrid)。labels と fields の値は行ごと
10
+ // (行 0 が y の最小)。labels は 2 次元の配列か「クラス*個数」を空白で区切った行の順の続け書き。
11
+ // 色:クラスごとに CLASS_COLORS(--series-1・--series-3・--fg・--series-4)と点の形(○・□・△・◇。色だけに頼らない)、領域はその色の薄い塗り、境界と等高線 --fg、
12
+ // サポートベクトルの輪 --fg(クラスの色と --emph が近いテーマでも紛れない)、k 平均法の重心は × の印。
13
+ egatariParts.define({name: "classify2d", version: "2.0.1", requires: {base: "1.3.0", "contour-core": "1.0.0"}, element: "m-classify2d"}, function(deps){
14
+ "use strict";
15
+ var base = deps.base, D = base, K = deps["contour-core"], clipN = 0;
16
+ var NUM = {type: "number"}, PT = {type: "array", minItems: 2, maxItems: 3, items: {type: ["number", "null"]}};
17
+ var CAP = {classes: 4, points: 300, nx: 160, ny: 120, seeds: 40, nodes: 31, iters: 10, levels: 5};
18
+ var SHAPES = ["circle", "square", "triangle", "diamond"];
19
+ // クラスの色の並び(m-folds の classes と同じ。1 つの意味に 1 つの色):--series-2 は印の色 --emph と同じテーマがあるので使わない。
20
+ // 既定のテーマでは --series-3 = --accent2、--series-4 = --muted なので、3 つ目は --fg(4 つ目の --muted は、k 平均法のまだ割り当てていない点と同じ色)
21
+ var CLASS_COLORS = ["var(--series-1)", "var(--series-3)", "var(--fg)", "var(--series-4)"];
22
+ var T = {
23
+ ja: {summary: function(c, n){ return "分類の図:クラス " + c.join("・") + "、点 " + n + " 個"; }, regions: "領域", tree: "決定木の分割", kmeans: function(n){ return "k 平均法(" + n + " 回の繰り返し)"; }, sv: "サポートベクトル"},
24
+ en: {summary: function(c, n){ return "Classification: classes " + c.join(", ") + "; " + n + " points"; }, regions: "regions", tree: "decision tree splits", kmeans: function(n){ return "k-means (" + n + " iterations)"; }, sv: "support vectors"}
25
+ };
26
+ function nice(lo, hi, n){
27
+ var span = hi - lo, raw = span / Math.max(1, n), p = Math.pow(10, Math.floor(Math.log10(raw))), m = raw / p, st = (m < 1.5 ? 1 : m < 3 ? 2 : m < 7 ? 5 : 10) * p, out = [];
28
+ for (var v = Math.ceil(lo / st - 1e-9) * st; v <= hi + 1e-9 * span; v += st) out.push(Math.abs(v) < st * 1e-9 ? 0 : v);
29
+ return {ticks: out, step: st};
30
+ }
31
+ function fmt(v, st){ var d = Math.max(0, -Math.floor(Math.log10(st) + 1e-9)); var s = v.toFixed(Math.min(4, d)); return s.indexOf("-") === 0 ? "−" + s.slice(1) : s; }
32
+ function rle(s){ var out = []; String(s).trim().split(/\s+/).forEach(function(tok){ var m = /^(-?\d+)\*(\d+)$/.exec(tok); if (m){ for (var i = 0; i < +m[2]; i++) out.push(+m[1]); } else if (/^-?\d+$/.test(tok)) out.push(+tok); else out.push(NaN); }); return out; }
33
+ // 種の点 s のボロノイ領域:長方形を、ほかの種との垂直二等分線で切っていく(半平面の切り取り)
34
+ function cell(seeds, s, rect){
35
+ var poly = [[rect[0], rect[2]], [rect[1], rect[2]], [rect[1], rect[3]], [rect[0], rect[3]]], p = seeds[s];
36
+ for (var o = 0; o < seeds.length && poly.length; o++){
37
+ if (o === s) continue;
38
+ var q = seeds[o], nx = q[0] - p[0], ny = q[1] - p[1], c = (q[0] * q[0] + q[1] * q[1] - p[0] * p[0] - p[1] * p[1]) / 2;
39
+ if (!nx && !ny) continue;
40
+ var inside = function(v){ return v[0] * nx + v[1] * ny <= c + 1e-12; }, out = [];
41
+ for (var i = 0; i < poly.length; i++){
42
+ var a = poly[i], b = poly[(i + 1) % poly.length], ia = inside(a), ib = inside(b);
43
+ if (ia) out.push(a);
44
+ if (ia !== ib){ var da = a[0] * nx + a[1] * ny - c, db = b[0] * nx + b[1] * ny - c, u = da / (da - db); out.push([a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u]); }
45
+ }
46
+ poly = out;
47
+ }
48
+ return poly;
49
+ }
50
+ return class extends base.MotionElement {
51
+ static partName = "classify2d";
52
+ static preview = "none";
53
+ static shape = {schema: {type: "object", additionalProperties: false, required: ["axes", "points"], properties: {
54
+ axes: {type: "object", additionalProperties: false, required: ["x", "y"], properties: {
55
+ x: {type: "object", additionalProperties: false, required: ["range"], properties: {label: {type: "string"}, range: {type: "array", minItems: 2, maxItems: 2, items: NUM}}},
56
+ y: {type: "object", additionalProperties: false, required: ["range"], properties: {label: {type: "string"}, range: {type: "array", minItems: 2, maxItems: 2, items: NUM}}}}},
57
+ classes: {type: "array", minItems: 1, maxItems: 4, items: {type: "object", additionalProperties: false, required: ["id"], properties: {id: {type: "integer"}, label: {type: "string"}}}},
58
+ points: {type: "array", minItems: 1, maxItems: 300, items: PT},
59
+ grid: {type: "object", additionalProperties: false, required: ["nx", "ny"], properties: {nx: {type: "integer"}, ny: {type: "integer"}, labels: {type: ["string", "array"]}}},
60
+ fields: {type: "array", maxItems: 2, items: {type: "object", additionalProperties: false, required: ["values", "levels"], properties: {
61
+ name: {type: "string"}, class: {type: "integer"}, values: {type: "array"}, levels: {type: "array", minItems: 1, maxItems: 5, items: NUM}, style: {type: "array", items: {type: "string", enum: ["solid", "dash"]}}, labels: {type: "boolean"}}}},
62
+ sv: {type: "array", items: {type: "integer"}},
63
+ voronoi: {type: "object", additionalProperties: false, required: ["seeds"], properties: {seeds: {type: "array", minItems: 1, maxItems: 40, items: PT}}},
64
+ tree: {type: "object", additionalProperties: false, required: ["nodes"], properties: {nodes: {type: "array", minItems: 1, maxItems: 31, items: {type: "object", additionalProperties: false, required: ["id"], properties: {
65
+ id: {type: "string"}, feature: {type: "integer", enum: [0, 1]}, threshold: NUM, left: {type: "string"}, right: {type: "string"}, class: {type: "integer"}}}}}},
66
+ kmeans: {type: "object", additionalProperties: false, required: ["iters"], properties: {iters: {type: "array", minItems: 1, maxItems: 10, items: {type: "object", additionalProperties: false, required: ["centroids", "assign"], properties: {
67
+ centroids: {type: "array", minItems: 1, maxItems: 4, items: {type: "array", minItems: 2, maxItems: 2, items: NUM}}, assign: {type: "array", items: {type: "integer"}}}}}}}
68
+ }}, example: /*@egatari-block example*/{"axes":{"x":{"label":"x₁","range":[0,4]},"y":{"label":"x₂","range":[0,3]}},"classes":[{"id":0,"label":"A"},{"id":1,"label":"B"}],"points":[[1,1,0],[1.2,2,0],[2.8,1.1,1],[3.1,2.4,1]],"grid":{"nx":5,"ny":4,"labels":"0*2 1*3 0*2 1*3 0*2 1*3 0*3 1*2"}}/*@egatari-block-end*/};
69
+ static props = {
70
+ dur: {type: "number", default: 0.9, doc: "1 ステップの秒数"},
71
+ size: {type: "number", default: 24, doc: "字の大きさ(px、24 以上)"},
72
+ marker: {type: "number", default: 8, doc: "点の印の半径(px)"}
73
+ };
74
+ get steps(){ return this.plan().steps.length; }
75
+ duration(k){ return k >= 1 && k <= this.plan().steps.length ? this.props.dur : 0; }
76
+ // データだけから決まること:ステップの並びと、確かめ(bad)
77
+ plan(){
78
+ if (this._plan) return this._plan;
79
+ var d = this.data || {}, bad = [], steps = [], pts = d.points || [], classes = d.classes || [], cls = {};
80
+ classes.forEach(function(c, i){ cls[c.id] = i; });
81
+ var known = function(c){ return c === null || c === undefined || c in cls; };
82
+ pts.forEach(function(p, i){ if (!known(p[2])) bad.push("points[" + i + "]: class " + p[2] + " is not in classes"); });
83
+ var rx = d.axes && d.axes.x.range, ry = d.axes && d.axes.y.range;
84
+ if (rx && !(rx[1] > rx[0])) bad.push("axes.x.range must be [min, max] with min < max");
85
+ if (ry && !(ry[1] > ry[0])) bad.push("axes.y.range must be [min, max] with min < max");
86
+ var labels = null;
87
+ if (d.grid){
88
+ var g = d.grid;
89
+ if (!(g.nx >= 2 && g.nx <= CAP.nx && g.ny >= 2 && g.ny <= CAP.ny)) bad.push("grid: nx 2–" + CAP.nx + " and ny 2–" + CAP.ny + " (got " + g.nx + " × " + g.ny + ")");
90
+ if (g.labels !== undefined){
91
+ var flat = typeof g.labels === "string" ? rle(g.labels) : [].concat.apply([], g.labels);
92
+ if (flat.length !== g.nx * g.ny) bad.push("grid.labels has " + flat.length + " values; nx × ny = " + g.nx * g.ny);
93
+ else if (flat.some(function(v){ return !(v in cls); })) bad.push("grid.labels has a class that is not in classes");
94
+ else { labels = []; for (var j = 0; j < g.ny; j++) labels.push(flat.slice(j * g.nx, (j + 1) * g.nx)); }
95
+ }
96
+ }
97
+ var fields = (d.fields || []).map(function(f, i){
98
+ var ok = d.grid && Array.isArray(f.values) && f.values.length === d.grid.ny && f.values.every(function(r){ return Array.isArray(r) && r.length === d.grid.nx && r.every(function(v){ return typeof v === "number"; }); });
99
+ if (!ok) bad.push("fields[" + i + "].values must be ny × nx numbers (a grid is needed)");
100
+ if (f.class !== undefined && !known(f.class)) bad.push("fields[" + i + "].class: " + f.class + " is not in classes");
101
+ return ok ? f : null;
102
+ }).filter(Boolean);
103
+ (d.sv || []).forEach(function(n){ if (!(n >= 0 && n < pts.length)) bad.push("sv: " + n + " is not a point index (0–" + (pts.length - 1) + ")"); });
104
+ (d.voronoi ? d.voronoi.seeds : []).forEach(function(s, i){ if (!known(s[2])) bad.push("voronoi.seeds[" + i + "]: class " + s[2] + " is not in classes"); });
105
+ // 決定木:根から幅優先で分割を並べ、節ごとに長方形を持たせる
106
+ var splits = [], leaves = [];
107
+ if (d.tree && rx && ry){
108
+ var byId = {}; d.tree.nodes.forEach(function(n){ byId[n.id] = n; });
109
+ var queue = [{n: d.tree.nodes[0], r: [rx[0], rx[1], ry[0], ry[1]]}], seen = {};
110
+ while (queue.length){
111
+ var q = queue.shift(), n = q.n;
112
+ if (seen[n.id]){ bad.push("tree: node \"" + n.id + "\" is reached twice"); continue; }
113
+ seen[n.id] = true;
114
+ if (n.left !== undefined || n.right !== undefined){
115
+ var L = byId[n.left], R = byId[n.right];
116
+ if (!L || !R){ bad.push("tree: node \"" + n.id + "\" needs left and right that exist"); continue; }
117
+ var lo = n.feature === 0 ? q.r[0] : q.r[2], hi = n.feature === 0 ? q.r[1] : q.r[3];
118
+ if (!(n.feature === 0 || n.feature === 1) || !(n.threshold > lo && n.threshold < hi)) bad.push("tree: node \"" + n.id + "\" threshold " + n.threshold + " is not inside its cell (" + lo + " to " + hi + " on feature " + n.feature + ")");
119
+ var rl = q.r.slice(), rr = q.r.slice();
120
+ if (n.feature === 0){ rl[1] = n.threshold; rr[0] = n.threshold; } else { rl[3] = n.threshold; rr[2] = n.threshold; }
121
+ splits.push({id: n.id, feature: n.feature, t: n.threshold, r: q.r});
122
+ queue.push({n: L, r: rl}, {n: R, r: rr});
123
+ } else {
124
+ if (!(n.class in cls)) bad.push("tree: leaf \"" + n.id + "\" needs a class from classes");
125
+ leaves.push({id: n.id, cls: n.class, r: q.r});
126
+ }
127
+ }
128
+ }
129
+ // k 平均法:割り当ては最も近い重心か(同じ距離は許す)、次の重心は割り当てた点の平均か
130
+ var km = d.kmeans ? d.kmeans.iters : null;
131
+ if (km) km.forEach(function(it, i){
132
+ if (it.assign.length !== pts.length){ bad.push("kmeans.iters[" + i + "].assign has " + it.assign.length + " entries; points has " + pts.length); return; }
133
+ var C = it.centroids, d2 = function(p, c){ return (p[0] - c[0]) * (p[0] - c[0]) + (p[1] - c[1]) * (p[1] - c[1]); };
134
+ it.assign.forEach(function(a, n){
135
+ if (!(a >= 0 && a < C.length)){ bad.push("kmeans.iters[" + i + "].assign[" + n + "] is not a centroid index"); return; }
136
+ var best = Math.min.apply(null, C.map(function(c){ return d2(pts[n], c); }));
137
+ if (d2(pts[n], C[a]) > best * (1 + 1e-9) + 1e-12) bad.push("kmeans.iters[" + i + "].assign[" + n + "] = " + a + " is not the nearest centroid");
138
+ });
139
+ if (km[i + 1]){
140
+ C.forEach(function(_, c){
141
+ var m = [0, 0], cnt = 0; it.assign.forEach(function(a, n){ if (a === c){ m[0] += pts[n][0]; m[1] += pts[n][1]; cnt++; } });
142
+ if (!cnt) return;
143
+ var want = [m[0] / cnt, m[1] / cnt], got = km[i + 1].centroids[c];
144
+ if (!got || Math.abs(got[0] - want[0]) > 1e-6 * Math.max(1, Math.abs(want[0])) + 0.51 * Math.pow(10, -dec(got[0])) || Math.abs(got[1] - want[1]) > 1e-6 * Math.max(1, Math.abs(want[1])) + 0.51 * Math.pow(10, -dec(got[1])))
145
+ bad.push("kmeans.iters[" + (i + 1) + "].centroids[" + c + "] should be the mean of the points assigned in iteration " + i + ": (" + +want[0].toFixed(6) + ", " + +want[1].toFixed(6) + ")");
146
+ });
147
+ }
148
+ });
149
+ function dec(v){ var s = String(v).split(".")[1]; return s ? Math.min(s.length, 12) : 12; }
150
+ // ステップ
151
+ steps.push({kind: "points"});
152
+ if (km){ km.forEach(function(_, i){ steps.push({kind: "assign", i: i}); if (i + 1 < km.length) steps.push({kind: "update", i: i}); }); }
153
+ else if (d.tree){ splits.forEach(function(s, i){ steps.push({kind: "split", i: i}); }); steps.push({kind: "leaves"}); }
154
+ else {
155
+ if (labels || d.voronoi) steps.push({kind: "regions"});
156
+ fields.forEach(function(f, i){ steps.push({kind: "field", i: i}); });
157
+ if ((d.sv || []).length) steps.push({kind: "sv"});
158
+ }
159
+ if (d.tree && (labels || d.voronoi || fields.length)) bad.push("tree mode draws its own regions: leave out grid, fields and voronoi");
160
+ if (km && (d.tree || labels || d.voronoi)) bad.push("kmeans mode draws its own cells: leave out grid, voronoi and tree");
161
+ return (this._plan = {d: d, bad: bad, steps: steps, cls: cls, classes: classes, labels: labels, fields: fields, splits: splits, leaves: leaves, km: km});
162
+ }
163
+ mount(ctx){
164
+ var self = this, P = this.props, pl = this.plan(), d = pl.d, ja = /^ja\b/i.test(ctx.lang || "ja"), L = ja ? T.ja : T.en;
165
+ if (!(Number.isFinite(P.dur) && P.dur > 0)){ ctx.report("attr", "[classify2d] dur must be positive; using 0.9"); P.dur = 0.9; }
166
+ if (!(Number.isFinite(P.size) && P.size >= 24)){ ctx.report("attr", "[classify2d] size must be at least 24; using 24"); P.size = 24; }
167
+ if (!(Number.isFinite(P.marker) && P.marker >= 4)){ ctx.report("attr", "[classify2d] marker must be at least 4; using 8"); P.marker = 8; }
168
+ pl.bad.forEach(function(s){ ctx.report("data", "[classify2d] " + s); });
169
+ this.style.display = "block"; this.style.position = "relative";
170
+ var W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight), fs = P.size, mr = P.marker;
171
+ var rx = d.axes.x.range, ry = d.axes.y.range, tx = nice(rx[0], rx[1], 6), ty = nice(ry[0], ry[1], 5);
172
+ var tw = function(s){ return base.textWidth(s, fs, {font: self}); };
173
+ var yTickW = Math.max.apply(null, ty.ticks.map(function(v){ return tw(fmt(v, ty.step)); }).concat([0]));
174
+ // 上:凡例の行(クラスの印と名前)と y 軸の名前。下:x の目盛りと x 軸の名前
175
+ var legendH = Math.ceil(fs * 1.7), m = {l: Math.ceil(yTickW) + 14, r: 12, t: legendH + 6, b: Math.ceil(fs * 1.3) + 6};
176
+ var px = m.l, py = m.t, pw = Math.max(1, W - m.l - m.r), ph = Math.max(1, H - m.t - m.b);
177
+ if (pw < 200 || ph < 150) ctx.report("size", "[classify2d] element is " + W + " × " + H + " px; allow at least " + Math.ceil(m.l + m.r + 200) + " × " + Math.ceil(m.t + m.b + 150) + " px");
178
+ var X = function(x){ return px + (x - rx[0]) / (rx[1] - rx[0]) * pw; }, Y = function(y){ return py + (ry[1] - y) / (ry[1] - ry[0]) * ph; };
179
+ this.geo = {X: X, Y: Y, px: px, py: py, pw: pw, ph: ph, rect: [rx[0], rx[1], ry[0], ry[1]]};
180
+ var colOf = function(c){ var i = pl.cls[c]; return i === undefined ? "var(--muted)" : CLASS_COLORS[i]; };
181
+ this.colOf = colOf;
182
+ this.setAttribute("role", "img");
183
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
184
+ var names = pl.classes.map(function(c){ return c.label || String(c.id); });
185
+ if (!this._aria) this.setAttribute("aria-label", L.summary(names, d.points.length) + (pl.km ? "; " + L.kmeans(pl.km.length) : d.tree ? "; " + L.tree : pl.labels || d.voronoi ? "; " + L.regions : "") + ((d.sv || []).length ? "; " + L.sv + " " + d.sv.length : ""));
186
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true"}, this);
187
+ var cid = "classify2d-2-0-0-clip" + (++clipN);
188
+ D.el("rect", {x: px, y: py, width: pw, height: ph}, D.el("clipPath", {id: cid}, D.el("defs", {}, svg)));
189
+ var plot = D.el("g", {"clip-path": "url(#" + cid + ")"}, svg);
190
+ // 層:領域 → ボロノイ → 決定木の葉 → 格子線 → 等高線 → 分割の線 → 点 → 輪 → 重心
191
+ this.regionG = D.el("g", {opacity: 0, "shape-rendering": "crispEdges"}, plot);
192
+ this.vorG = D.el("g", {opacity: 0}, plot);
193
+ this.leafG = D.el("g", {opacity: 0}, plot);
194
+ this.kmG = D.el("g", {}, plot);
195
+ var gridG = D.el("g", {}, plot);
196
+ tx.ticks.forEach(function(v){ D.el("line", {x1: X(v), y1: py, x2: X(v), y2: py + ph, stroke: "var(--line)", "stroke-width": 1, opacity: 0.6}, gridG); });
197
+ ty.ticks.forEach(function(v){ D.el("line", {x1: px, y1: Y(v), x2: px + pw, y2: Y(v), stroke: "var(--line)", "stroke-width": 1, opacity: 0.6}, gridG); });
198
+ this.boundaryG = D.el("g", {opacity: 0}, plot);
199
+ this.fieldG = pl.fields.map(function(){ return D.el("g", {opacity: 0}, plot); });
200
+ this.splitEls = [];
201
+ var splitG = D.el("g", {}, plot);
202
+ D.el("rect", {x: px, y: py, width: pw, height: ph, fill: "none", stroke: "var(--muted)", "stroke-width": 2}, svg);
203
+ // 目盛りと軸の名前
204
+ // x の目盛りの数は、右端の x 軸の名前と重ならないものだけ
205
+ var xLabW = d.axes.x.label ? tw(d.axes.x.label.replace(/[*_]/g, "")) + 12 : 0;
206
+ tx.ticks.forEach(function(v){ var s = fmt(v, tx.step); if (X(v) + tw(s) / 2 > px + pw - xLabW) return; D.el("text", {x: X(v), y: py + ph + fs + 2, "font-size": fs, "text-anchor": "middle", fill: "var(--muted)"}, svg).textContent = s; });
207
+ ty.ticks.forEach(function(v){ D.el("text", {x: px - 8, y: Y(v) + fs * 0.35, "font-size": fs, "text-anchor": "end", fill: "var(--muted)"}, svg).textContent = fmt(v, ty.step); });
208
+ if (d.axes.y.label) D.mtext(svg, px, legendH - fs * 0.45, d.axes.y.label, {"font-size": fs, fill: "var(--fg)"});
209
+ // 凡例:右上にクラスの印と名前(k 平均法はクラスターなので書かない)
210
+ var legW = 0, legend = pl.km ? [] : pl.classes.map(function(c, i){ var t = c.label || String(c.id), w = 2 * mr + 10 + tw(t) + 20; legW += w; return {t: t, w: w, i: i, id: c.id}; });
211
+ var lx = W - m.r - legW, yLabW = d.axes.y.label ? tw(d.axes.y.label.replace(/[*_]/g, "")) + 16 : 0;
212
+ if (lx < px + yLabW) ctx.report("layout", "[classify2d] the class names need " + Math.ceil(legW) + " px beside the y-axis name; shorten them");
213
+ legend.forEach(function(o){ self.marker(svg, lx + mr, legendH / 2 + 2, o.i, colOf(o.id), mr); D.el("text", {x: lx + 2 * mr + 10, y: legendH / 2 + 2 + fs * 0.35, "font-size": fs, fill: "var(--fg)"}, svg).textContent = o.t; lx += o.w; });
214
+ // x 軸の名前:目盛りの右端の数の左に入らなければ、目盛りの行の右に
215
+ if (d.axes.x.label) D.mtext(svg, px + pw, py + ph + fs + 2, d.axes.x.label, {"font-size": fs, "text-anchor": "end", fill: "var(--fg)", "data-xlabel": ""});
216
+ // 領域(格子の上の predict):行ごとに同じクラスの続きを 1 つの長方形に。境界は違うクラスの間のセルの辺(階段)
217
+ if (pl.labels){
218
+ var g = d.grid, dx = (rx[1] - rx[0]) / (g.nx - 1), dy = (ry[1] - ry[0]) / (g.ny - 1), lab = pl.labels;
219
+ var cx = function(i){ return Math.max(rx[0], Math.min(rx[1], rx[0] + (i - 0.5) * dx)); }, cy = function(j){ return Math.max(ry[0], Math.min(ry[1], ry[0] + (j - 0.5) * dy)); };
220
+ lab.forEach(function(row, j){
221
+ var i0 = 0;
222
+ for (var i = 1; i <= row.length; i++) if (i === row.length || row[i] !== row[i0]){
223
+ D.el("rect", {x: X(cx(i0)).toFixed(1), y: Y(cy(j + 1)).toFixed(1), width: (X(cx(i)) - X(cx(i0))).toFixed(1), height: (Y(cy(j)) - Y(cy(j + 1))).toFixed(1), fill: colOf(row[i0]), "fill-opacity": 0.2}, self.regionG);
224
+ i0 = i;
225
+ }
226
+ });
227
+ var path = "";
228
+ for (var j = 0; j < g.ny; j++) for (var i = 0; i < g.nx; i++){
229
+ if (i + 1 < g.nx && lab[j][i] !== lab[j][i + 1]) path += "M" + X(cx(i + 1)).toFixed(1) + " " + Y(cy(j)).toFixed(1) + "V" + Y(cy(j + 1)).toFixed(1);
230
+ if (j + 1 < g.ny && lab[j][i] !== lab[j + 1][i]) path += "M" + X(cx(i)).toFixed(1) + " " + Y(cy(j + 1)).toFixed(1) + "H" + X(cx(i + 1)).toFixed(1);
231
+ }
232
+ // 確率や決定関数の等高線があれば、境界はそちらの滑らかな線で見せる(階段は描かない)
233
+ if (path && !pl.fields.length) D.el("path", {d: path, fill: "none", stroke: "var(--fg)", "stroke-width": 2.5, "stroke-linecap": "square"}, this.boundaryG);
234
+ }
235
+ // ボロノイ図(種の点から計算)
236
+ if (d.voronoi){
237
+ var seeds = d.voronoi.seeds, rect = this.geo.rect;
238
+ seeds.forEach(function(sd, s){
239
+ var poly = cell(seeds, s, rect);
240
+ if (poly.length < 3) return;
241
+ D.el("path", {d: "M" + poly.map(function(v){ return X(v[0]).toFixed(1) + " " + Y(v[1]).toFixed(1); }).join("L") + "Z", fill: sd[2] === null || sd[2] === undefined ? "none" : colOf(sd[2]), "fill-opacity": 0.2, stroke: "var(--fg)", "stroke-width": 2}, self.vorG);
242
+ });
243
+ seeds.forEach(function(sd){ D.el("circle", {cx: X(sd[0]), cy: Y(sd[1]), r: 4, fill: "var(--fg)"}, self.vorG); });
244
+ }
245
+ // 等高線(確率・決定関数)と、その値の名前(線の上、地の色の縁取り)
246
+ pl.fields.forEach(function(f, n){
247
+ var g = d.grid, dx = (rx[1] - rx[0]) / (g.nx - 1), dy = (ry[1] - ry[0]) / (g.ny - 1);
248
+ var gxp = function(p){ return X(rx[0] + p[0] * dx); }, gyp = function(p){ return Y(ry[0] + p[1] * dy); };
249
+ f.levels.forEach(function(lv, li){
250
+ var dash = (f.style || [])[li] === "dash";
251
+ K.lines(f.values, lv).forEach(function(line){
252
+ if (line.length < 2) return;
253
+ D.el("path", {d: "M" + line.map(function(p){ return gxp(p).toFixed(1) + " " + gyp(p).toFixed(1); }).join("L"), fill: "none", stroke: "var(--fg)", "stroke-width": dash ? 2 : 3, "stroke-dasharray": dash ? "10 8" : null}, self.fieldG[n]);
254
+ if (f.labels !== false){
255
+ var at = K.labelAt(line), x = gxp([at.x, at.y]), y = gyp([at.x, at.y]), len = Math.hypot(gxp(line[line.length - 1]) - gxp(line[0]), gyp(line[line.length - 1]) - gyp(line[0]));
256
+ if (at.length && (len > 3 * fs || line.length > 8)){
257
+ var t = D.el("text", {x: x.toFixed(1), y: (y + fs * 0.35).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)", stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", "stroke-linejoin": "round"}, self.fieldG[n]);
258
+ t.textContent = (lv < 0 ? "−" : "") + String(Math.abs(lv));
259
+ }
260
+ }
261
+ });
262
+ });
263
+ });
264
+ // 決定木の分割(親のセルの中の線)と葉
265
+ pl.splits.forEach(function(s){
266
+ var e = s.feature === 0 ? D.el("line", {x1: X(s.t), y1: Y(s.r[3]), x2: X(s.t), y2: Y(s.r[3]), stroke: "var(--fg)", "stroke-width": 3}, splitG) : D.el("line", {x1: X(s.r[0]), y1: Y(s.t), x2: X(s.r[0]), y2: Y(s.t), stroke: "var(--fg)", "stroke-width": 3}, splitG);
267
+ self.splitEls.push(e);
268
+ });
269
+ pl.leaves.forEach(function(lf){ D.el("rect", {x: X(lf.r[0]), y: Y(lf.r[3]), width: X(lf.r[1]) - X(lf.r[0]), height: Y(lf.r[2]) - Y(lf.r[3]), fill: colOf(lf.cls), "fill-opacity": 0.2}, self.leafG); });
270
+ // k 平均法のセル(重心のボロノイ図。描くたびに重心から計算)
271
+ if (pl.km){ this.kmCells = pl.km[0].centroids.map(function(_, c){ return D.el("path", {fill: CLASS_COLORS[c], "fill-opacity": 0.18, stroke: "var(--fg)", "stroke-width": 2, opacity: 0}, self.kmG); }); }
272
+ // 点
273
+ var ptG = this.ptG = D.el("g", {opacity: 0}, svg);
274
+ this.ptEls = d.points.map(function(p){ return self.marker(ptG, X(p[0]), Y(p[1]), pl.km ? -1 : pl.cls[p[2]], pl.km ? "var(--muted)" : colOf(p[2]), mr); });
275
+ this.svG = D.el("g", {opacity: 0}, svg);
276
+ (d.sv || []).forEach(function(n){ var p = d.points[n]; if (p) D.el("circle", {cx: X(p[0]), cy: Y(p[1]), r: mr + 7, fill: "none", stroke: "var(--fg)", "stroke-width": 3}, self.svG); });
277
+ if (pl.km) this.cEls = pl.km[0].centroids.map(function(_, c){ var g = D.el("g", {opacity: 0}, svg); D.el("path", {d: "M-12 -12L12 12M-12 12L12 -12", stroke: "var(--bg)", "stroke-width": 9, "stroke-linecap": "round"}, g); D.el("path", {d: "M-12 -12L12 12M-12 12L12 -12", stroke: CLASS_COLORS[c], "stroke-width": 5, "stroke-linecap": "round"}, g); return g; });
278
+ if (d.points.length * Math.PI * mr * mr > pw * ph * 0.35) ctx.report("layout", "[classify2d] " + d.points.length + " points cover more than a third of the plot at marker " + mr + " px; use a smaller marker or fewer points");
279
+ }
280
+ // クラスの印:○・□・△・◇(クラスの順)。i < 0 は印なしの○
281
+ marker(g, x, y, i, col, r){
282
+ var s = SHAPES[i] || "circle", e;
283
+ if (s === "circle") e = D.el("circle", {cx: x.toFixed(1), cy: y.toFixed(1), r: r, fill: col, stroke: "var(--bg)", "stroke-width": 1.5}, g);
284
+ else if (s === "square") e = D.el("rect", {x: (x - r * 0.9).toFixed(1), y: (y - r * 0.9).toFixed(1), width: (1.8 * r).toFixed(1), height: (1.8 * r).toFixed(1), fill: col, stroke: "var(--bg)", "stroke-width": 1.5}, g);
285
+ else if (s === "triangle") e = D.el("path", {d: "M" + x.toFixed(1) + " " + (y - 1.2 * r).toFixed(1) + "L" + (x + 1.1 * r).toFixed(1) + " " + (y + 0.8 * r).toFixed(1) + "L" + (x - 1.1 * r).toFixed(1) + " " + (y + 0.8 * r).toFixed(1) + "Z", fill: col, stroke: "var(--bg)", "stroke-width": 1.5}, g);
286
+ else e = D.el("path", {d: "M" + x.toFixed(1) + " " + (y - 1.25 * r).toFixed(1) + "L" + (x + 1.1 * r).toFixed(1) + " " + y.toFixed(1) + "L" + x.toFixed(1) + " " + (y + 1.25 * r).toFixed(1) + "L" + (x - 1.1 * r).toFixed(1) + " " + y.toFixed(1) + "Z", fill: col, stroke: "var(--bg)", "stroke-width": 1.5}, g);
287
+ return e;
288
+ }
289
+ render(k, t){
290
+ if (!this.svg) return;
291
+ var self = this, pl = this.plan(), G = this.geo, dur = this.props.dur, steps = pl.steps;
292
+ var ph = function(i){ return k > i + 1 ? 1 : k < i + 1 ? 0 : base.prog(t, 0, dur); };
293
+ var at = function(kind, i){ for (var n = 0; n < steps.length; n++) if (steps[n].kind === kind && (i === undefined || steps[n].i === i)) return n; return -1; };
294
+ this.ptG.setAttribute("opacity", ph(0).toFixed(3));
295
+ var r = at("regions"); this.regionG.setAttribute("opacity", r >= 0 ? ph(r).toFixed(3) : 0); this.vorG.setAttribute("opacity", r >= 0 ? ph(r).toFixed(3) : 0); this.boundaryG.setAttribute("opacity", r >= 0 ? ph(r).toFixed(3) : 0);
296
+ this.fieldG.forEach(function(g, n){ var s = at("field", n); g.setAttribute("opacity", ph(s).toFixed(3)); });
297
+ var sv = at("sv"); this.svG.setAttribute("opacity", sv >= 0 ? ph(sv).toFixed(3) : 0);
298
+ // 決定木:分割の線が親のセルの端から端へ伸びる
299
+ pl.splits.forEach(function(s, n){
300
+ var e = ph(at("split", n)), el = self.splitEls[n];
301
+ if (s.feature === 0){ el.setAttribute("y1", G.Y(s.r[3]).toFixed(1)); el.setAttribute("y2", G.Y(s.r[3] + (s.r[2] - s.r[3]) * e).toFixed(1)); }
302
+ else { el.setAttribute("x1", G.X(s.r[0]).toFixed(1)); el.setAttribute("x2", G.X(s.r[0] + (s.r[1] - s.r[0]) * e).toFixed(1)); }
303
+ el.setAttribute("opacity", e > 0 ? 1 : 0);
304
+ });
305
+ var lv = at("leaves"); this.leafG.setAttribute("opacity", lv >= 0 ? ph(lv).toFixed(3) : 0);
306
+ // k 平均法:割り当て(点の色とセル)、更新(重心が動き、セルが付いていく)
307
+ if (pl.km){
308
+ var km = pl.km, cur = -1, cs = km[0].centroids, assign = null, showCells = 0;
309
+ steps.forEach(function(s, n){
310
+ var e = ph(n);
311
+ if (e <= 0) return;
312
+ if (s.kind === "assign"){ cur = s.i; cs = km[s.i].centroids; assign = km[s.i].assign; showCells = e; }
313
+ if (s.kind === "update"){ var a = km[s.i].centroids, b = km[s.i + 1].centroids; cs = a.map(function(c, j){ return [c[0] + (b[j][0] - c[0]) * e, c[1] + (b[j][1] - c[1]) * e]; }); showCells = 1; }
314
+ });
315
+ var first = ph(0) > 0 ? 1 : 0;
316
+ this.cEls.forEach(function(g, j){ var c = cs[j]; g.setAttribute("transform", "translate(" + G.X(c[0]).toFixed(1) + " " + G.Y(c[1]).toFixed(1) + ")"); g.setAttribute("opacity", first); });
317
+ this.kmCells.forEach(function(p, j){ var poly = cell(cs, j, G.rect); p.setAttribute("d", poly.length > 2 ? "M" + poly.map(function(v){ return G.X(v[0]).toFixed(1) + " " + G.Y(v[1]).toFixed(1); }).join("L") + "Z" : ""); p.setAttribute("opacity", showCells.toFixed(3)); });
318
+ this.ptEls.forEach(function(e, n){ e.setAttribute("style", "fill:" + (assign ? CLASS_COLORS[assign[n]] : "var(--muted)")); });
319
+ }
320
+ }
321
+ };
322
+ });
@@ -0,0 +1,18 @@
1
+ ---
2
+ summary: A tall figure (SVG, HTML) in a fixed-height frame, scrolled to set places by step; viewers may scroll it
3
+ steps: largest child data-scroll-step
4
+ props:
5
+ dur: scroll seconds
6
+ margin: px above target
7
+ ---
8
+
9
+ For a tall timeline, flow or code shown without splitting it.
10
+
11
+ Child of `<m-scroll style="height:440px" aria-label="name">`: the figure.
12
+
13
+ - `data-scroll-step="k"` on a child: step k scrolls it to the top
14
+ - Wheel, touch, ↑ ↓, PageUp/Down scroll the frame; ← → and Space move slides
15
+ - A hand-scrolled place stays until the next step
16
+ <!-- llm: omit -->
17
+ - `--line` border; outside is cut on purpose (`data-clip`). Video and print show the author's place.
18
+ <!-- llm: end -->
@@ -0,0 +1,103 @@
1
+ // m-scroll 2.0.0: puts a tall figure (inline SVG, HTML) in a frame of fixed height and moves it with the steps.
2
+ // <m-scroll style="height:440px"> … children … </m-scroll>: the children go into the frame as they are. A child with
3
+ // data-scroll-step="k" is the place the frame shows from step k on (k = 1, 2, …); steps = the largest k (the steps attribute
4
+ // wins). Inside the frame the wheel, touch, ↑ ↓ and PageUp / PageDown scroll the frame and do not move the slides; ← → and
5
+ // Space stay the player's. A viewer who scrolled by hand keeps their place until the next step (viewer input, spec §8.4);
6
+ // entering the slide again (ctx.entered) or a reset (ctx.reset) gives the frame back to the steps.
7
+ // Video (ctx.mode "video") and print show the author's place for the step. Under prefers-reduced-motion the player gives
8
+ // t = Infinity, so the frame jumps. The frame is cut on purpose (data-clip); the part draws nothing of its own.
9
+ // Origin: a student of the lab made it inside a progress-report file (scroll 0.1.0); taken in for 2.17 (handoff #66).
10
+ egatariParts.define({name: "scroll", version: "2.0.0", requires: {base: "1.3.0"}, element: "m-scroll"}, function(deps){
11
+ "use strict";
12
+ var base = deps.base;
13
+ var LINE = 40; // px per ↑ ↓; PageUp / PageDown move 0.9 of the frame
14
+ var CSS_ID = "scroll-2-0-0-css";
15
+ var CSS = [
16
+ "m-scroll{display:block;position:relative;overflow:hidden}",
17
+ "m-scroll .sc-frame{position:relative;height:100%;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;border:2px solid var(--line);border-radius:6px;box-sizing:border-box}",
18
+ "m-scroll .sc-frame:focus-visible{outline:3px solid var(--emph);outline-offset:-3px}",
19
+ "@media print{m-scroll .sc-frame{scrollbar-width:none}}",
20
+ ].join("\n");
21
+ return class extends base.MotionElement {
22
+ static partName = "scroll";
23
+ static interactive = true; // the viewer can scroll the frame (docs/conventions.md §6)
24
+ static preview = "none"; // nothing lies ahead to show faint: the figure is all there, only its place changes
25
+ static viewerInput = true; // a place scrolled by hand is the viewer's state until the next step (spec §8.4)
26
+ // no JSON: the children are the figure. The example is how to write it (as m-sweep's attribute-only shape)
27
+ static shape = {schema: null, example: '<m-scroll style="height:440px" aria-label="年表"><svg viewBox="0 0 1000 1300" width="1000" height="1300">… <g data-scroll-step="1">…</g> …</svg></m-scroll>'};
28
+ static props = {
29
+ dur: {type: "number", default: 0.8, doc: "秒数:ステップが変わったときに枠が動く時間"},
30
+ margin: {type: "number", default: 12, doc: "px:data-scroll-step の要素の上に空ける余白"},
31
+ };
32
+ get steps(){
33
+ var a = this.getAttribute("steps");
34
+ if (a !== null) return +a;
35
+ var n = 0;
36
+ [].forEach.call(this.querySelectorAll("[data-scroll-step]"), function(e){
37
+ var k = parseInt(e.getAttribute("data-scroll-step"), 10);
38
+ if (k > n) n = k;
39
+ });
40
+ return n;
41
+ }
42
+ mount(ctx){
43
+ var doc = this.ownerDocument, self = this;
44
+ if (!doc.getElementById(CSS_ID)) {
45
+ var st = doc.createElement("style");
46
+ st.id = CSS_ID; st.textContent = CSS;
47
+ (doc.head || doc.documentElement).appendChild(st);
48
+ }
49
+ this.video = ctx.mode === "video";
50
+ var ja = /^ja\b/i.test(ctx.lang || "");
51
+ this.setAttribute("data-clip", ""); // what lies outside the frame is shown by scrolling (cut on purpose)
52
+ var fr = this._fr = doc.createElement("div");
53
+ fr.className = "sc-frame";
54
+ fr.setAttribute("data-clip", "");
55
+ fr.setAttribute("tabindex", "0");
56
+ fr.setAttribute("role", "region");
57
+ fr.setAttribute("aria-label", this.getAttribute("aria-label") || (ja ? "縦に送る図" : "Scrolling figure"));
58
+ [].slice.call(this.childNodes).forEach(function(n){ if (!(n.nodeType === 1 && n.localName === "script")) fr.appendChild(n); });
59
+ this.appendChild(fr);
60
+ var stop = function(e){ e.stopPropagation(); };
61
+ ["wheel", "touchstart", "touchmove", "pointerdown", "click", "dblclick"].forEach(function(n){ fr.addEventListener(n, stop, {passive: true}); });
62
+ fr.addEventListener("keydown", function(e){
63
+ var d = e.key === "ArrowUp" ? -LINE : e.key === "ArrowDown" ? LINE
64
+ : e.key === "PageUp" ? -fr.clientHeight * 0.9 : e.key === "PageDown" ? fr.clientHeight * 0.9 : null;
65
+ if (d === null) return;
66
+ e.preventDefault(); e.stopPropagation();
67
+ fr.scrollBy({top: d, behavior: "auto"});
68
+ });
69
+ // scroll events come later than the write, so a flag cannot tell the steps' scroll from the viewer's:
70
+ // a place more than 2 px from the one the steps wrote is the viewer's
71
+ fr.addEventListener("scroll", function(){
72
+ if (!self.video && (self._expect === undefined || Math.abs(fr.scrollTop - self._expect) > 2)) self._user = true;
73
+ }, {passive: true});
74
+ var view = doc.defaultView;
75
+ if (view) view.addEventListener("beforeprint", function(){ self._user = false; if (self._k !== undefined) self.place(self._at(self._k)); });
76
+ }
77
+ // the scrollTop that shows the element of step k, or null when no child has data-scroll-step="k"
78
+ _target(k){
79
+ var fr = this._fr, a = fr.querySelector('[data-scroll-step="' + k + '"]');
80
+ if (!a) return null;
81
+ // the slide's scale from the border box (getBoundingClientRect and offsetHeight both include the border)
82
+ var r = fr.getBoundingClientRect(), s = fr.offsetHeight ? r.height / fr.offsetHeight : 1;
83
+ var top = (a.getBoundingClientRect().top - r.top) / (s || 1) - fr.clientTop + fr.scrollTop - this.props.margin;
84
+ return Math.round(Math.max(0, Math.min(top, fr.scrollHeight - fr.clientHeight)));
85
+ }
86
+ // the place for step k: the element of the largest step ≤ k, else the top (so the result does not depend on the call order)
87
+ _at(k){
88
+ for (var j = k; j >= 1; j--) { var y = this._target(j); if (y !== null) return y; }
89
+ return 0;
90
+ }
91
+ place(y){ this._expect = y; this._fr.scrollTop = y; }
92
+ duration(k){ return k >= 1 ? this.props.dur : 0; }
93
+ render(k, t, ctx){
94
+ if (!this._fr) return;
95
+ if (ctx && (ctx.entered === true || ctx.reset)) this._user = false;
96
+ if (this._k !== k) { this._k = k; this._user = false; } // a new step takes the frame back
97
+ if (this._user) return;
98
+ var to = this._at(k), from = k >= 1 ? this._at(k - 1) : to;
99
+ // whole pixels: a fractional scrollTop can land a few px apart depending on the call order
100
+ this.place(Math.round(base.lerp(from, to, base.prog(t, 0, this.props.dur))));
101
+ }
102
+ };
103
+ });
@@ -0,0 +1,101 @@
1
+ # Reading abcjs 6.7.2 for m-score (notes for the build hook)
2
+
3
+ m-score knows nothing about abcjs (components 2.0 design §4.1). It reads `abcMap` (`tempo`, `notes`, `beams`, `arcs`)
4
+ and finds things in `abcSvg` only by the build's data- tags, never by an abcjs class. This file gives the abcjs facts a
5
+ producer needs to write those tags. `tools/score-fixtures.mjs` follows them. It is the stand-in for Studio's build
6
+ hook and writes `fixtures/*.json` and `demo.html`. They were checked on the fixtures here (`ties.json` is test-only) and in
7
+ abcjs's source (`src/write/creation/abstract-engraver.js`, `src/write/draw/tie.js`, `src/write/draw/beam.js`).
8
+
9
+ ## Tags the build writes (all digits; the part reads no other data- attribute)
10
+
11
+ | Tag | On | Value | The part shows it with |
12
+ |---|---|---|---|
13
+ | `data-note="i"` | each note's or rest's `<g>` (`abselem.elemset[0]` of the parsed note) | its index in `notes` | that note (and colours it while current) |
14
+ | `data-beam="k"` | each beam path (`abcjs-beam-elem`) | its index in `beams` | the first note of `beams[k]` |
15
+ | `data-measure="m"` | each bar line's `<g>` (`abselem.elemset[0]` of a `bar` element) | the measure it closes (its `abcjs-mm`) | the last note of measure `m` |
16
+ | `data-arc="n"` | each drawn tie or slur piece | `arcs[].n` | a tie with its `to`, a slur with its `from` |
17
+
18
+ - Everything without a tag is shown from step 0: the staff, clef, key and time signatures, and whatever else abcjs draws.
19
+ So anything that should appear with a note must be tagged. This covers decorations, lyrics and chord symbols, if abcjs
20
+ ever draws them outside the note's `<g>`; the fixtures have none.
21
+ - A `<g>` that contains a tag is looked into. One that contains none is kept whole.
22
+ - A staff line is one child of the root `<svg>`. abcjs puts each line in its own `abcjs-staff-wrapper` `<g>`.
23
+ The part stacks these children and puts the names band under each.
24
+ - The part reports, without guessing:
25
+ - a note with no `data-note` element, and a `data-note` used twice;
26
+ - a beam with no `data-beam` element;
27
+ - an arc with no `data-arc` line;
28
+ - a tag value that `abcMap` does not have.
29
+ - `notes[].cls` (`"abcjs-v0 abcjs-mm1 abcjs-n2"`) stays in `abcMap` as the adapter's record, for checking. The part does not read it.
30
+ - `tools/test-score.mjs` and `tools/test-score-noclass.mjs` strip every `abcjs-*` class from the fixtures. They check
31
+ that the part behaves the same: same steps, events, names and DOM.
32
+
33
+ ## Notes
34
+
35
+ - With `add_classes: true`, a note or rest is a `<g>` with `abcjs-note` or `abcjs-rest`, `abcjs-l<line>`, `abcjs-m<measure in the line>`,
36
+ `abcjs-mm<measure>`, `abcjs-v<voice>` and `abcjs-n<note in the measure>`. Only `abcjs-v… abcjs-mm… abcjs-n…` together is unique.
37
+ - Pitch name: the letter and octave come from `pitches[q].pitch` (a diatonic step, 0 = C4). The accidental comes from the
38
+ sounding MIDI pitch after `tune.setUpAudio()` (`midiPitches[q].pitch`). A tied continuation has no `midiPitches`.
39
+ - `duration` is in whole notes. Multiply it by 4 for quarter notes, and by `tripletMultiplier` from `startTriplet` to
40
+ `endTriplet`. Tempo is `bpm × Σ duration × 4` quarter notes per minute.
41
+ - abcjs writes the tempo, title and lyrics at 16–20 units, below the 24 px floor. Render with `%%printtempo false` and without `T:`.
42
+
43
+ ## Beams
44
+
45
+ `drawBeam` draws one path per beam group, all levels in one path, with class `abcjs-beam-elem`. The paths come in the
46
+ order of the engraved voice's `beams`, so the build tags the k-th `abcjs-beam-elem` path in document order `data-beam="k"` (`tune.lines[l].staffGroup.voices[v].beams`, skipping `'bar'`). The notes of each
47
+ group are in `elems[].abcelem`.
48
+
49
+ ## Ties and slurs
50
+
51
+ - **Which arcs exist** (from the parsed notes): a tie per pitch, from a pitch with `startTie` to the next note whose pitch
52
+ with the same step has `endTie`. abcjs ends a tie on the first open tie with that pitch, or else the oldest one. A slur
53
+ runs from `startSlur` to the `endSlur` with the same label, on the note or on a pitch. `[C-EG] [CEG]` ties only C.
54
+ - **Which path is which:** each drawn arc is a `TieElem` in the engraved voice's `otherchildren`. Its path is in `elemset[0]`
55
+ and its end noteheads are `anchor1` and `anchor2`. The notehead's `parent.abcelem` is the note, and `parent.heads`
56
+ gives the pitch. A `TieElem` does not record whether it is a tie or a slur.
57
+ - **Line breaks:** an arc that crosses a line break is drawn once per line. The piece on the first line has only `anchor1`
58
+ (class `abcjs-end-edge`). At the start of each later line abcjs recreates every open arc. That piece has only `anchor2`,
59
+ or neither on a middle line (class `abcjs-start-edge`).
60
+ - **Drawing order**, per staff line (the order of `otherchildren`):
61
+ 1. First, the pieces continued from the previous line: all open slurs, in start order, then all open ties in the
62
+ order they were created (by start note; a chord's pitches low to high).
63
+ 2. Then the arcs that start on this line, by start note. At one note abcjs goes pitch by pitch, low to high. For each
64
+ pitch it creates that pitch's tie, then any slur starting on that pitch. A slur over a chord sits on the lowest pitch.
65
+ So the order at one note is: the lowest pitch's tie, the slur, then the other pitches' ties.
66
+ - **Class quirks:**
67
+ - Every arc path has `abcjs-slur`.
68
+ - A slur within a line has `abcjs-legato`.
69
+ - A slur piece cut by a line break is drawn like a tie and has `abcjs-tie`.
70
+ - So does a slur between two notes of the same pitch with nothing between them.
71
+ - **Hidden duplicate:** the slur leaving a tied chord at a line break is drawn on exactly the same path as the lowest
72
+ pitch's tie, so it cannot be seen. The build drops it.
73
+ - **How `tools/score-fixtures.mjs` tags a piece:**
74
+ - A piece with both anchors matches the one arc between those notes; a tie must also match by pitch.
75
+ - A piece with one anchor can match both a tie and a slur at the same note. Then the order above decides: on the start
76
+ line the tie comes first, and on the next line the slur comes first.
77
+ - Every piece gets `data-arc="<n>"`. If a piece matches no arc, or more than one, the script fails.
78
+
79
+ ## Writing only what the rendered-markup list admits (egatari-spec ce96072)
80
+
81
+ The part reads `abcSvg` through the spec's list (`schema/rendered-markup-1.json`, svg) and reports anything it drops.
82
+ abcjs 6.7.2 (`foregroundColor: "currentColor"`, also its default) writes, besides the drawing:
83
+
84
+ | abcjs writes | Admitted? | The build |
85
+ |---|---|---|
86
+ | `<style>` (its drag-and-drop CSS) | no | leaves it out |
87
+ | `<title>Sheet Music</title>` | yes | leaves it out (the part's drawing is aria-hidden; the slide gives the label) |
88
+ | `xmlns:xlink` on `<svg>`, `selectable` on each note's `<g>` | no | leaves them out |
89
+ | `data-name`, `data-index` | yes (data-*) | leaves them out: they are abcjs's, not build tags |
90
+ | `fill`, `stroke` on `<svg>` and `<g>` (`stroke="none"` on notes, clef, key, time), `stroke="none"` on text | yes (since ce96072) | keeps them as abcjs writes them |
91
+ | on text (chord symbols, lyrics, title, tempo): `font-family`, `text-decoration` | no | keeps them: the part drops them (expected losses: the slide's font, no underline); the demo has no text, `extras.json` (test only) does |
92
+
93
+ The data records the renderer once at its top: `renderers: {abcjs: {version: "6.7.2", options: {add_classes, staffwidth,
94
+ foregroundColor}}}` (spec §6.2).
95
+
96
+ ## What m-score does with it
97
+
98
+ - It finds notes, beams, bar lines and arc pieces only by the tags above.
99
+ - A tie piece appears with the note it leads to (`to`), a slur piece with its first note (`from`).
100
+ - A pitch is not sounded again at note `j` when a tie arc has `to = j` and that `pitch`. A tied pitch sounds for the
101
+ whole chain.
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009-2026 Paul Rosen and Gregory Dyke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ **This text is from: http://opensource.org/licenses/MIT**