egatari 0.6.17 → 0.6.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -1
- package/README.ja.md +14 -13
- package/README.md +2 -1
- package/components.lock.json +153 -54
- package/components2.lock.json +1001 -1
- package/kit/build.mjs +1 -1
- package/kit/check-messages.mjs +9 -0
- package/kit/check.mjs +8 -0
- package/kit/core/bookmark.mjs +28 -0
- package/kit/core/build-core.mjs +5 -3
- package/kit/core/check-parity.mjs +6 -0
- package/kit/core/check-rules.mjs +4 -3
- package/kit/core/check-source.mjs +10 -1
- package/kit/core/checks.mjs +79 -0
- package/kit/core/find-replace.mjs +170 -0
- package/kit/core/format.mjs +4 -1
- package/kit/core/image-insert.mjs +197 -0
- package/kit/core/image-size.mjs +1 -1
- package/kit/core/layout-scan.mjs +1 -1
- package/kit/core/llm-fix.mjs +1 -1
- package/kit/core/llm-pack-assemble.mjs +40 -67
- package/kit/core/llm-pack-data.mjs +882 -52
- package/kit/core/llm-pack.mjs +6 -4
- package/kit/core/llm-request.mjs +2 -2
- package/kit/core/new-deck-pack.mjs +38 -44
- package/kit/core/new-deck.mjs +82 -74
- package/kit/core/part-labels.mjs +3 -0
- package/kit/core/portable.mjs +5 -2
- package/kit/core/purposes.mjs +9 -3
- package/kit/core/sample-info.mjs +17 -3
- package/kit/core/scorm.mjs +30 -6
- package/kit/core/script-unclosed.mjs +49 -0
- package/kit/core/slide-ops.mjs +27 -1
- package/kit/core/tate-mix.mjs +25 -0
- package/kit/core/template-text.mjs +2 -0
- package/kit/core/theme-derive.mjs +56 -17
- package/kit/core/theme-shapes.mjs +15 -1
- package/kit/deck.js +124 -6
- package/kit/instruction-version.json +1 -1
- package/kit/layouts.css +8 -0
- package/kit/llm-pack.mjs +5 -7
- package/kit/panes.js +17 -1
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/presenter.js +36 -4
- package/kit/tools.js +54 -2
- package/kit/track.js +46 -5
- package/package.json +1 -1
- package/server/editor-ui.js +21 -1
- package/vendor/components/CATALOG.md +25 -22
- package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
- package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
- package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
- package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
- package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
- package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
- package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
- package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
- package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
- package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
- package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
- package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
- package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
- package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
- package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
- package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
- package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
- package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
- package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
- package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
- package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
- package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
- package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
- package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
- package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
- package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
- package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
- package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
- package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
- package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
- package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
- package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
- package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
- package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
- package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
- package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
- package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
- package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
- package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
- package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
- package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
- package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
- package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
- package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
- package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
- package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
- package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
- package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
- package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
- package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
- package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
- package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
- package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
- package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
- package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
- package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
- package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
- package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
- package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
- package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
- package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
- package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
- package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
- package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
- package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
- package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
- package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
- package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
- package/vendor/components-2/manifest-2.16.0.json +2919 -0
- package/vendor/components-2/manifest-2.17.0.json +2852 -0
- package/vendor/components-2/manifest-2.18.0.json +3182 -0
- package/vendor/components-2/manifest-2.20.0.json +3217 -0
- package/vendor/components-2/manifest-2.21.0.json +3220 -0
- package/vendor/egatari-spec/SOURCE.json +2 -2
- package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
- package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changes to the strokesvg kana shapes (FONTLOG)
|
|
2
|
+
|
|
3
|
+
Source: strokesvg <https://github.com/zhengkyl/strokesvg>, commit `e4c2c91034e03c9c2f4e95f14f2361a948f52cd0`
|
|
4
|
+
(kana SVGs derived from Klee One; SIL OFL 1.1). Converted by `tools/kana-import-strokesvg.mjs`. These changes are
|
|
5
|
+
part of the OFL-licensed work.
|
|
6
|
+
|
|
7
|
+
- 2026-10-26 — Format and precision. Each character's strokes in writing order; each stroke a list of pieces
|
|
8
|
+
`[outline, centreline]` (strokesvg splits a stroke that crosses itself into pieces, each with its own clip; they
|
|
9
|
+
stay grouped as one stroke). Coordinates scaled from strokesvg's 1024 box to 0–100 (×100/1024) and rounded to
|
|
10
|
+
0.1, written as one absolute move and then relative commands; arcs kept. The brush (strokesvg's stroke width 128)
|
|
11
|
+
is 12.5.
|
|
12
|
+
- 2026-10-26 — **半濁点** of ぱ ぴ ぷ ぺ ぽ パ ピ プ ペ ポ: the circle's centreline is redrawn to **start at the bottom
|
|
13
|
+
centre and go clockwise** (bottom → left → top → right, and a little past the start), as taught in 光村図書
|
|
14
|
+
『こくご一(上)』p.27 (半濁点) and p.37 (句点): 「下中心から時計回り」. Its centre and radius come from the circle's
|
|
15
|
+
own outline (the middle of the ring); the outline is unchanged. strokesvg's line started above the ring and went
|
|
16
|
+
anticlockwise.
|
|
17
|
+
- 2026-10-26 — **っ ッ ゎ ヮ ヵ ヶ** added (not in strokesvg). Each is its base character (つ ツ わ ワ カ ケ) scaled
|
|
18
|
+
uniformly and moved so that its outline box fits Klee One's own small glyph box (read from the font's metrics;
|
|
19
|
+
the scale and move are recorded under `"derived"` in the file). Checked against the Klee One small glyphs by
|
|
20
|
+
overlay: they match within about 0.3 units (the font's small forms are very slightly bolder).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: Plane vectors and 2 × 2 matrices step by step: ops, linear maps, eigenvectors, bases; formulas beside
|
|
3
|
+
steps: vectors → each op → matrix → basis
|
|
4
|
+
props:
|
|
5
|
+
dur: s per step
|
|
6
|
+
size: text px
|
|
7
|
+
example: {"range":[-4,4,-3,3],"vectors":[{"id":"a","v":[2,1],"label":"*a*"},{"id":"b","v":[-1,2],"label":"*b*"}],"ops":[{"sum":["a","b"],"as":"c","label":"*a* + *b*"},{"dot":["a","b"],"value":0}]}
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
`vectors` (`id`, `v`, `label`), `ops`: `sum`, `diff`, `scale` (`["a", 2]`), `proj`, `dot`; `as` names a result; `value` is checked. Or `matrix` or `basis`.
|
|
11
|
+
<!-- llm: omit -->
|
|
12
|
+
- `range` [xmin, xmax, ymin, ymax]; equal units.
|
|
13
|
+
- `show`: `eigen` (eigenvector spans), `unit` (default; the unit square), `det`. Complex eigenvalues report data.
|
|
14
|
+
- Colours: vectors term, the step's result emph, helpers muted dashed, the mapped grid and new basis accent2.
|
|
15
|
+
- No preview of later steps.
|
|
16
|
+
<!-- llm: end -->
|
|
17
|
+
|
|
18
|
+
Demo: `demo.html`.
|
|
19
|
+
|
|
20
|
+
<!-- llm: omit -->
|
|
21
|
+
Notes
|
|
22
|
+
|
|
23
|
+
- 2-D only.
|
|
24
|
+
- The formula panel's lines are limited by the height; extra lines report layout.
|
|
25
|
+
<!-- llm: end -->
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
// m-vector:平面のベクトルと 2 × 2 の行列。座標平面にベクトルを描き、和・差・スカラー倍・正射影・内積を 1 ステップずつ、
|
|
2
|
+
// 行列の 1 次変換(格子と単位正方形が I から M へ動く。固有ベクトルの向きは変わらない。面積は |det|)と、基底の取り替えを見せる。
|
|
3
|
+
// 2 次元の計算はパーツがする(書いた value は計算と比べて確かめる)。右の欄に、ステップごとの式を 1 行ずつ足す。
|
|
4
|
+
// <m-vector style="height:440px"><script type="application/json">
|
|
5
|
+
// {"range": [-4, 4, -3, 3], "vectors": [{"id": "a", "v": [2, 1], "label": "*a*"}, {"id": "b", "v": [-1, 2], "label": "*b*"}],
|
|
6
|
+
// "ops": [{"sum": ["a", "b"], "as": "c", "label": "*a* + *b*"}, {"dot": ["a", "b"]}]}
|
|
7
|
+
// (JSON の終わり)</m-vector>
|
|
8
|
+
// 色:ベクトル --term、そのステップの結果 --emph、補助の線(平行移動・垂線)--muted の破線、変換した格子・新しい基底 --accent2、
|
|
9
|
+
// 固有ベクトルの向き --emph の破線。
|
|
10
|
+
egatariParts.define({name: "vector", version: "2.1.0", requires: {base: "1.3.0"}, element: "m-vector"}, function(deps){
|
|
11
|
+
"use strict";
|
|
12
|
+
var base = deps.base, D = base, clipN = 0;
|
|
13
|
+
var NUM = {type: "number"}, V2 = {type: "array", minItems: 2, maxItems: 2, items: NUM}, ID = {type: "string"};
|
|
14
|
+
var T = {
|
|
15
|
+
ja: {proj: function(a, b){ return a + " の " + b + " への正射影"; }, det: function(d){ return "det *M* = " + d + "(単位正方形の面積が " + d.replace(/^−/, "") + " 倍" + (d.indexOf("−") === 0 ? "、向きが裏返る" : "") + ")"; },
|
|
16
|
+
eigen: function(l){ return "固有値 " + l.join("、") + "(固有ベクトルの向きは変わらない)"; }, complex: "固有値は複素数(向きの変わらないベクトルはない)",
|
|
17
|
+
basis: function(b1, b2){ return "新しい基底 " + b1 + "、" + b2; }, inBasis: function(lab, s){ return lab + " = " + s; }, area: function(d){ return "面積 " + d; }},
|
|
18
|
+
en: {proj: function(a, b){ return "proj of " + a + " onto " + b; }, det: function(d){ return "det *M* = " + d + " (the unit square's area × " + d.replace(/^−/, "") + (d.indexOf("−") === 0 ? ", flipped" : "") + ")"; },
|
|
19
|
+
eigen: function(l){ return "eigenvalues " + l.join(", ") + " (eigenvectors keep their direction)"; }, complex: "complex eigenvalues (no direction is kept)",
|
|
20
|
+
basis: function(b1, b2){ return "new basis " + b1 + ", " + b2; }, inBasis: function(lab, s){ return lab + " = " + s; }, area: function(d){ return "area " + d; }}
|
|
21
|
+
};
|
|
22
|
+
// 数の字:小数 2 桁まで、末尾の 0 は書かない、負号は −
|
|
23
|
+
function num(v){ var r = Math.round(v * 100) / 100; if (Object.is(r, -0) || Math.abs(r) < 1e-12) r = 0; return (r < 0 ? "−" : "") + String(Math.abs(r)); }
|
|
24
|
+
function pair(v){ return "(" + num(v[0]) + ", " + num(v[1]) + ")"; }
|
|
25
|
+
function paren(v){ var s = num(v); return v < 0 ? "(" + s + ")" : s; }
|
|
26
|
+
function mul(M, v){ return [M[0][0] * v[0] + M[0][1] * v[1], M[1][0] * v[0] + M[1][1] * v[1]]; }
|
|
27
|
+
function dec(v){ var s = String(v).split(".")[1]; return s ? s.length : 0; }
|
|
28
|
+
return class extends base.MotionElement {
|
|
29
|
+
static partName = "vector";
|
|
30
|
+
static preview = "none";
|
|
31
|
+
static shape = {schema: {type: "object", additionalProperties: false, required: ["vectors"], properties: {
|
|
32
|
+
range: {type: "array", minItems: 4, maxItems: 4, items: NUM},
|
|
33
|
+
vectors: {type: "array", minItems: 1, maxItems: 6, items: {type: "object", additionalProperties: false, required: ["id", "v"], properties: {id: ID, v: V2, label: {type: "string"}, from: V2}}},
|
|
34
|
+
ops: {type: "array", maxItems: 8, items: {type: "object", additionalProperties: false, anyOf: [{required: ["sum"]}, {required: ["diff"]}, {required: ["scale"]}, {required: ["proj"]}, {required: ["dot"]}], properties: {
|
|
35
|
+
sum: {type: "array", minItems: 2, maxItems: 2, items: ID}, diff: {type: "array", minItems: 2, maxItems: 2, items: ID},
|
|
36
|
+
scale: {type: "array", minItems: 2, maxItems: 2, items: {type: ["string", "number"]}}, proj: {type: "array", minItems: 2, maxItems: 2, items: ID}, dot: {type: "array", minItems: 2, maxItems: 2, items: ID},
|
|
37
|
+
as: ID, label: {type: "string"}, value: {type: ["number", "array"], items: NUM}, note: {type: "string"}}}},
|
|
38
|
+
matrix: {type: "array", minItems: 2, maxItems: 2, items: V2},
|
|
39
|
+
basis: {type: "array", minItems: 2, maxItems: 2, items: V2},
|
|
40
|
+
basisLabels: {type: "array", minItems: 2, maxItems: 2, items: {type: "string"}},
|
|
41
|
+
show: {type: "array", items: {type: "string", enum: ["grid", "unit", "eigen", "det"]}}
|
|
42
|
+
}}, example: /*@egatari-block example*/{"range":[-4,4,-3,3],"vectors":[{"id":"a","v":[2,1],"label":"*a*"},{"id":"b","v":[-1,2],"label":"*b*"}],"ops":[{"sum":["a","b"],"as":"c","label":"*a* + *b*"},{"dot":["a","b"],"value":0}]}/*@egatari-block-end*/};
|
|
43
|
+
static props = {
|
|
44
|
+
dur: {type: "number", default: 1, doc: "1 ステップの秒数"},
|
|
45
|
+
size: {type: "number", default: 26, doc: "字の大きさ(px、24 以上)"}
|
|
46
|
+
};
|
|
47
|
+
get steps(){ var p = this.plan(); return p.steps.length; }
|
|
48
|
+
duration(k){ return k >= 1 && k <= this.plan().steps.length ? this.props.dur : 0; }
|
|
49
|
+
// データだけから決まる計算:ベクトル(id → 値と名前)、ステップ(種類・図形・右の欄の行)、確かめ(bad)
|
|
50
|
+
plan(){
|
|
51
|
+
if (this._plan) return this._plan;
|
|
52
|
+
var d = this.data || {}, bad = [], ja = !/^en\b/i.test(this.getAttribute("lang") || (this.closest && this.closest("[lang]") ? this.closest("[lang]").getAttribute("lang") : "ja") || "ja");
|
|
53
|
+
var L = ja ? T.ja : T.en, vec = {}, steps = [], show = d.show || ["grid", "unit"];
|
|
54
|
+
var lab = function(id){ return vec[id] ? vec[id].label : id; };
|
|
55
|
+
(d.vectors || []).forEach(function(o, i){
|
|
56
|
+
if (vec[o.id]) bad.push("vectors[" + i + "]: id \"" + o.id + "\" is used twice");
|
|
57
|
+
vec[o.id] = {v: o.v, label: o.label || "*" + o.id + "*", from: o.from || [0, 0], base: true};
|
|
58
|
+
});
|
|
59
|
+
steps.push({kind: "vectors", lines: (d.vectors || []).map(function(o){ return lab(o.id) + " = " + pair(o.v); })});
|
|
60
|
+
var need = function(id, j){ if (!vec[id]){ bad.push("ops[" + j + "]: unknown vector \"" + id + "\""); return false; } return true; };
|
|
61
|
+
var check = function(j, got, want){
|
|
62
|
+
if (got === undefined) return;
|
|
63
|
+
var g = [].concat(got), w = [].concat(want);
|
|
64
|
+
var okv = g.length === w.length && g.every(function(x, i){ return Math.abs(x - w[i]) <= 0.51 * Math.pow(10, -dec(x)) + 1e-9; });
|
|
65
|
+
if (!okv) bad.push("ops[" + j + "].value is " + JSON.stringify(got) + " but the part computes " + (w.length === 1 ? +w[0].toFixed(6) : "[" + w.map(function(x){ return +x.toFixed(6); }).join(", ") + "]"));
|
|
66
|
+
};
|
|
67
|
+
(d.ops || []).forEach(function(op, j){
|
|
68
|
+
var s = null;
|
|
69
|
+
if (op.sum && need(op.sum[0], j) && need(op.sum[1], j)){
|
|
70
|
+
var A = vec[op.sum[0]].v, B = vec[op.sum[1]].v, r = [A[0] + B[0], A[1] + B[1]];
|
|
71
|
+
s = {kind: "sum", a: op.sum[0], b: op.sum[1], r: r, lines: [lab(op.sum[0]) + " + " + lab(op.sum[1]) + " = " + pair(r)]}; check(j, op.value, r);
|
|
72
|
+
} else if (op.diff && need(op.diff[0], j) && need(op.diff[1], j)){
|
|
73
|
+
var A2 = vec[op.diff[0]].v, B2 = vec[op.diff[1]].v, r2 = [A2[0] - B2[0], A2[1] - B2[1]];
|
|
74
|
+
s = {kind: "diff", a: op.diff[0], b: op.diff[1], r: r2, lines: [lab(op.diff[0]) + " − " + lab(op.diff[1]) + " = " + pair(r2)]}; check(j, op.value, r2);
|
|
75
|
+
} else if (op.scale){
|
|
76
|
+
var id = typeof op.scale[0] === "string" ? op.scale[0] : op.scale[1], k = typeof op.scale[0] === "number" ? op.scale[0] : op.scale[1];
|
|
77
|
+
if (typeof id !== "string" || typeof k !== "number") bad.push("ops[" + j + "].scale is [vector id, number]");
|
|
78
|
+
else if (need(id, j)){ var r3 = [k * vec[id].v[0], k * vec[id].v[1]]; s = {kind: "scale", a: id, k: k, r: r3, lines: [num(k) + lab(id) + " = " + pair(r3)]}; check(j, op.value, r3); }
|
|
79
|
+
} else if ((op.proj || op.dot) && need((op.proj || op.dot)[0], j) && need((op.proj || op.dot)[1], j)){
|
|
80
|
+
var ids = op.proj || op.dot, A4 = vec[ids[0]].v, B4 = vec[ids[1]].v, bb = B4[0] * B4[0] + B4[1] * B4[1], dot = A4[0] * B4[0] + A4[1] * B4[1];
|
|
81
|
+
if (bb === 0){ bad.push("ops[" + j + "]: " + ids[1] + " is the zero vector"); }
|
|
82
|
+
else {
|
|
83
|
+
var c = dot / bb, r4 = [c * B4[0], c * B4[1]];
|
|
84
|
+
if (op.proj){ s = {kind: "proj", a: ids[0], b: ids[1], r: r4, lines: [L.proj(lab(ids[0]), lab(ids[1])) + " = " + pair(r4)]}; check(j, op.value, r4); }
|
|
85
|
+
else { s = {kind: "dot", a: ids[0], b: ids[1], r: r4, value: dot, lines: [lab(ids[0]) + "·" + lab(ids[1]) + " = " + paren(A4[0]) + "×" + paren(B4[0]) + " + " + paren(A4[1]) + "×" + paren(B4[1]) + " = " + num(dot)]}; check(j, op.value, dot); }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!s){ if (!bad.length) bad.push("ops[" + j + "] needs one of sum, diff, scale, proj, dot"); steps.push({kind: "none", lines: []}); return; }
|
|
89
|
+
if (op.note) s.lines.push(op.note);
|
|
90
|
+
s.label = op.label || (op.as ? "*" + op.as + "*" : s.kind === "scale" ? num(s.k) + lab(s.a) : "");
|
|
91
|
+
if (op.as){
|
|
92
|
+
if (vec[op.as]) bad.push("ops[" + j + "].as \"" + op.as + "\" is already a vector");
|
|
93
|
+
else if (s.kind !== "dot") vec[op.as] = {v: s.r, label: op.label || "*" + op.as + "*", from: [0, 0]};
|
|
94
|
+
}
|
|
95
|
+
steps.push(s);
|
|
96
|
+
});
|
|
97
|
+
if (d.matrix && d.basis) bad.push("matrix and basis are separate lessons: give one of them");
|
|
98
|
+
if (d.matrix){
|
|
99
|
+
var M = d.matrix, det = M[0][0] * M[1][1] - M[0][1] * M[1][0], tr = M[0][0] + M[1][1], disc = tr * tr - 4 * det, ev = [];
|
|
100
|
+
var lines = ["*M* = ((" + num(M[0][0]) + ", " + num(M[0][1]) + "), (" + num(M[1][0]) + ", " + num(M[1][1]) + "))"];
|
|
101
|
+
if (show.indexOf("det") >= 0 || show.indexOf("unit") >= 0) lines.push(L.det(num(det)));
|
|
102
|
+
if (show.indexOf("eigen") >= 0){
|
|
103
|
+
if (disc < -1e-12){ bad.push("matrix has complex eigenvalues; its eigenvector spans are not drawn (leave eigen out of show)"); lines.push(L.complex); }
|
|
104
|
+
else {
|
|
105
|
+
var sq = Math.sqrt(Math.max(0, disc)), ls = disc > 1e-12 ? [(tr + sq) / 2, (tr - sq) / 2] : [tr / 2];
|
|
106
|
+
ls.forEach(function(l){
|
|
107
|
+
// (M − λI) x = 0 の解の向き
|
|
108
|
+
var a = M[0][0] - l, b = M[0][1], c2 = M[1][0], e = M[1][1] - l, u = Math.abs(a) + Math.abs(b) > 1e-9 ? [-b, a] : Math.abs(c2) + Math.abs(e) > 1e-9 ? [-e, c2] : [1, 0];
|
|
109
|
+
var n = Math.hypot(u[0], u[1]); ev.push({l: l, u: [u[0] / n, u[1] / n]});
|
|
110
|
+
if (Math.abs(a) + Math.abs(b) + Math.abs(c2) + Math.abs(e) < 1e-9) ev.push({l: l, u: [0, 1]}); // M = λI:どの向きも
|
|
111
|
+
});
|
|
112
|
+
lines.push(L.eigen(ls.map(num)));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
steps.push({kind: "matrix", M: M, det: det, ev: ev, lines: lines});
|
|
116
|
+
}
|
|
117
|
+
if (d.basis){
|
|
118
|
+
var Bm = d.basis, bd = Bm[0][0] * Bm[1][1] - Bm[1][0] * Bm[0][1], bl = d.basisLabels || ["*b*_1", "*b*_2"];
|
|
119
|
+
if (Math.abs(bd) < 1e-12) bad.push("basis vectors are parallel (not a basis)");
|
|
120
|
+
var lines2 = [L.basis(bl[0] + " = " + pair(Bm[0]), bl[1] + " = " + pair(Bm[1]))];
|
|
121
|
+
if (Math.abs(bd) >= 1e-12) (d.vectors || []).forEach(function(o){
|
|
122
|
+
// v = c1 b1 + c2 b2 → (c1, c2) = B⁻¹ v(B の列が b1, b2)
|
|
123
|
+
var c1 = (o.v[0] * Bm[1][1] - o.v[1] * Bm[1][0]) / bd, c2 = (Bm[0][0] * o.v[1] - Bm[0][1] * o.v[0]) / bd;
|
|
124
|
+
var term = function(c, l, first){ if (Math.abs(c) < 1e-12) return ""; var s = Math.abs(Math.abs(c) - 1) < 1e-12 ? l : num(Math.abs(c)) + l; return (c < 0 ? (first ? "−" : " − ") : (first ? "" : " + ")) + s; };
|
|
125
|
+
var t1 = term(c1, bl[0], true), t2 = term(c2, bl[1], !t1);
|
|
126
|
+
lines2.push(L.inBasis(lab(o.id), (t1 + t2) || "0"));
|
|
127
|
+
});
|
|
128
|
+
steps.push({kind: "basis", B: Bm, labels: bl, lines: lines2});
|
|
129
|
+
}
|
|
130
|
+
// 範囲:書いていなければ、すべてのベクトルと結果が入る整数の範囲(1 の余白)
|
|
131
|
+
var r = d.range;
|
|
132
|
+
if (!r){
|
|
133
|
+
var xs = [0], ys = [0];
|
|
134
|
+
Object.keys(vec).forEach(function(id){ var o = vec[id]; xs.push(o.from[0], o.from[0] + o.v[0]); ys.push(o.from[1], o.from[1] + o.v[1]); });
|
|
135
|
+
steps.forEach(function(s){ if (s.r){ xs.push(s.r[0]); ys.push(s.r[1]); } if (s.kind === "sum"){ var A = vec[s.a].v, B = vec[s.b].v; xs.push(A[0] + B[0]); ys.push(A[1] + B[1]); } });
|
|
136
|
+
if (d.matrix) Object.keys(vec).forEach(function(id){ var w = mul(d.matrix, vec[id].v); xs.push(w[0]); ys.push(w[1]); });
|
|
137
|
+
if (d.basis) d.basis.forEach(function(b){ xs.push(b[0]); ys.push(b[1]); });
|
|
138
|
+
r = [Math.floor(Math.min.apply(null, xs)) - 1, Math.ceil(Math.max.apply(null, xs)) + 1, Math.floor(Math.min.apply(null, ys)) - 1, Math.ceil(Math.max.apply(null, ys)) + 1];
|
|
139
|
+
} else if (!(r[1] > r[0] && r[3] > r[2])) { bad.push("range is [xmin, xmax, ymin, ymax] with min < max"); r = [-4, 4, -3, 3]; }
|
|
140
|
+
return (this._plan = {vec: vec, steps: steps, bad: bad, range: r, show: show, L: L, ja: ja, d: d});
|
|
141
|
+
}
|
|
142
|
+
mount(ctx){
|
|
143
|
+
var self = this, P = this.props, pl = this.plan(), d = pl.d;
|
|
144
|
+
if (!(Number.isFinite(P.dur) && P.dur > 0)){ ctx.report("attr", "[vector] dur must be positive; using 1"); P.dur = 1; }
|
|
145
|
+
if (!(Number.isFinite(P.size) && P.size >= 24)){ ctx.report("attr", "[vector] size must be at least 24; using 26"); P.size = 26; }
|
|
146
|
+
pl.bad.forEach(function(s){ ctx.report("data", "[vector] " + s); });
|
|
147
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
148
|
+
var W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight), fs = P.size, tick = 24, row = Math.ceil(fs * 1.65), r = pl.range;
|
|
149
|
+
// 右の欄の行(ステップごとに足す)
|
|
150
|
+
var allLines = [].concat.apply([], pl.steps.map(function(s){ return s.lines; }));
|
|
151
|
+
var tw = function(s){ return base.textWidth(s.replace(/\*/g, "").replace(/_(\d)/g, "$1"), fs, {font: self}); };
|
|
152
|
+
var panelNatural = Math.max(200, Math.max.apply(null, allLines.map(tw).concat([0]))) + 32;
|
|
153
|
+
var m = {l: 44, r: 16, t: 24, b: 42}; // 目盛りの数字の分
|
|
154
|
+
var sx = r[1] - r[0], sy = r[3] - r[2];
|
|
155
|
+
var s0 = Math.min((W - panelNatural - 24 - m.l - m.r) / sx, (H - m.t - m.b) / sy);
|
|
156
|
+
var s = Math.max(4, Math.min(s0, (H - m.t - m.b) / sy));
|
|
157
|
+
if (s0 < 30) s = Math.max(4, Math.min((W * 0.6 - m.l - m.r) / sx, (H - m.t - m.b) / sy));
|
|
158
|
+
var pw = sx * s, ph = sy * s, ox = m.l, oy = Math.max(m.t, (H - m.b - ph) / 2 + m.t / 2);
|
|
159
|
+
var panelX = ox + pw + m.r + 24, panelW = Math.max(1, W - panelX);
|
|
160
|
+
if (s < 30 || panelW < 200) ctx.report("size", "[vector] element is " + W + " × " + H + " px; allow about " + Math.ceil(m.l + m.r + 30 * sx + 24 + panelNatural) + " × " + Math.ceil(m.t + m.b + 30 * sy) + " px for this range and the formulas (a unit of at least 30 px)");
|
|
161
|
+
var X = function(x){ return ox + (x - r[0]) * s; }, Y = function(y){ return oy + (r[3] - y) * s; };
|
|
162
|
+
this.geo = {X: X, Y: Y, s: s, ox: ox, oy: oy, pw: pw, ph: ph, fs: fs};
|
|
163
|
+
this.setAttribute("role", "img");
|
|
164
|
+
if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
|
|
165
|
+
if (!this._aria) this.setAttribute("aria-label", allLines.map(function(t){ return t.replace(/\*/g, "").replace(/_(\d)/g, "$1"); }).join("; "));
|
|
166
|
+
var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true"}, this);
|
|
167
|
+
var id = "vector-2-0-0-clip" + (++clipN), defs = D.el("defs", {}, svg), cp = D.el("clipPath", {id: id}, defs);
|
|
168
|
+
D.el("rect", {x: ox, y: oy, width: pw, height: ph}, cp);
|
|
169
|
+
var plane = D.el("g", {"clip-path": "url(#" + id + ")"}, svg);
|
|
170
|
+
// 格子と軸
|
|
171
|
+
var step = sx > 16 || sy > 16 ? 2 : 1, gx = [], gy = [];
|
|
172
|
+
for (var x = Math.ceil(r[0] / step) * step; x <= r[1] + 1e-9; x += step) gx.push(x);
|
|
173
|
+
for (var y = Math.ceil(r[2] / step) * step; y <= r[3] + 1e-9; y += step) gy.push(y);
|
|
174
|
+
this.gridG = D.el("g", {}, plane);
|
|
175
|
+
if (pl.show.indexOf("grid") >= 0){
|
|
176
|
+
gx.forEach(function(x){ D.el("line", {x1: X(x), y1: Y(r[2]), x2: X(x), y2: Y(r[3]), stroke: "var(--line)", "stroke-width": x === 0 ? 0 : 1.5}, self.gridG); });
|
|
177
|
+
gy.forEach(function(y){ D.el("line", {x1: X(r[0]), y1: Y(y), x2: X(r[1]), y2: Y(y), stroke: "var(--line)", "stroke-width": y === 0 ? 0 : 1.5}, self.gridG); });
|
|
178
|
+
}
|
|
179
|
+
if (r[0] <= 0 && r[1] >= 0) D.el("line", {x1: X(0), y1: Y(r[2]), x2: X(0), y2: Y(r[3]), stroke: "var(--muted)", "stroke-width": 2}, plane);
|
|
180
|
+
if (r[2] <= 0 && r[3] >= 0) D.el("line", {x1: X(r[0]), y1: Y(0), x2: X(r[1]), y2: Y(0), stroke: "var(--muted)", "stroke-width": 2}, plane);
|
|
181
|
+
D.el("rect", {x: ox, y: oy, width: pw, height: ph, fill: "none", stroke: "var(--line)", "stroke-width": 2}, svg);
|
|
182
|
+
// 目盛りの数字(0 は書かない。混むときは 1 つおき)
|
|
183
|
+
var every = Math.max(1, Math.ceil(36 / (s * step)));
|
|
184
|
+
gx.forEach(function(x, i){ if (x !== 0 && i % every === 0) D.el("text", {x: X(x), y: oy + ph + tick + 2, "font-size": tick, "text-anchor": "middle", fill: "var(--muted)"}, svg).textContent = num(x); });
|
|
185
|
+
gy.forEach(function(y, i){ if (y !== 0 && y !== r[2] && i % every === 0) D.el("text", {x: ox - 8, y: Y(y) + tick * 0.36, "font-size": tick, "text-anchor": "end", fill: "var(--muted)"}, svg).textContent = num(y); });
|
|
186
|
+
// 変換する層(格子・単位正方形・固有ベクトルの向き)と、新しい基底の格子
|
|
187
|
+
var mx = pl.steps.find(function(q){ return q.kind === "matrix"; }), bs = pl.steps.find(function(q){ return q.kind === "basis"; });
|
|
188
|
+
var R = Math.max(Math.abs(r[0]), Math.abs(r[1]), Math.abs(r[2]), Math.abs(r[3])) * 4 + 4;
|
|
189
|
+
this.tGrid = []; this.eigenL = []; this.unit = null; this.bGrid = [];
|
|
190
|
+
if (mx){
|
|
191
|
+
var gT = this.tGridG = D.el("g", {opacity: 0}, plane);
|
|
192
|
+
for (var i = -Math.ceil(R); i <= Math.ceil(R); i++){
|
|
193
|
+
this.tGrid.push({p: [i, -R], q: [i, R], e: D.el("line", {stroke: "var(--accent2)", "stroke-width": i === 0 ? 3 : 1.5}, gT)});
|
|
194
|
+
this.tGrid.push({p: [-R, i], q: [R, i], e: D.el("line", {stroke: "var(--accent2)", "stroke-width": i === 0 ? 3 : 1.5}, gT)});
|
|
195
|
+
}
|
|
196
|
+
if (pl.show.indexOf("unit") >= 0) this.unit = D.el("path", {fill: "var(--accent2)", "fill-opacity": 0.25, stroke: "var(--accent2)", "stroke-width": 2, opacity: 0}, plane);
|
|
197
|
+
mx.ev.forEach(function(e){ self.eigenL.push(D.el("line", {x1: X(-R * e.u[0]), y1: Y(-R * e.u[1]), x2: X(R * e.u[0]), y2: Y(R * e.u[1]), stroke: "var(--emph)", "stroke-width": 2.5, "stroke-dasharray": "10 8", opacity: 0}, plane)); });
|
|
198
|
+
}
|
|
199
|
+
if (bs){
|
|
200
|
+
var gB = this.bGridG = D.el("g", {opacity: 0}, plane), B = bs.B;
|
|
201
|
+
for (var i2 = -Math.ceil(R); i2 <= Math.ceil(R); i2++){
|
|
202
|
+
[[[i2, -R], [i2, R]], [[-R, i2], [R, i2]]].forEach(function(pq){
|
|
203
|
+
var p = [pq[0][0] * B[0][0] + pq[0][1] * B[1][0], pq[0][0] * B[0][1] + pq[0][1] * B[1][1]], q = [pq[1][0] * B[0][0] + pq[1][1] * B[1][0], pq[1][0] * B[0][1] + pq[1][1] * B[1][1]];
|
|
204
|
+
D.el("line", {x1: X(p[0]), y1: Y(p[1]), x2: X(q[0]), y2: Y(q[1]), stroke: "var(--accent2)", "stroke-width": i2 === 0 ? 3 : 1.5}, gB);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// 矢印(線と先の三角)。描くたびに座標を書く
|
|
209
|
+
var arrowG = D.el("g", {}, svg);
|
|
210
|
+
var all = this.allArrows = [], labs = this.allLabels = [];
|
|
211
|
+
// marks for the geometry check (spec §8.4): each arrow is an edge (its line, not the head) between unnamed ends, and a name is a label of its arrow
|
|
212
|
+
var mk = function(col, dash, wd, id){ var g = D.el("g", {opacity: 0, "data-part": "edge", "data-part-id": id, "data-part-from": "@" + id, "data-part-to": "@" + id}, arrowG); return all[all.length] = {g: g, line: D.el("line", Object.assign({"data-part-line": "", stroke: col, "stroke-width": wd || 4, "stroke-linecap": "round"}, dash ? {"stroke-dasharray": "10 8"} : {}), g), head: D.el("path", {fill: col}, g), col: col}; };
|
|
213
|
+
this.arrows = {};
|
|
214
|
+
Object.keys(pl.vec).forEach(function(k){ if (pl.vec[k].base) self.arrows[k] = mk("var(--term)", false, 0, "v-" + k); });
|
|
215
|
+
this.labG = D.el("g", {}, svg);
|
|
216
|
+
this.labels = {};
|
|
217
|
+
// 添え字(_1・^2)のある名前は 32px 以上で組む:mtext の添え字は 24px より小さくしないので、本文が 24〜26px だと同じ大きさに見える
|
|
218
|
+
var mkLab = function(t, id){ var g = D.el("g", {opacity: 0}, self.labG); D.mtext(g, 0, 0, t, {"data-part": "label", "data-part-id": id, "data-part-of": "edge", "font-size": /(^|[^\\])[_^]./.test(t) ? Math.max(fs, 32) : fs, "text-anchor": "middle", fill: "var(--fg)"}); labs.push(g); return g; };
|
|
219
|
+
Object.keys(pl.vec).forEach(function(k){ if (pl.vec[k].base) self.labels[k] = mkLab(pl.vec[k].label, "v-" + k); });
|
|
220
|
+
// ステップごとの補助と結果
|
|
221
|
+
this.opG = pl.steps.map(function(st, si){
|
|
222
|
+
var o = {}, sid = "step" + (si + 1);
|
|
223
|
+
if (st.kind === "sum" || st.kind === "diff" || st.kind === "proj" || st.kind === "dot") o.help = mk("var(--muted)", true, 3, sid + "-help");
|
|
224
|
+
if (st.kind === "proj" || st.kind === "dot"){ var b2 = pl.vec[st.b].v, nb = Math.hypot(b2[0], b2[1]) || 1, RR = 1000; o.lineB = D.el("line", {x1: X(-RR * b2[0] / nb), y1: Y(-RR * b2[1] / nb), x2: X(RR * b2[0] / nb), y2: Y(RR * b2[1] / nb), stroke: "var(--muted)", "stroke-width": 1.5, opacity: 0}, plane); }
|
|
225
|
+
if (st.kind !== "vectors" && st.kind !== "matrix" && st.kind !== "basis" && st.kind !== "none"){ o.res = mk("var(--emph)", false, 5, sid); if (st.label) o.lab = mkLab(st.label, sid); }
|
|
226
|
+
if (st.kind === "basis"){ o.b1 = mk("var(--accent2)", false, 5, sid + "-b1"); o.b2 = mk("var(--accent2)", false, 5, sid + "-b2"); o.l1 = mkLab(st.labels[0], sid + "-b1"); o.l2 = mkLab(st.labels[1], sid + "-b2"); }
|
|
227
|
+
return o;
|
|
228
|
+
});
|
|
229
|
+
// 右の欄
|
|
230
|
+
var lg = D.el("g", {}, svg), y0 = oy + fs, maxLines = Math.floor((H - y0 + fs) / row);
|
|
231
|
+
if (allLines.length > maxLines) ctx.report("layout", "[vector] the formulas need " + allLines.length + " lines; the panel holds " + maxLines + " (fewer ops, or a taller element)");
|
|
232
|
+
var n = 0;
|
|
233
|
+
this.lineG = pl.steps.map(function(st){
|
|
234
|
+
return st.lines.map(function(t){
|
|
235
|
+
var g = D.el("g", {opacity: 0}, lg), yy = y0 + Math.min(n, maxLines - 1) * row; n++;
|
|
236
|
+
var txt = t; if (tw(t) > panelW - 8){ ctx.report("layout", "[vector] the line \"" + t.replace(/\*/g, "").slice(0, 24) + "…\" is wider than the panel (" + Math.floor(panelW) + " px)"); }
|
|
237
|
+
D.mtext(g, panelX, yy, txt, {"font-size": fs, fill: "var(--fg)"});
|
|
238
|
+
return g;
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// 矢印を p から q へ(e は 0〜1 の伸び)
|
|
243
|
+
arrow(a, p, q, e){
|
|
244
|
+
var G = this.geo, x0 = G.X(p[0]), y0 = G.Y(p[1]), x1 = G.X(p[0] + (q[0] - p[0]) * e), y1 = G.Y(p[1] + (q[1] - p[1]) * e), dx = x1 - x0, dy = y1 - y0, n = Math.hypot(dx, dy);
|
|
245
|
+
if (n < 1){ a.g.setAttribute("opacity", 0); return; }
|
|
246
|
+
var ux = dx / n, uy = dy / n, h = Math.min(18, n * 0.6), w = h * 0.55, bx = x1 - ux * h, by = y1 - uy * h;
|
|
247
|
+
a.line.setAttribute("x1", x0.toFixed(1)); a.line.setAttribute("y1", y0.toFixed(1)); a.line.setAttribute("x2", bx.toFixed(1)); a.line.setAttribute("y2", by.toFixed(1));
|
|
248
|
+
a.head.setAttribute("d", "M" + x1.toFixed(1) + " " + y1.toFixed(1) + " L" + (bx - uy * w).toFixed(1) + " " + (by + ux * w).toFixed(1) + " L" + (bx + uy * w).toFixed(1) + " " + (by - ux * w).toFixed(1) + " Z");
|
|
249
|
+
a.g.setAttribute("opacity", 1);
|
|
250
|
+
}
|
|
251
|
+
// 名前を矢印の先の少し先に
|
|
252
|
+
place(g, p, q, op){
|
|
253
|
+
var G = this.geo, dx = q[0] - p[0], dy = q[1] - p[1], n = Math.hypot(dx, dy) || 1, off = G.fs * 0.9;
|
|
254
|
+
var x = G.X(q[0]) + dx / n * off, y = G.Y(q[1]) - dy / n * off + G.fs * 0.35;
|
|
255
|
+
g.setAttribute("transform", "translate(" + x.toFixed(1) + " " + y.toFixed(1) + ")"); g.setAttribute("opacity", op);
|
|
256
|
+
}
|
|
257
|
+
render(k, t){
|
|
258
|
+
if (!this.svg) return;
|
|
259
|
+
var self = this, pl = this.plan(), G = this.geo, dur = this.props.dur, steps = pl.steps, ph = function(i){ return k > i + 1 ? 1 : k < i + 1 ? 0 : base.prog(t, 0, dur); };
|
|
260
|
+
var mi = steps.findIndex(function(q){ return q.kind === "matrix"; }), bi = steps.findIndex(function(q){ return q.kind === "basis"; });
|
|
261
|
+
var em = mi >= 0 ? ph(mi) : 0, M = mi >= 0 ? steps[mi].M : null;
|
|
262
|
+
var A = M ? [[1 + (M[0][0] - 1) * em, M[0][1] * em], [M[1][0] * em, 1 + (M[1][1] - 1) * em]] : null;
|
|
263
|
+
var tf = function(v){ return A ? mul(A, v) : v; };
|
|
264
|
+
// ベクトル
|
|
265
|
+
this.allArrows.forEach(function(a){ a.line.setAttribute("x1", 0); a.line.setAttribute("y1", 0); a.line.setAttribute("x2", 0); a.line.setAttribute("y2", 0); a.head.setAttribute("d", ""); a.head.setAttribute("opacity", 1); a.g.setAttribute("opacity", 0); });
|
|
266
|
+
this.allLabels.forEach(function(g){ g.setAttribute("transform", "translate(0 0)"); g.setAttribute("opacity", 0); });
|
|
267
|
+
var e0 = ph(0);
|
|
268
|
+
Object.keys(this.arrows).forEach(function(id){
|
|
269
|
+
var o = pl.vec[id], p = tf(o.from), q = tf([o.from[0] + o.v[0], o.from[1] + o.v[1]]);
|
|
270
|
+
if (e0 <= 0){ self.arrows[id].g.setAttribute("opacity", 0); self.labels[id].setAttribute("opacity", 0); return; }
|
|
271
|
+
self.arrows[id].g.setAttribute("opacity", 1); self.arrow(self.arrows[id], p, q, e0); self.place(self.labels[id], p, [p[0] + (q[0] - p[0]) * e0, p[1] + (q[1] - p[1]) * e0], e0.toFixed(3));
|
|
272
|
+
});
|
|
273
|
+
// 操作:補助は そのステップの間だけ(次のステップで消える)、結果は残す(行列の変換にも付いていく)
|
|
274
|
+
steps.forEach(function(st, i){
|
|
275
|
+
var o = self.opG[i], e = ph(i);
|
|
276
|
+
var e1 = k > i + 1 ? 1 : k < i + 1 ? 0 : base.prog(t, 0, dur / 2), e2 = k > i + 1 ? 1 : k < i + 1 ? 0 : base.prog(t, dur / 2, dur / 2);
|
|
277
|
+
var helpOn = k === i + 1;
|
|
278
|
+
if (o.help) o.help.g.setAttribute("opacity", 0);
|
|
279
|
+
if (o.lineB) o.lineB.setAttribute("opacity", 0);
|
|
280
|
+
if (st.kind === "sum" || st.kind === "diff"){
|
|
281
|
+
var a = pl.vec[st.a].v, b = pl.vec[st.b].v;
|
|
282
|
+
if (helpOn){
|
|
283
|
+
if (st.kind === "sum") self.arrow(o.help, tf([a[0] * e1, a[1] * e1]), tf([a[0] * e1 + b[0], a[1] * e1 + b[1]]), 1); // b を a の先へ平行移動
|
|
284
|
+
else self.arrow(o.help, tf(b), tf(a), e1); // b の先から a の先へ
|
|
285
|
+
}
|
|
286
|
+
if (e2 > 0) self.arrow(o.res, [0, 0], tf(st.r), e2); else o.res.g.setAttribute("opacity", 0);
|
|
287
|
+
} else if (st.kind === "scale"){
|
|
288
|
+
var v = pl.vec[st.a].v;
|
|
289
|
+
if (e > 0) self.arrow(o.res, [0, 0], tf([v[0] * (1 + (st.k - 1) * e), v[1] * (1 + (st.k - 1) * e)]), 1); else o.res.g.setAttribute("opacity", 0);
|
|
290
|
+
} else if (st.kind === "proj" || st.kind === "dot"){
|
|
291
|
+
var a2 = pl.vec[st.a].v;
|
|
292
|
+
if (helpOn){
|
|
293
|
+
o.lineB.setAttribute("opacity", 1);
|
|
294
|
+
self.arrow(o.help, a2, st.r, e1); o.help.head.setAttribute("opacity", 0);
|
|
295
|
+
}
|
|
296
|
+
if (e2 > 0) self.arrow(o.res, [0, 0], tf(st.r), e2); else o.res.g.setAttribute("opacity", 0);
|
|
297
|
+
} else if (st.kind === "basis"){
|
|
298
|
+
var B = st.B;
|
|
299
|
+
if (e > 0){ self.arrow(o.b1, [0, 0], B[0], e); self.arrow(o.b2, [0, 0], B[1], e); self.place(o.l1, [0, 0], [B[0][0] * e, B[0][1] * e], e.toFixed(3)); self.place(o.l2, [0, 0], [B[1][0] * e, B[1][1] * e], e.toFixed(3)); }
|
|
300
|
+
else { o.b1.g.setAttribute("opacity", 0); o.b2.g.setAttribute("opacity", 0); o.l1.setAttribute("opacity", 0); o.l2.setAttribute("opacity", 0); }
|
|
301
|
+
}
|
|
302
|
+
if (o.lab){ if (o.res && o.res.g.getAttribute("opacity") !== "0" && (e2 > 0 || st.kind === "scale" && e > 0)) self.place(o.lab, [0, 0], tf(st.kind === "scale" ? [pl.vec[st.a].v[0] * (1 + (st.k - 1) * e), pl.vec[st.a].v[1] * (1 + (st.k - 1) * e)] : st.r), (st.kind === "scale" ? e : e2).toFixed(3)); else o.lab.setAttribute("opacity", 0); }
|
|
303
|
+
// 右の欄:そのステップで出す
|
|
304
|
+
self.lineG[i].forEach(function(g){ g.setAttribute("opacity", (k > i + 1 ? 1 : k < i + 1 ? 0 : base.prog(t, 0, dur / 2)).toFixed(3)); });
|
|
305
|
+
});
|
|
306
|
+
// 行列:格子・単位正方形・固有ベクトルの向き
|
|
307
|
+
if (A){
|
|
308
|
+
this.tGrid.forEach(function(L){ var p = mul(A, L.p), q = mul(A, L.q); L.e.setAttribute("x1", G.X(p[0]).toFixed(1)); L.e.setAttribute("y1", G.Y(p[1]).toFixed(1)); L.e.setAttribute("x2", G.X(q[0]).toFixed(1)); L.e.setAttribute("y2", G.Y(q[1]).toFixed(1)); });
|
|
309
|
+
this.tGridG.setAttribute("opacity", k >= mi + 1 ? 1 : 0);
|
|
310
|
+
this.gridG.setAttribute("opacity", k >= mi + 1 ? 0.35 : 1);
|
|
311
|
+
if (this.unit){ var c = [[0, 0], [1, 0], [1, 1], [0, 1]].map(function(v){ var w = mul(A, v); return G.X(w[0]).toFixed(1) + " " + G.Y(w[1]).toFixed(1); }); this.unit.setAttribute("d", "M" + c.join(" L") + " Z"); this.unit.setAttribute("opacity", k >= mi + 1 ? 1 : 0); }
|
|
312
|
+
this.eigenL.forEach(function(l){ l.setAttribute("opacity", k >= mi + 1 ? 1 : 0); });
|
|
313
|
+
}
|
|
314
|
+
if (bi >= 0){ var eb = ph(bi); this.bGridG.setAttribute("opacity", eb.toFixed(3)); this.gridG.setAttribute("opacity", (1 - 0.65 * eb).toFixed(3)); }
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
});
|