egatari 0.6.14 → 0.6.16
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 +62 -1
- package/README.ja.md +65 -64
- package/README.md +40 -39
- package/bin/egatari.mjs +3 -3
- package/components.lock.json +507 -153
- package/components2.lock.json +1710 -33
- package/kit/check-messages.mjs +105 -71
- package/kit/check.mjs +17 -11
- package/kit/core/article-messages.mjs +15 -15
- package/kit/core/article-render.mjs +1 -1
- package/kit/core/article-text.mjs +3 -1
- package/kit/core/build-core.mjs +23 -1
- package/kit/core/check-parity.mjs +2 -2
- package/kit/core/check-rules.mjs +12 -7
- package/kit/core/colab-core.mjs +2 -2
- package/kit/core/comment-core.mjs +6 -0
- package/kit/core/export-name.mjs +2 -2
- package/kit/core/geometry-check.mjs +363 -25
- package/kit/core/layout-scan.mjs +75 -5
- package/kit/core/live-policy.mjs +2 -2
- package/kit/core/live.mjs +2 -2
- package/kit/core/llm-fix.mjs +24 -13
- package/kit/core/llm-insert.mjs +11 -11
- package/kit/core/llm-outline.mjs +7 -7
- package/kit/core/llm-pack-assemble.mjs +5 -2
- package/kit/core/llm-pack-data.mjs +225 -39
- package/kit/core/llm-pack.mjs +3 -3
- package/kit/core/new-deck.mjs +17 -3
- package/kit/core/part-labels.mjs +6 -0
- package/kit/core/parts2.mjs +5 -5
- package/kit/core/player.mjs +18 -0
- package/kit/core/portable.mjs +26 -8
- package/kit/core/purposes.mjs +2 -2
- package/kit/core/ref-voice.mjs +1 -1
- package/kit/core/scorm.mjs +1 -1
- package/kit/core/sound-preferences.mjs +1 -1
- package/kit/core/theme-derive.mjs +209 -0
- package/kit/core/themes-list.mjs +1 -1
- package/kit/core/themes-lock.mjs +1 -1
- package/kit/core/tier-a.mjs +20 -8
- package/kit/deck.js +7 -4
- package/kit/instruction-version.json +1 -1
- package/kit/live.js +20 -20
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/kit/presenter.js +5 -3
- package/kit/templates/new-deck.mjs +6 -6
- package/kit/tools.js +13 -6
- package/kit/track.js +1 -1
- package/package.json +4 -2
- package/server/dev.mjs +3 -2
- package/server/editor-ui.js +28 -20
- package/server/hints.js +22 -2
- package/tts/yomi.yaml +8 -0
- package/vendor/components/CATALOG.md +21 -14
- package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/README.en.md +40 -0
- package/vendor/components/sha256/000cc8b85d22854d93587d53fe07585e0d9f0abee86d863c5ed1f6c53967912b/index.js +408 -0
- package/vendor/components/sha256/0396a1895978803ae342b7f598f187b17ead47800e8f8317a5cb041111349813/index.js +278 -0
- package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/README.en.md +26 -0
- package/vendor/components/sha256/07b8bfd9240585ee76082632c6f9483017d46ad3c74e509e715c27294970606c/index.js +322 -0
- package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/README.en.md +54 -0
- package/vendor/components/sha256/08778858e2fb42765077b50e08f848089b1d11ea394909a4f611557b94b3acf2/index.js +470 -0
- package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/README.en.md +18 -0
- package/vendor/components/sha256/0a08eb254e59cb306adb32c940ffe54e88efa3c9b7ef05ee021c38995996e742/index.js +279 -0
- package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/README.en.md +31 -0
- package/vendor/components/sha256/1001b3cfcd3fbc34370accbb37aa550c8cadbb54bf8e8155d417219de3797be9/index.js +267 -0
- package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/README.en.md +53 -0
- package/vendor/components/sha256/109c302247e0c62720872be35392a73bea72804b0ed421ef8ced3f030f72e537/index.js +171 -0
- package/vendor/components/sha256/1117758820dc561f41cf9d1cc0bab8cf3173cde7771ac10a12b94c96007c0f55/index.js +268 -0
- package/vendor/components/sha256/137017ad452afe209bdff81bc02ffae99c6b60a1c4aed2383515974f65511ff2/index.js +205 -0
- package/vendor/components/sha256/1a1471ba5f68e54304825a64e736afeda421e3763cdcbcdab2e45509562a0291/index.js +607 -0
- package/vendor/components/sha256/1b15fcc12b2fa43821e6299e87aae31aa69dbbc5a0d1b80088a5d7c5f8b8f7f5/index.js +429 -0
- package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/README.en.md +23 -0
- package/vendor/components/sha256/1cc1732d052e58f7913ee50c0fc834d896db6b00ba779164de11b442347863db/index.js +147 -0
- package/vendor/components/sha256/21c099461befc0d382ddfe982f2a6cd8eeb6dd731252164ac619525e4bacdf0d/index.js +242 -0
- package/vendor/components/sha256/2352e0e22460f4a3c46dca6cef27cd9c63f161a411f1cf56c75c585e9124503c/index.js +315 -0
- package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/README.en.md +53 -0
- package/vendor/components/sha256/2564dd8096be4cb3ba43703dc76029c1ba3965b831e430597c754865df4b67f4/index.js +171 -0
- package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/README.en.md +38 -0
- package/vendor/components/sha256/2bae0f89ba91574c6ffb654e246365acd9aaf16a7aae92d95e1bad045671fbd2/index.js +414 -0
- package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/README.en.md +45 -0
- package/vendor/components/sha256/2c68c355d60fdc879728c39245b7cf964b193628b63e9ab87df09c6bc2bfa7d3/index.js +211 -0
- package/vendor/components/sha256/2f111b900898579b3ec1611c2110db336a46d9133171a0cbb125ee37bd1f24f8/index.js +592 -0
- package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/README.en.md +45 -0
- package/vendor/components/sha256/2fd81df4107ecb28c0dcecfdb3fd8fb9a474b5a7e0aeb16d8c0c6b1275c3a178/index.js +211 -0
- package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/README.en.md +20 -0
- package/vendor/components/sha256/337febae1374670413653c453feee7cec169892e130248617c6642a91678564e/index.js +310 -0
- package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/README.en.md +35 -0
- package/vendor/components/sha256/38f6385118112c679b520909d677935176e0c7aa2183a877324eeb5108606eae/index.js +179 -0
- package/vendor/components/sha256/3af0b84b1799fc64ec74d6da9cbd343eccd89e8a11c81bfb444562c911284442/index.js +342 -0
- package/vendor/components/sha256/3c69bf3b3c6b9f76048fbc0839b3aa9699723570086d3d44bac799230ed6de5b/index.js +121 -0
- package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/README.en.md +37 -0
- package/vendor/components/sha256/3f2f66da34496213cf6140ae041122c31f13c77e5ee18ad11a3390fbc4a6ecca/index.js +501 -0
- package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/README.en.md +38 -0
- package/vendor/components/sha256/41b82d13037c4597e560cf2b3adebea4495ebb4711a8bb82b1a84495839b8fc8/index.js +414 -0
- package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/README.en.md +30 -0
- package/vendor/components/sha256/4220949efd68ff86e73ee6a0920b9f5b53f445cfcd657db72ecb2b55da1cc019/index.js +305 -0
- package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/README.en.md +31 -0
- package/vendor/components/sha256/47f7ea3e2551abb250a9f5883716791026f0f54ae9cca6d82fabdb92478c69ae/index.js +236 -0
- package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/README.en.md +21 -0
- package/vendor/components/sha256/4b515bfb3a39a6c1e2b04f235affc5bc84e74d80bfd7f9e6d9b5d84d0a9eeb57/index.js +108 -0
- package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/README.en.md +28 -0
- package/vendor/components/sha256/4e7ba7759ddebfa5432b733e5f10abfd336ef7d6cc4d46305d5ff7d00ed3a423/index.js +213 -0
- package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/README.en.md +35 -0
- package/vendor/components/sha256/52149f061935e65502b8353cf70285bba93ab24451d2daac26b994d3901d3864/index.js +179 -0
- package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/README.en.md +53 -0
- package/vendor/components/sha256/5644e63364f46ee53d5f8623355149753147cdc4720e4c66fc9b8a32627e68a5/index.js +171 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/chords.json +89 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/extras.json +192 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/fixtures/ties.json +360 -0
- package/vendor/components/sha256/5662bea8cc48f484ccf14c5a8ac12d64b2c5ab032a26176d133ed3a8eb33a557/index.js +508 -0
- package/vendor/components/sha256/59996a56df462b36e24a928d4397c9308d9e39ad8224ebd19fb5c981608ef458/index.js +521 -0
- package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/README.en.md +30 -0
- package/vendor/components/sha256/5afcaf27e9209a32a8a8e6667b637ea434326b76f563689552716de953c94a98/index.js +305 -0
- package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/README.en.md +30 -0
- package/vendor/components/sha256/5cf9baec12bac716d9218d6fbc4f95446adf31658da62564aa403bb5bdee542e/index.js +192 -0
- package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/README.en.md +20 -0
- package/vendor/components/sha256/5ffac218340cc51ce842a530f6021fc916090376b243e2ad5d4c0ef48a040ce9/index.js +307 -0
- package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/README.en.md +24 -0
- package/vendor/components/sha256/6084fd3102b7d450db3804120ac27aa585ab44937734d980fb50c51f39fc98a7/index.js +554 -0
- package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/README.en.md +25 -0
- package/vendor/components/sha256/60e3e41c34034e16f9f7ee9ce6c8d669ebb753614989fc2e5e181ef295e83631/index.js +316 -0
- package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/README.en.md +18 -0
- package/vendor/components/sha256/6156a8a03235e1ed92d3cd3ba1f40df86667059003d82e47297bd3917ef562b8/index.js +279 -0
- package/vendor/components/sha256/624acb997c4975ace65570b529b3ba00baa421c80ecb7fc80f392a64e8c573a7/index.js +107 -0
- package/vendor/components/sha256/62602488ee33dd4bdef8516de16da5ab27d7f7265d5041681beab80e08f1d482/index.js +97 -0
- package/vendor/components/sha256/67eaf344bddac79b74ed03fdcd70285c7b52b160e6c5ffbd6897848179aa5230/index.js +818 -0
- package/vendor/components/sha256/682c9c8871eccd19ff1264e0323a2e4c5798b0488b612ba0339c6fe85aab5914/index.js +926 -0
- package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/README.en.md +51 -0
- package/vendor/components/sha256/6937967bbf62098aca7cef99f14f97fa11c861a12da6a1d8fe5fa55a6b4551f2/index.js +230 -0
- package/vendor/components/sha256/72138936ed0b8fd3cb0214ae7ed250ae3f1f8b21ed6fd593544947774064ba0d/index.js +250 -0
- package/vendor/components/sha256/74c1a0f3ed1370c5003aa5770ee28cea2ce994d415680116a92fdbcd5854ba62/index.js +198 -0
- package/vendor/components/sha256/76125035eb153b98befa9c735bcd9fc4f99f774dc1d082fdae40acaadfe7d95b/index.js +818 -0
- package/vendor/components/sha256/7728cf7dde88a6688aba0ed70f23f7e21362a147beac09c1fa1a4b773e08e93b/index.js +354 -0
- package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/README.en.md +23 -0
- package/vendor/components/sha256/7822f137d446604a83c1dbc3b40fdb455001dc55da12276ff3e7079d270dd143/index.js +289 -0
- package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/README.en.md +31 -0
- package/vendor/components/sha256/7c2b93508a09a5dd36639ab1329ca6d00487b326c53db436b14295174dc03369/index.js +236 -0
- package/vendor/components/sha256/7d50e50fbb6c5ec636b62509bd88ddaac1870e0522cf11bcc293ce924d48072d/index.js +312 -0
- package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/README.en.md +42 -0
- package/vendor/components/sha256/82ffee434e7f2213031190f832f3a75a8cdf59554fdbc092c0b079d6b0753cad/index.js +549 -0
- package/vendor/components/sha256/87fc302c41b2bfeea88951ed689ec01b4dc79218c4bc69b310dc2228dfa2e153/index.js +926 -0
- package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/README.en.md +24 -0
- package/vendor/components/sha256/8886ccd82d68dc1bbf5b7ffcef746074ce8a3d26414d55691dc5e691e4976ded/index.js +103 -0
- package/vendor/components/sha256/89c8c16788e24df17920542ed6eb6557dea4a10e835de8fe839e439ccbba8014/index.js +69 -0
- package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/README.en.md +44 -0
- package/vendor/components/sha256/8beed7e471fa0d6b801b5c540f69ab77220e228c58ff16b0bc2b1a6eef30800e/index.js +304 -0
- package/vendor/components/sha256/8d9af78aef44ad2f98101c67d32473373d39725a09c923969aa621d5f5b124bb/index.js +121 -0
- package/vendor/components/sha256/8f861d71df72a82be86a3e63abf7d69bbab5aac6fa68be6e077c4e19c3519ed8/index.js +312 -0
- package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/README.en.md +54 -0
- package/vendor/components/sha256/90415da5ad04e1944258e29c929c5de65c8152c829414e911ba55a84ac89f348/index.js +470 -0
- package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/README.en.md +24 -0
- package/vendor/components/sha256/91a1e0e48e20cac705cbe6e33e66a24a2851b1dc88c5164ed906bcecba4d943f/index.js +214 -0
- package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/README.en.md +33 -0
- package/vendor/components/sha256/91a9353a0c3b3744765944783aa1537b3f6ff1677c67caede643cdf2f52289cf/index.js +390 -0
- package/vendor/components/sha256/9289efef4a75afe011e54a17e34db08cfb16a450b2e0653e6a98525495cfba99/index.js +315 -0
- package/vendor/components/sha256/93256a923199ea51108cdb7491c3c96f376dbef15b64cbf1a1aa7cc5726b4970/index.js +429 -0
- package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/README.en.md +24 -0
- package/vendor/components/sha256/94f4891971b26f5bc157ef9f7f630b1528fc7e2a4c63e84e01951a5a3f94cedc/index.js +550 -0
- package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/README.en.md +28 -0
- package/vendor/components/sha256/94f4f798fdd070fc1693494e772ff479d3e694a07a0c97b6e97c3b3895cad478/index.js +213 -0
- package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/README.en.md +40 -0
- package/vendor/components/sha256/95583538da2982ec5f508217a8f2821796e6a34cf755baa66f2aaeb1c6dae814/index.js +348 -0
- package/vendor/components/sha256/97c074a5473618c65f4c23263f056870a0b7940e73475f2a1f32f68c08d8eb0f/index.js +198 -0
- package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/README.en.md +66 -0
- package/vendor/components/sha256/98e1957b1fac2d55d9bfa6a0990ead6a2730d571c988055ca280df05a0e9ea37/index.js +984 -0
- package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/README.en.md +34 -0
- package/vendor/components/sha256/99a26795f8b351ade4a4cbbea845aeb149c96b09fe96151edda57128082185fa/index.js +244 -0
- package/vendor/components/sha256/a18b2b15d00c76462a43823b5c270c7ddd7c31794da9c236f74f20f80ec2ffdb/index.js +354 -0
- package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/README.en.md +32 -0
- package/vendor/components/sha256/a744049fc56e0a5d5b1638bef597a4e65f99d0776a35d830a389f216f314f1bc/index.js +222 -0
- package/vendor/components/sha256/a979207c60fbd2a12cb557297eb0217eb098d660de684530a0f43d0d9c64e6ef/index.js +312 -0
- package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/README.en.md +34 -0
- package/vendor/components/sha256/aba898152e40ca44e1e7bea22242bd6897a31e0254cbfd70e426907b65379af2/index.js +244 -0
- package/vendor/components/sha256/af7ed69b8969f6da14784b6e9d26e4dfd20147772ea172a99bd936a71be10fcd/index.js +278 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/chords.json +89 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/extras.json +192 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/fixtures/ties.json +360 -0
- package/vendor/components/sha256/b08a536a07498629c026f8fc2962acda791c83a99268ac715db5e764087000e2/index.js +508 -0
- package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/README.en.md +66 -0
- package/vendor/components/sha256/b28d136dffb03a3e855b2ff959712a143da9a84c3a4fd13a1126d7711083a2d6/index.js +990 -0
- package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/README.en.md +24 -0
- package/vendor/components/sha256/b2d9c417f258745c56c04e05dc9463a412a4978d46c3ffff2556f0b0fafbbfc2/index.js +550 -0
- package/vendor/components/sha256/b8096d7a60609520981273673761a110e40e3bdf52a7ab5548363b20e16f6e93/index.js +404 -0
- package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/README.en.md +32 -0
- package/vendor/components/sha256/b9e27e84b2c534b87d6da5da30ee808d7863cbd1b818082b4c11d1f8b7129b1a/index.js +222 -0
- package/vendor/components/sha256/bd8e3893df02411deccc1d6d7b02292ca0d59dfeddfafcf99419430981572c82/index.js +351 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/chords.json +89 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/extras.json +192 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/fixtures/ties.json +360 -0
- package/vendor/components/sha256/c201dbc3f1f790c59cc010b3be3566daa9085754614402e9dc1296dba9e87769/index.js +508 -0
- package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/README.en.md +31 -0
- package/vendor/components/sha256/c5226220649a5854d56ceeaea16722fe54a79b4197f71c51c4e1523bf22bec32/index.js +267 -0
- package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/OFL.txt +93 -0
- package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/index.js +749 -0
- package/vendor/components/sha256/c691f9c83d06502bf20f86df02ee5a516063d6af1e9ee8204aad8fd8c1a44a71/strokes-CHANGES.md +20 -0
- package/vendor/components/sha256/c791e69e722f64146242f97acb29a341160d0c327cfe1d76307954d80e70db85/index.js +268 -0
- package/vendor/components/sha256/c8c0de41d603b61c6ec4dc1da5b50559e213dd1f3693ee5019df858016fd6daf/index.js +747 -0
- package/vendor/components/sha256/c99d4f2ab443484b9f462e405c72ea4794838b88f8823f27c606d12cbbedb996/index.js +404 -0
- package/vendor/components/sha256/cbde046e30c35db60259911a88e2ae0bedaf545e29b1da8b8ce13bc602a33c19/index.js +465 -0
- package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/README.en.md +51 -0
- package/vendor/components/sha256/ccdd16ed76838ac9d6abb4ee695769bfecb802ae490ac91914ed68131ad04434/index.js +228 -0
- package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/README.en.md +35 -0
- package/vendor/components/sha256/ce0a52fa13ae579020d1172845647daee9ba78e070736e47740f2d2feabffe7e/index.js +179 -0
- package/vendor/components/sha256/cf0985ffcd8e7cbe2175ddb9a4342b2a4aa3f322794188fc99af8789b494460d/index.js +521 -0
- package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/LICENSE-strokesvg.txt +115 -0
- package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/OFL.txt +93 -0
- package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/index.js +749 -0
- package/vendor/components/sha256/cff7ed8a0e0708bcef2e13105b28810bda867251a9f205ad9c2f1a5b4f759866/strokes-CHANGES.md +20 -0
- package/vendor/components/sha256/d01dc7fd78d08dd720ed86b39d7877dc0913d72e914036088a86af2df2faee52/index.js +484 -0
- package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/README.en.md +24 -0
- package/vendor/components/sha256/d448fec2aeb436f187875c493b1592b373c6a18274ffc64231dbe3f1b54f8cbc/index.js +214 -0
- package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/README.en.md +31 -0
- package/vendor/components/sha256/d4aa3ffb394d5db7f47081b1818958547fe164bb968df03131f9400c103b97c4/index.js +271 -0
- package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/README.en.md +25 -0
- package/vendor/components/sha256/d582d02ceeaf1ec4d94115b806852ddb66c009788e67728ae0e08cb8d29ca546/index.js +316 -0
- package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/README.en.md +23 -0
- package/vendor/components/sha256/d75ab2c8f6c01082bfcaeaba44290367d6b49654e2bf538422b7b3e499de9acf/index.js +120 -0
- package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/README.en.md +40 -0
- package/vendor/components/sha256/d8f5272dac33066a04ecefa9a828ca11d18dec581866899f55433573ba4472d6/index.js +405 -0
- package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/README.en.md +66 -0
- package/vendor/components/sha256/dd1ff8de877573e30635928e9abce0b1fba8dfc95a079eca86703a884d3c3d59/index.js +984 -0
- package/vendor/components/sha256/ddd4b9cbbc282cbb3117ff662e1a14ecdb3cc7c16072a574418ec6a6eecef4d8/index.js +107 -0
- package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/README.en.md +22 -0
- package/vendor/components/sha256/e24a4235a661bfda4049e1c72b6c376066fcc65e27a2bdfe77942a3394726c81/index.js +145 -0
- package/vendor/components/sha256/e2da948daac7bfac158857877b5a6932dbd2369e73901abcef118c92dd20b725/index.js +747 -0
- package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/README.en.md +42 -0
- package/vendor/components/sha256/e40201a655bf5c556d70fbf45b5052dd48c33fc8030b331a9d9cbc96913d02a6/index.js +268 -0
- package/vendor/components/sha256/e653a4da80f7761442dc5b504ea5b0700fd0acf1979beeff56122cfdb3d4654c/index.js +607 -0
- package/vendor/components/sha256/ea217c6821e931b2d8474bf56d38f2dcc89ec705fe1d276f313e1c7e8db2b98a/index.js +233 -0
- package/vendor/components/sha256/ea2e4e24838574f607879c7d05556281258c018331e4da3e6f3a5263173f2e99/index.js +75 -0
- package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/README.en.md +42 -0
- package/vendor/components/sha256/eb0b402dc4738b2dca2918c7f64a4d6fc3c27b4ba419270bbe8240a3c8a77f0c/index.js +549 -0
- package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/README.en.md +44 -0
- package/vendor/components/sha256/f219b47f32b0a78e8f8f5dac83596acfed24dd6e8bfe3f05f8ebfb9582d64485/index.js +203 -0
- package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/README.en.md +34 -0
- package/vendor/components/sha256/f4204773037ae296786e3614b5bfd7487b0f5ba6d5cf92ce20262bb7613e1b6b/index.js +244 -0
- package/vendor/components/sha256/fa1a09c10181456143d125d68dbbdcacde6bab2e4a2b3e573367103ce28ebf55/index.js +228 -0
- package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/README.en.md +51 -0
- package/vendor/components/sha256/fa9c9f63d74a514636961bcb8af75063e00e39bdf85655ecf5d4d7bbc05a831a/index.js +228 -0
- package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/README.en.md +23 -0
- package/vendor/components/sha256/facebe095849528396ee91d7d6856cb6945ba89ca8b1f34dce488dccb29e9d40/index.js +147 -0
- package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/README.en.md +20 -0
- package/vendor/components/sha256/fb0a77a344098c53cc90215685cee32b0d31362a1de5b5ac0eee422ed2c3c430/index.js +307 -0
- package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/README.en.md +26 -0
- package/vendor/components/sha256/fc48e703adab4715157f8dbb0e33c8b5c00099358ae522484290a7098fda2910/index.js +322 -0
- package/vendor/components-2/manifest-2.12.0.json +2348 -0
- package/vendor/components-2/manifest-2.13.0.json +2477 -0
- package/vendor/components-2/manifest-2.14.0.json +2460 -0
- package/vendor/components-2/manifest-2.14.1.json +2460 -0
- package/vendor/components-2/manifest-2.15.0.json +2460 -0
- package/vendor/egatari-spec/SOURCE.json +3 -3
- package/vendor/egatari-spec/schema/deck-meta.schema.json +16 -1
- package/vendor/egatari-spec/schema/egatari-metadata.schema.json +17 -2
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// m-folds: the validation block advances through k train/validation splits.
|
|
2
|
+
// 2.1.0: with `splits` (and `samples`), each sample is a cell and each row is one split from scikit-learn's splitter
|
|
3
|
+
// (KFold with shuffle, StratifiedKFold = クラスの比率を保つ KFold, GroupKFold, TimeSeriesSplit, a holdout): test cells as the
|
|
4
|
+
// validation block, train cells as before, unused cells empty; class colours and names, group runs, time order. The k mode
|
|
5
|
+
// draws exactly as 2.0.1.
|
|
6
|
+
egatariParts.define({name: "folds", version: "2.1.1", requires: {base: "1.3.0"}, element: "m-folds"}, function(deps){
|
|
7
|
+
"use strict";
|
|
8
|
+
var base = deps.base;
|
|
9
|
+
var TEXT = {
|
|
10
|
+
ja: {train: "学習(学)", validate: "検証(検・枠)", t: "学", v: "検", error: "誤差", mean: "平均", fold: "分割", unused: "使わない", cls: "クラス", group: "グループ", time: "時間 →", test: "検証", trainS: "訓練"},
|
|
11
|
+
en: {train: "train (T)", validate: "validate (V, outline)", t: "T", v: "V", error: "error", mean: "mean", fold: "fold", unused: "unused", cls: "class", group: "group", time: "time →", test: "validate", trainS: "train"}
|
|
12
|
+
};
|
|
13
|
+
function set(e, a, v){ e.setAttribute(a, String(v)); }
|
|
14
|
+
function fmt(v){ return v.toFixed(2); }
|
|
15
|
+
var PAL = ["var(--series-1)", "var(--series-3)", "var(--fg)", "var(--series-4)"]; // m-classify2d の CLASS_COLORS と同じ並び
|
|
16
|
+
return class extends base.MotionElement {
|
|
17
|
+
static partName = "folds";
|
|
18
|
+
static preview = "none";
|
|
19
|
+
static shape = {schema: {type: "object", additionalProperties: false, anyOf: [{required: ["k"]}, {required: ["splits"]}], properties: {
|
|
20
|
+
k: {type: "number"}, errors: {type: "array", items: {type: "number"}}, labels: {type: "array", items: {type: "string"}},
|
|
21
|
+
samples: {type: "array", minItems: 2, maxItems: 60, items: {type: "object", additionalProperties: false, properties: {class: {type: "integer"}, group: {type: "string"}, t: {type: ["number", "string"]}}}},
|
|
22
|
+
splits: {type: "array", minItems: 1, maxItems: 10, items: {type: "object", additionalProperties: false, required: ["test"], properties: {test: {type: "array", items: {type: "integer"}}, train: {type: "array", items: {type: "integer"}}}}},
|
|
23
|
+
splitter: {type: "string", enum: ["KFold", "StratifiedKFold", "GroupKFold", "TimeSeriesSplit", "ShuffleSplit", "holdout"]},
|
|
24
|
+
classes: {type: "array", maxItems: 4, items: {type: "object", additionalProperties: false, required: ["id"], properties: {id: {type: "integer"}, label: {type: "string"}}}}
|
|
25
|
+
}}, example: {k: 5, errors: [0.21, 0.18, 0.25, 0.19, 0.22], labels: ["1", "2", "3", "4", "5"]}};
|
|
26
|
+
static props = {
|
|
27
|
+
dur: {type: "number", default: 1, doc: "ステップの秒数"},
|
|
28
|
+
size: {type: "number", default: 0, doc: "文字 px(0 は 26)"}
|
|
29
|
+
};
|
|
30
|
+
get steps(){ if (this.data.splits) return this.data.splits.length + 1; var k = this.data.k; return Number.isInteger(k) && k >= 2 && k <= 10 ? k + 1 : 0; }
|
|
31
|
+
duration(k){ return k >= 1 && k <= this.steps ? this.props.dur : 0; }
|
|
32
|
+
label(g, x, y, s, anchor){
|
|
33
|
+
var e = base.el("text", {x: x, y: y, "font-size": this.fs, "text-anchor": anchor || "start", fill: "var(--fg)"}, g);
|
|
34
|
+
e.textContent = s; return e;
|
|
35
|
+
}
|
|
36
|
+
mount(ctx){
|
|
37
|
+
var self = this, d = this.data, P = this.props;
|
|
38
|
+
this.T = /^ja\b/i.test(ctx.lang || "") ? TEXT.ja : TEXT.en;
|
|
39
|
+
var T = this.T;
|
|
40
|
+
if (!(Number.isFinite(P.dur) && P.dur > 0)){ ctx.report("attr", "[folds] dur must be positive; using 1"); P.dur = 1; }
|
|
41
|
+
if (!(P.size === 0 || Number.isFinite(P.size) && P.size >= 24)){ ctx.report("attr", "[folds] size must be 0 or at least 24; using 26"); P.size = 0; }
|
|
42
|
+
this.fs = P.size || 26;
|
|
43
|
+
this.style.display = "block"; this.style.position = "relative"; this.style.writingMode = "horizontal-tb"; this.setAttribute("role", "img");
|
|
44
|
+
if (d.splits) return this.mountSamples(ctx);
|
|
45
|
+
if (!Number.isInteger(d.k) || d.k < 2 || d.k > 10){ ctx.report("data", "[folds] k must be an integer 2–10"); return; }
|
|
46
|
+
if (d.errors && (d.errors.length !== d.k || d.errors.some(function(v){ return v < 0; }))){ ctx.report("data", "[folds] errors must contain k non-negative numbers"); return; }
|
|
47
|
+
if (d.labels && d.labels.length !== d.k){ ctx.report("data", "[folds] labels must contain k names"); return; }
|
|
48
|
+
var labels = d.labels || Array.from({length: d.k}, function(_, i){ return String(i + 1); });
|
|
49
|
+
var errors = d.errors || null, mean = errors ? errors.reduce(function(s, v){ return s + v / d.k; }, 0) : null;
|
|
50
|
+
this.model = {k: d.k, labels: labels, errors: errors, mean: mean};
|
|
51
|
+
var summary = labels.map(function(s, i){ return T.fold + " " + (i + 1) + ": " + T.validate + " " + s + ", " + T.train + " " + labels.filter(function(_, j){ return j !== i; }).join(", ") + (errors ? "; " + T.error + " " + fmt(errors[i]) : ""); }).join("; ");
|
|
52
|
+
if (!this.getAttribute("aria-label")) this.setAttribute("aria-label", summary + (errors ? "; " + T.mean + " " + fmt(mean) : ""));
|
|
53
|
+
var W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight), fs = this.fs, line = fs * 1.45 + 4;
|
|
54
|
+
var width = function(s){ return base.textWidth(s, fs, {font: self}); };
|
|
55
|
+
var errorWidth = errors ? Math.max(width(T.error), width(T.mean + " " + fmt(mean)), ...errors.map(function(v){ return Math.max(width(fmt(v)), fmt(v).length * fs * 0.62); })) + 8 : 0;
|
|
56
|
+
var left = Math.max(42, width(String(d.k)) + 16), ex = W - errorWidth - 8, right = errors ? ex - 20 : W - 8;
|
|
57
|
+
var bw = (right - left) / d.k, top = 2 * line + 16;
|
|
58
|
+
var footer = errors ? line + fs * 0.4 : 0, minRow = Math.max(32, Math.ceil(fs * 1.2));
|
|
59
|
+
var minHeight = Math.ceil(top + d.k * minRow + footer + 4);
|
|
60
|
+
var rh = Math.max(minRow, Math.min(Math.max(44, line + 4), (H - top - footer - 4) / d.k)), bh = rh - 6;
|
|
61
|
+
var letters = bh >= fs * 1.43;
|
|
62
|
+
this.geometry = {row: rh, minRow: minRow, minHeight: minHeight, letters: letters};
|
|
63
|
+
// Compact row numbers/errors use a monospace font whose box fits 32px rows.
|
|
64
|
+
function rowLabel(g, x, y, s, anchor){
|
|
65
|
+
var e = self.label(g, x, y, s, anchor);
|
|
66
|
+
if (!letters) e.setAttribute("style", "font-family:ui-monospace, Menlo, Consolas, monospace;fill:var(--fg)");
|
|
67
|
+
return e;
|
|
68
|
+
}
|
|
69
|
+
this.svg = base.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true"}, this);
|
|
70
|
+
this.header = base.el("g", {opacity: 0}, this.svg);
|
|
71
|
+
function swatch(x, validate, text){
|
|
72
|
+
base.el("rect", {x: x, y: 8, width: 32, height: fs * 1.45, fill: validate ? "var(--emph-tint)" : "var(--term-tint)", stroke: validate ? "var(--emph)" : "none", "stroke-width": 3}, self.header);
|
|
73
|
+
self.label(self.header, x + 42, fs + 4, text);
|
|
74
|
+
}
|
|
75
|
+
var legend2 = 8 + 42 + width(T.train) + 28;
|
|
76
|
+
swatch(8, false, T.train); swatch(legend2, true, T.validate);
|
|
77
|
+
var legendWidth = Math.ceil(legend2 + 42 + width(T.validate) + 8);
|
|
78
|
+
if (legendWidth > W) ctx.report("size", "[folds] legend needs " + legendWidth + " px width; element has " + W + " px");
|
|
79
|
+
if (bw < 8) ctx.report("size", "[folds] " + d.k + " blocks have " + Math.floor(bw) + " px each; allow at least 8 px per block");
|
|
80
|
+
labels.forEach(function(s, i){
|
|
81
|
+
self.label(self.header, left + (i + 0.5) * bw, 2 * line, s, "middle");
|
|
82
|
+
if (width(s) > bw - 8) ctx.report("size", "[folds] label " + (i + 1) + " needs " + Math.ceil(width(s)) + " px; block fits " + Math.max(0, Math.floor(bw - 8)) + " px (shorten the label)");
|
|
83
|
+
});
|
|
84
|
+
if (errors) this.label(this.header, ex, 2 * line, T.error);
|
|
85
|
+
this.rows = labels.map(function(_, i){
|
|
86
|
+
var g = base.el("g", {opacity: 0}, self.svg), y = top + i * rh;
|
|
87
|
+
rowLabel(g, left - 12, y + bh / 2 + fs * 0.31, String(i + 1), "end");
|
|
88
|
+
var blocks = labels.map(function(_, j){
|
|
89
|
+
var valid = i === j, x = left + j * bw + 3;
|
|
90
|
+
var rect = base.el("rect", {x: x, y: y, width: Math.max(1, bw - 6), height: bh, rx: 3, fill: valid ? "var(--emph-tint)" : "var(--term-tint)", stroke: valid ? "var(--emph)" : "none", "stroke-width": 3}, g);
|
|
91
|
+
if (letters && bw - 6 >= 40) self.label(g, x + (bw - 6) / 2, y + bh / 2 + fs * 0.31, valid ? T.v : T.t, "middle");
|
|
92
|
+
return {rect: rect, validation: valid};
|
|
93
|
+
});
|
|
94
|
+
if (errors) rowLabel(g, ex, y + bh / 2 + fs * 0.31, fmt(errors[i]));
|
|
95
|
+
return {g: g, blocks: blocks};
|
|
96
|
+
});
|
|
97
|
+
this.finalLayer = base.el("g", {opacity: 0}, this.svg);
|
|
98
|
+
var bottom = top + d.k * rh, finalY = bottom + line;
|
|
99
|
+
if (errors){
|
|
100
|
+
base.el("line", {x1: ex, x2: W - 8, y1: bottom + 6, y2: bottom + 6, stroke: "var(--muted)", "stroke-width": 2}, this.finalLayer);
|
|
101
|
+
this.label(this.finalLayer, ex, finalY, T.mean + " " + fmt(mean));
|
|
102
|
+
}
|
|
103
|
+
if (H < minHeight) ctx.report("size", "[folds] k = " + d.k + " needs at least " + minHeight + " px height (header " + top.toFixed(1) + " + " + d.k + " × " + minRow + " rows + " + (footer + 4).toFixed(1) + " footer); element has " + H + " px");
|
|
104
|
+
}
|
|
105
|
+
render(k, t){
|
|
106
|
+
if (this.sm) return this.renderSamples(k, t);
|
|
107
|
+
if (!this.model) return;
|
|
108
|
+
var dur = this.props.dur, phase = function(step){ return k > step ? 1 : k < step ? 0 : base.prog(t, 0, dur); };
|
|
109
|
+
set(this.header, "opacity", phase(1));
|
|
110
|
+
this.rows.forEach(function(o, i){ set(o.g, "opacity", phase(i + 1)); });
|
|
111
|
+
set(this.finalLayer, "opacity", phase(this.model.k + 1));
|
|
112
|
+
}
|
|
113
|
+
// 標本のモード(2.1.0):列が標本、行が分割。データの確かめと描き方。クラスの色は --emph(検証の枠)と同じ色にならないよう
|
|
114
|
+
// --series-2 を飛ばす(1 つの意味に 1 つの色)。m-classify2d の CLASS_COLORS と同じ並び
|
|
115
|
+
mountSamples(ctx){
|
|
116
|
+
var self = this, d = this.data, T = this.T, sp = d.splits, kind = d.splitter || "";
|
|
117
|
+
var n = d.samples ? d.samples.length : 1 + Math.max.apply(null, [].concat.apply([], sp.map(function(s){ return s.test.concat(s.train || []); })).concat([0]));
|
|
118
|
+
var samples = d.samples || Array.from({length: n}, function(){ return {}; }), bad = [];
|
|
119
|
+
if (n < 2 || n > 60) bad.push("splits cover " + n + " samples; 2–60 can be drawn");
|
|
120
|
+
var cls = {}; (d.classes || []).forEach(function(c, i){ cls[c.id] = i; });
|
|
121
|
+
samples.forEach(function(s, i){ if (s.class !== undefined && !(s.class in cls)) bad.push("samples[" + i + "].class " + s.class + " is not in classes"); });
|
|
122
|
+
var role = sp.map(function(s, r){
|
|
123
|
+
var a = Array(n).fill(0), testSet = {};
|
|
124
|
+
s.test.forEach(function(i){ if (!(i >= 0 && i < n)) bad.push("splits[" + r + "].test has " + i + " (samples 0–" + (n - 1) + ")"); else { a[i] = 2; testSet[i] = 1; } });
|
|
125
|
+
(s.train || Array.from({length: n}, function(_, i){ return i; }).filter(function(i){ return !testSet[i]; })).forEach(function(i){
|
|
126
|
+
if (!(i >= 0 && i < n)) bad.push("splits[" + r + "].train has " + i); else if (testSet[i]) bad.push("splits[" + r + "]: sample " + i + " is in both train and test"); else a[i] = 1;
|
|
127
|
+
});
|
|
128
|
+
return a;
|
|
129
|
+
});
|
|
130
|
+
// 分け方の決まり:KFold の仲間は、どの標本もちょうど 1 回だけ検証に入る
|
|
131
|
+
var kfold = !kind || kind === "KFold" || kind === "StratifiedKFold" || kind === "GroupKFold";
|
|
132
|
+
if (kfold){
|
|
133
|
+
for (var i = 0; i < n; i++){ var c = role.filter(function(a){ return a[i] === 2; }).length; if (c !== 1){ bad.push("sample " + i + " is in the test set of " + c + " splits; " + (kind || "KFold") + " uses each sample once (set splitter for TimeSeriesSplit, ShuffleSplit or holdout)"); break; } }
|
|
134
|
+
}
|
|
135
|
+
if (kind === "GroupKFold") role.forEach(function(a, r){ var tr = {}, te = {}; a.forEach(function(v, i){ var g = samples[i].group; if (v === 1) tr[g] = 1; if (v === 2) te[g] = 1; }); Object.keys(te).forEach(function(g){ if (tr[g]) bad.push("splits[" + r + "]: group \"" + g + "\" is in both train and test (GroupKFold keeps a group together)"); }); });
|
|
136
|
+
if (kind === "TimeSeriesSplit") role.forEach(function(a, r){ var lastTrain = a.lastIndexOf(1), firstTest = a.indexOf(2); if (lastTrain > firstTest && firstTest >= 0) bad.push("splits[" + r + "]: a train sample comes after a test sample (TimeSeriesSplit trains on the past)"); });
|
|
137
|
+
if (kind === "holdout" && sp.length !== 1) bad.push("holdout has one split; got " + sp.length);
|
|
138
|
+
if (kind === "StratifiedKFold") role.forEach(function(a, r){
|
|
139
|
+
// クラスの比率を保つ:検証に入る各クラスの数が、全体の数 ÷ 分割数から 1 未満しかずれない
|
|
140
|
+
Object.keys(cls).forEach(function(c){ var tot = samples.filter(function(s){ return String(s.class) === c; }).length, got = a.filter(function(v, i){ return v === 2 && String(samples[i].class) === c; }).length; if (Math.abs(got - tot / sp.length) >= 1) bad.push("splits[" + r + "]: class " + c + " has " + got + " test samples; StratifiedKFold keeps about " + +(tot / sp.length).toFixed(2)); });
|
|
141
|
+
});
|
|
142
|
+
if (d.errors && (d.errors.length !== sp.length || d.errors.some(function(v){ return v < 0; }))) bad.push("errors must contain one non-negative number per split");
|
|
143
|
+
bad.forEach(function(s){ ctx.report("data", "[folds] " + s); });
|
|
144
|
+
if (bad.length && bad.some(function(s){ return /samples 0–|2–60|errors must/.test(s); })) return;
|
|
145
|
+
var errors = d.errors && d.errors.length === sp.length ? d.errors : null, mean = errors ? errors.reduce(function(s, v){ return s + v / errors.length; }, 0) : null;
|
|
146
|
+
this.sm = {n: n, role: role, errors: errors, mean: mean};
|
|
147
|
+
var used = role.some(function(a){ return a.indexOf(0) >= 0; });
|
|
148
|
+
if (!this.getAttribute("aria-label")) this.setAttribute("aria-label", (kind ? kind + ": " : "") + role.map(function(a, r){ return T.fold + " " + (r + 1) + ": " + T.test + " " + a.map(function(v, i){ return v === 2 ? i + 1 : null; }).filter(Boolean).join(", ") + (errors ? "; " + T.error + " " + fmt(errors[r]) : ""); }).join("; ") + (errors ? "; " + T.mean + " " + fmt(mean) : ""));
|
|
149
|
+
var W = Math.max(1, this.clientWidth), H = Math.max(1, this.clientHeight), fs = this.fs, line = Math.ceil(fs * 1.45 + 4);
|
|
150
|
+
var width = function(s){ return base.textWidth(s, fs, {font: self}); };
|
|
151
|
+
var hasCls = samples.some(function(s){ return s.class !== undefined; }), hasGrp = samples.some(function(s){ return s.group !== undefined; }), hasT = samples.some(function(s){ return s.t !== undefined; });
|
|
152
|
+
var errorWidth = errors ? Math.max(width(T.error), width(T.mean + " " + fmt(mean)), width("0.00")) + 8 : 0;
|
|
153
|
+
var stripLab = Math.max(hasCls ? width(T.cls) : 0, hasGrp ? width(T.group) : 0, width(String(sp.length))) + 16;
|
|
154
|
+
var left = Math.max(42, stripLab), ex = W - errorWidth - 8, right = errors ? ex - 20 : W - 8, cw = (right - left) / n;
|
|
155
|
+
var strips = (hasCls ? 1 : 0) + (hasGrp ? 1 : 0) + (hasT ? 1 : 0), top = line + 8 + strips * line;
|
|
156
|
+
var footer = errors ? line + 8 : 4, rh = Math.max(28, Math.min(Math.ceil(fs * 2.6), (H - top - footer) / sp.length)), bh = rh - 6;
|
|
157
|
+
if (cw < 6) ctx.report("size", "[folds] " + n + " samples have " + cw.toFixed(1) + " px each; allow at least 6 px per sample (a wider element or fewer samples)");
|
|
158
|
+
if (H < top + sp.length * 28 + footer) ctx.report("size", "[folds] " + sp.length + " splits need at least " + Math.ceil(top + sp.length * 28 + footer) + " px height; element has " + H + " px");
|
|
159
|
+
this.geometry = {cell: cw, row: rh, top: top};
|
|
160
|
+
var svg = this.svg = base.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true"}, this);
|
|
161
|
+
var head = this.header = base.el("g", {opacity: 0}, svg);
|
|
162
|
+
// 凡例:学習・検証(・使わない)・クラスの名前(右へ並べる)
|
|
163
|
+
var x = 8, item = function(fill, stroke, text, dash){ base.el("rect", {x: x, y: 8, width: 28, height: fs * 1.2, fill: fill, stroke: stroke || "none", "stroke-width": 3, "stroke-dasharray": dash ? "4 3" : null}, head); self.label(head, x + 36, fs + 4, text); x += 36 + width(text) + 24; };
|
|
164
|
+
item("var(--term-tint)", null, T.trainS); item("var(--emph-tint)", "var(--emph)", T.test);
|
|
165
|
+
if (used) item("var(--bg)", "var(--line)", T.unused, true);
|
|
166
|
+
(d.classes || []).forEach(function(c, i){ base.el("circle", {cx: x + 10, cy: 8 + fs * 0.6, r: 9, fill: PAL[i]}, head); self.label(head, x + 26, fs + 4, c.label || String(c.id)); x += 26 + width(c.label || String(c.id)) + 24; });
|
|
167
|
+
if (x > W) ctx.report("size", "[folds] the legend needs " + Math.ceil(x) + " px width; element has " + W + " px");
|
|
168
|
+
var sy = line + 8;
|
|
169
|
+
if (hasCls){
|
|
170
|
+
self.label(head, left - 12, sy + fs * 0.85, T.cls, "end");
|
|
171
|
+
samples.forEach(function(s, i){ if (s.class !== undefined) base.el("rect", {x: left + i * cw + 1, y: sy + 4, width: Math.max(1, cw - 2), height: line - 12, fill: PAL[cls[s.class] || 0]}, head); });
|
|
172
|
+
sy += line;
|
|
173
|
+
}
|
|
174
|
+
if (hasGrp){
|
|
175
|
+
self.label(head, left - 12, sy + fs * 0.85, T.group, "end");
|
|
176
|
+
// 同じグループの続き:枠で囲み、入れば名前
|
|
177
|
+
var i0 = 0;
|
|
178
|
+
for (var i = 1; i <= n; i++) if (i === n || samples[i].group !== samples[i0].group){
|
|
179
|
+
base.el("rect", {x: left + i0 * cw + 1, y: sy + 4, width: Math.max(1, (i - i0) * cw - 2), height: line - 12, fill: "none", stroke: "var(--muted)", "stroke-width": 2, rx: 4}, head);
|
|
180
|
+
var gname = samples[i0].group === undefined ? "" : String(samples[i0].group);
|
|
181
|
+
if (gname && width(gname) <= (i - i0) * cw - 8) self.label(head, left + (i0 + (i - i0) / 2) * cw, sy + fs * 0.85, gname, "middle");
|
|
182
|
+
i0 = i;
|
|
183
|
+
}
|
|
184
|
+
sy += line;
|
|
185
|
+
}
|
|
186
|
+
if (hasT){
|
|
187
|
+
self.label(head, left, sy + fs * 0.85, String(samples[0].t !== undefined ? samples[0].t : ""));
|
|
188
|
+
var tEnd = String(samples[n - 1].t !== undefined ? samples[n - 1].t : "");
|
|
189
|
+
self.label(head, right, sy + fs * 0.85, tEnd, "end");
|
|
190
|
+
var mid = left + (right - left) / 2, tw0 = width(T.time);
|
|
191
|
+
if (width(String(samples[0].t)) + width(tEnd) + tw0 + 48 <= right - left) self.label(head, mid, sy + fs * 0.85, T.time, "middle");
|
|
192
|
+
}
|
|
193
|
+
if (errors) this.label(head, ex, top - 8, T.error);
|
|
194
|
+
this.rows = role.map(function(a, r){
|
|
195
|
+
var g = base.el("g", {opacity: 0}, svg), y = top + r * rh;
|
|
196
|
+
self.label(g, left - 12, y + bh / 2 + fs * 0.31, String(r + 1), "end");
|
|
197
|
+
a.forEach(function(v, i){
|
|
198
|
+
base.el("rect", {x: left + i * cw + 1, y: y, width: Math.max(1, cw - 2), height: bh, rx: Math.min(3, cw / 4), fill: v === 2 ? "var(--emph-tint)" : v === 1 ? "var(--term-tint)" : "var(--bg)", stroke: v === 2 ? "var(--emph)" : v === 0 ? "var(--line)" : "none", "stroke-width": v === 2 ? 2.5 : 1.5, "stroke-dasharray": v === 0 ? "4 3" : null}, g);
|
|
199
|
+
});
|
|
200
|
+
if (errors) self.label(g, ex, y + bh / 2 + fs * 0.31, fmt(errors[r]));
|
|
201
|
+
return {g: g};
|
|
202
|
+
});
|
|
203
|
+
this.finalLayer = base.el("g", {opacity: 0}, svg);
|
|
204
|
+
if (errors){ var bottom = top + sp.length * rh; base.el("line", {x1: ex, x2: W - 8, y1: bottom + 2, y2: bottom + 2, stroke: "var(--muted)", "stroke-width": 2}, this.finalLayer); this.label(this.finalLayer, ex, bottom + line - 4, T.mean + " " + fmt(mean)); }
|
|
205
|
+
}
|
|
206
|
+
renderSamples(k, t){
|
|
207
|
+
var dur = this.props.dur, n = this.sm.role.length, phase = function(step){ return k > step ? 1 : k < step ? 0 : base.prog(t, 0, dur); };
|
|
208
|
+
set(this.header, "opacity", phase(1));
|
|
209
|
+
this.rows.forEach(function(o, i){ set(o.g, "opacity", phase(i + 1)); });
|
|
210
|
+
set(this.finalLayer, "opacity", phase(n + 1));
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: Flow chart: boxes and arrows by step
|
|
3
|
+
steps: largest node/edge step
|
|
4
|
+
props:
|
|
5
|
+
fade: box fade-in (s)
|
|
6
|
+
draw: arrow draw (s)
|
|
7
|
+
size: box text px
|
|
8
|
+
pulse-dur: pulse run (s)
|
|
9
|
+
pulse-n: pulse dots
|
|
10
|
+
label-gap: min label–box gap px
|
|
11
|
+
example: {"nodes": [{"id": "a", "label": "Observe", "x": 20, "y": 40, "w": 200, "h": 70, "step": 1}, {"id": "b", "label": "Update", "x": 320, "y": 40, "w": 200, "h": 70, "step": 2}], "edges": [{"from": "a", "to": "b", "step": 2}]}
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
Child JSON: `{"nodes": [...], "edges": [...]}`; px; `x`, `y` = box top-left, `w`, `h` = size.
|
|
15
|
+
|
|
16
|
+
- node: `id`, `label` (`\n`) or `tex` (KaTeX), `step`, `tone` (`term`/`emph`/`muted`), `at` (start s), `shape:"diamond"` (decision; ~2× text width)
|
|
17
|
+
- edge: `from` `to` `step` (default: later end), `label`, `tone`, `dash`, `offset` (label gap), `at`, `loop` (back edge: `"left"` `"right"` `"top"` `"bottom"` or `true` = auto)
|
|
18
|
+
|
|
19
|
+
<!-- llm: omit -->
|
|
20
|
+
- Edge ends (2.0.4): boxes apart along one axis: the edge ends mid facing side of the target, starts on the source's facing side near the target's centre line; `shift` runs along those sides (reported if it leaves them). Before, centre-to-centre lines could end between stacked wide boxes
|
|
21
|
+
- Lines, labels `--fg` (or `tone`); arrows draw after their step's boxes
|
|
22
|
+
- `kind` colours: `money` `--emph`, `service` `--term`, `data` `--muted`
|
|
23
|
+
- `muted` box: `--muted` frame, `--bg` fill, `--fg` text. Before v1.2.0 labels and `muted` text were `--muted`
|
|
24
|
+
- `loop` `true`: right if ends stacked, bottom if side by side; runs 34 px outside boxes between the ends (rounded elbow); `label` outside, `amount` inside; leave room on that side
|
|
25
|
+
- `shape: "diamond"`: rhombus in `x` `y` `w` `h`; about 2× text width; yes/no as outgoing `label`s
|
|
26
|
+
- Business: `amount` opposite `label`; `shift` text on its side; pulse dots 0.22 s apart, `pulseAt` default 0.2, gone at the end
|
|
27
|
+
- Label/`amount` nearer than `label-gap` to a box or off the figure: moved off the line 6 px at a time (to 60), then other side
|
|
28
|
+
- `cues(k)`: pulse start times (null without pulses), for `{cue}`
|
|
29
|
+
<!-- llm: end -->
|
|
30
|
+
|
|
31
|
+
<!-- llm: business -->
|
|
32
|
+
Business-model edges:
|
|
33
|
+
|
|
34
|
+
- `kind`: `money` (thick), `service`, `data` (dashed); `tone`/`dash` win
|
|
35
|
+
- `amount`: bold figure
|
|
36
|
+
- `shift`: px right of travel; both directions = 2 parallel lines
|
|
37
|
+
- `pulse`: `pulse-n` dots run start→end in `pulse-dur` s; `true` = once after drawing; `[step, …]` = once per step; pulse steps count
|
|
38
|
+
<!-- llm: end -->
|
|
39
|
+
|
|
40
|
+
The demo is `demo.html`.
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// m-flow:流れ図の箱と矢印を段階ごとに出して、図を組み立てる
|
|
2
|
+
// <m-flow style="height:400px"><script type="application/json">
|
|
3
|
+
// {"nodes":[{"id":"a","label":"観測 *w*","x":20,"y":40,"w":200,"h":70,"step":1}, …],
|
|
4
|
+
// "edges":[{"from":"a","to":"b","step":2,"label":"更新"}]}
|
|
5
|
+
// (JSON の終わり)</m-flow>
|
|
6
|
+
// 座標は要素の箱の px(x, y は箱の左上)。箱は段階 step で現れ、矢印は同じ段階の箱の後に引く
|
|
7
|
+
// 箱の字は label(*斜体*、_下付き、^上付き、\n で改行)か tex(KaTeX)。tone は term / emph / muted
|
|
8
|
+
// お金・モノの流れ(ビジネスモデルの図):edge の kind(money / service / data)で色と線種を決め、amount(金額など)を太字で添える。
|
|
9
|
+
// 同じ 2 つの箱の行きと帰りは shift(線に垂直にずらす px)で分ける。pulse の辺は、点の列が始点から終点へ流れる
|
|
10
|
+
// (pulse: true なら辺の段階に 1 回、[段階, …] ならその段階ごとに 1 回。位置は (k, t) だけで決まり、流れ終わると消える)
|
|
11
|
+
// 流れ図の判断:node の shape: "diamond"(箱の x, y, w, h に内接するひし形)。はい/いいえは出ていく辺の label
|
|
12
|
+
// 戻る辺:edge の loop(true / "left" / "right" / "top" / "bottom")。箱の横から出て、間の箱の外側を回って戻り先の箱の横に入る
|
|
13
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・previewOpacity を使い、プレイヤーのグローバルは使わない。
|
|
14
|
+
// 式(tex)は組み立てのときに KaTeX で描く(spec §6.2):build.fields の nodes[].tex を作り手が描いて texHtml を足し、
|
|
15
|
+
// この部品は markup-reader で決まった要素と属性だけを読んで置く(再生のときに KaTeX は動かない)。描いた結果がなければ tex を字のまま出して知らせる。
|
|
16
|
+
// 知らないデータ(loop の値、ない箱を指す辺)は ctx.report で知らせる(1.x の console.warn / console.error の代わり)
|
|
17
|
+
egatariParts.define({name: "flow", version: "2.1.1", requires: {base: "1.3.0", "markup-reader": "1.0.3"}, element: "m-flow"}, function(deps){
|
|
18
|
+
"use strict";
|
|
19
|
+
var base = deps.base, MR = deps["markup-reader"];
|
|
20
|
+
// 複数行の名前の行の位置(1 行目からの下がり、px)と、上下に足す余白。base 1.1.0 で mtext の下付き・上付きは 24px 以上になり、
|
|
21
|
+
// 行の間 lh(字の 1.25 倍)では上の行の下付きと下の行の上付きが重なる。下付きの字の下端は基線から添字の 0.75 倍まで、上付きの字の
|
|
22
|
+
// 上端は添字の 1.4 倍まで(Source Sans 3 で測った値。BIZ UDPGothic ではそれぞれ 0.5 倍と 1.2 倍)。上の行に下付き(_)があれば
|
|
23
|
+
// その下端から字の下の余白(字の 0.12 倍)を引いた分、下の行に上付き(^)があればその上端から字の上の高さ(0.88 倍)を引いた分だけ
|
|
24
|
+
// 行の間を広げる。top・bottom は 1 行目の上付き・最後の行の下付きの分(添字がなければどれも 0 で、行は lh ずつ)
|
|
25
|
+
function subX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /_./.test(s) ? Math.max(0, 0.75 * ss - 0.12 * fs) : 0; }
|
|
26
|
+
function supX(s, fs){ var ss = Math.max(24, Math.round(fs * 0.75)); return /\^./.test(s) ? Math.max(0, 1.4 * ss - 0.88 * fs) : 0; }
|
|
27
|
+
function lineYs(lines, lh, fs){
|
|
28
|
+
var y = [0];
|
|
29
|
+
for (var j = 1; j < lines.length; j++) y.push(y[j - 1] + lh + subX(lines[j - 1], fs) + supX(lines[j], fs));
|
|
30
|
+
y.top = supX(lines[0], fs); y.bottom = subX(lines[lines.length - 1], fs);
|
|
31
|
+
return y;
|
|
32
|
+
}
|
|
33
|
+
return class extends base.MotionElement {
|
|
34
|
+
static partName = "flow"; // the registry name (define meta name), for report prefixes
|
|
35
|
+
// 組み立てのときに描く欄(spec §6.2)。式の意味は字(tex)でも持つので、KaTeX の出力は HTML だけ
|
|
36
|
+
static build = {fields: {"nodes[].tex": "katex"}, options: {katex: {output: "html"}}};
|
|
37
|
+
// データの形(kit/shape.js)。座標は要素の箱の px(x, y は箱の左上)
|
|
38
|
+
static shape = {
|
|
39
|
+
schema: {type: "object", additionalProperties: false, required: ["nodes"], properties: {
|
|
40
|
+
nodes: {type: "array", minItems: 1, items: {type: "object", required: ["id", "x", "y", "w", "h"], properties: {
|
|
41
|
+
id: {type: ["string", "integer"]}, label: {type: "string"}, tex: {type: "string"}, texHtml: {type: "string"}, x: {type: "number"}, y: {type: "number"}, w: {type: "number"}, h: {type: "number"},
|
|
42
|
+
step: {type: "integer"}, tone: {type: "string"}, at: {type: "number"}, shape: {type: "string"}}}},
|
|
43
|
+
edges: {type: "array", items: {type: "object", required: ["from", "to"], properties: {
|
|
44
|
+
from: {type: ["string", "integer"]}, to: {type: ["string", "integer"]}, step: {type: "integer"}, label: {type: "string"}, tone: {type: "string"}, dash: {type: "boolean"},
|
|
45
|
+
kind: {enum: ["money", "service", "data"]}, amount: {type: ["string", "number"]}, shift: {type: "number"}, pulse: {type: ["boolean", "array"]}, pulseAt: {type: "number"}, offset: {type: "number"}, at: {type: "number"},
|
|
46
|
+
loop: {type: ["boolean", "string"]}}}},
|
|
47
|
+
renderers: {type: "object"}}},
|
|
48
|
+
example: {nodes: [{id: "a", label: "観測", x: 20, y: 40, w: 200, h: 70, step: 1}, {id: "b", label: "更新", x: 320, y: 40, w: 200, h: 70, step: 2}], edges: [{from: "a", to: "b", step: 2}]},
|
|
49
|
+
};
|
|
50
|
+
static props = {
|
|
51
|
+
fade: {type: "number", default: 0.45, doc: "箱が現れる秒数"},
|
|
52
|
+
draw: {type: "number", default: 0.6, doc: "矢印を引く秒数"},
|
|
53
|
+
size: {type: "number", default: 26, doc: "箱の字の大きさ(px)"},
|
|
54
|
+
"pulse-dur": {type: "number", default: 1.2, doc: "pulse の点が始点から終点まで流れる秒数"},
|
|
55
|
+
"pulse-n": {type: "number", default: 3, doc: "pulse で流れる点の数"},
|
|
56
|
+
"label-gap": {type: "number", default: 12, doc: "辺の名前・金額と箱との最小の間(px)。近ければ線から離す"},
|
|
57
|
+
};
|
|
58
|
+
get steps(){
|
|
59
|
+
if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
|
|
60
|
+
var d = this.data || {}, m = 0;
|
|
61
|
+
(d.nodes || []).concat(d.edges || []).forEach(function(x){ m = Math.max(m, x.step || 1); });
|
|
62
|
+
// pulse の段階([段階, …])も数える
|
|
63
|
+
(d.edges || []).forEach(function(x){ if (Array.isArray(x.pulse)) x.pulse.forEach(function(k){ m = Math.max(m, k); }); });
|
|
64
|
+
return m;
|
|
65
|
+
}
|
|
66
|
+
mount(ctx){
|
|
67
|
+
var P = this.props, D = base, self = this, data = this.data || {nodes: [], edges: []}, sk = MR.sink(this, ctx);
|
|
68
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
69
|
+
var W = this.clientWidth, H = this.clientHeight;
|
|
70
|
+
var svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, style: "display:block;overflow:visible"}, this);
|
|
71
|
+
var gE = D.el("g", {}, svg), gN = D.el("g", {}, svg);
|
|
72
|
+
var tone = {term: ["var(--term)", "var(--term-tint)", "var(--fg)"], emph: ["var(--emph)", "var(--emph-tint)", "var(--emph)"],
|
|
73
|
+
muted: ["var(--muted)", "var(--bg)", "var(--fg)"]}; // muted:枠は --muted、字は --fg(字は情報。薄い字は投影で読めない)
|
|
74
|
+
var byId = {}, dup = [];
|
|
75
|
+
// 箱。段階の中の開始時刻 at(既定 0)
|
|
76
|
+
this.nodes = (data.nodes || []).map(function(n){
|
|
77
|
+
var c = tone[n.tone || "term"] || tone.term, cx = n.x + n.w / 2, cy = n.y + n.h / 2;
|
|
78
|
+
var g = D.el("g", {opacity: 0}, gN);
|
|
79
|
+
// data-part:Studio の形の検査(geometry check)が測る印。形の要素に box、字に label(data-part-of で持ち主が箱か辺か)
|
|
80
|
+
var nid = String(n.id), pb = {"data-part": "box", "data-part-id": nid}, pl = {"data-part": "label", "data-part-id": nid, "data-part-of": "box"};
|
|
81
|
+
if (n.shape === "diamond") D.el("polygon", Object.assign({class: "box", points: [cx, n.y, n.x + n.w, cy, cx, n.y + n.h, n.x, cy].join(" "), "stroke-linejoin": "round", fill: c[1], stroke: c[0], "stroke-width": n.tone === "emph" ? 3 : 2.2}, pb), g);
|
|
82
|
+
else D.el("rect", Object.assign({class: "box", x: n.x, y: n.y, width: n.w, height: n.h, rx: 10, fill: c[1], stroke: c[0], "stroke-width": n.tone === "emph" ? 3 : 2.2}, pb), g);
|
|
83
|
+
// 式の div は行の中の inline-block なので、上端にそろえないと親の行の高さの分だけ下へずれる
|
|
84
|
+
if (n.tex){ var tf = MR.texFrame(g, cx, cy + P.size * 0.36, n, "tex", {size: P.size, anchor: "middle", color: c[2], w: n.w, h: n.h}, sk);
|
|
85
|
+
tf.firstChild.style.verticalAlign = "top"; for (var k in pl) tf.setAttribute(k, pl[k]); }
|
|
86
|
+
else {
|
|
87
|
+
var lines = String(n.label || "").split("\n"), ys = lineYs(lines, P.size * 1.25, P.size), y0 = cy - ys[ys.length - 1] / 2 + P.size * 0.36;
|
|
88
|
+
lines.forEach(function(s, j){ D.mtext(g, cx, y0 + ys[j], s, Object.assign({"text-anchor": "middle", "font-size": P.size, fill: c[2]}, pl)); });
|
|
89
|
+
}
|
|
90
|
+
var o = {g: g, cx: cx, cy: cy, n: n, step: n.step || 1, at: n.at || 0};
|
|
91
|
+
if (byId[n.id]) dup.push(JSON.stringify(n.id));
|
|
92
|
+
byId[n.id] = o;
|
|
93
|
+
return o;
|
|
94
|
+
});
|
|
95
|
+
// 同じ id の箱が 2 つ以上あれば、辺は後に書いた箱を指す(知らせる)
|
|
96
|
+
if (dup.length) ctx.report("data", "[flow] node ids are not unique: " + dup.join(", ") + " (edges use the last node with that id)");
|
|
97
|
+
// 矢印:箱の中心どうしを結ぶ線を、箱の縁で切る
|
|
98
|
+
function edgePt(n, dx, dy, gap){
|
|
99
|
+
var hw = n.w / 2 + gap, hh = n.h / 2 + gap;
|
|
100
|
+
// ひし形は |dx| / hw + |dy| / hh = 1 の上で切る
|
|
101
|
+
var s = n.shape === "diamond" ? 1 / (Math.abs(dx) / hw + Math.abs(dy) / hh) : Math.min(dx ? hw / Math.abs(dx) : Infinity, dy ? hh / Math.abs(dy) : Infinity);
|
|
102
|
+
return [n.x + n.w / 2 + dx * s, n.y + n.h / 2 + dy * s];
|
|
103
|
+
}
|
|
104
|
+
// 戻る辺の道:箱の side の側の辺の中点から出て、両端の間にある箱(と両端)の外側 28 px を回り、戻り先の同じ側に入る
|
|
105
|
+
function loopRoute(lp, A, B){
|
|
106
|
+
var sd = lp === true ? (Math.abs(B.y + B.h / 2 - A.y - A.h / 2) >= Math.abs(B.x + B.w / 2 - A.x - A.w / 2) ? "right" : "bottom") : lp;
|
|
107
|
+
if (!/^(left|right|top|bottom)$/.test(sd)){ ctx.report("data", "[flow] loop=" + JSON.stringify(lp) + " is not true, left, right, top or bottom (right is used)"); sd = "right"; }
|
|
108
|
+
var hz = sd === "left" || sd === "right", sg = sd === "right" || sd === "bottom" ? 1 : -1;
|
|
109
|
+
var out = function(n){ return hz ? [sg > 0 ? n.x + n.w + 6 : n.x - 6, n.y + n.h / 2] : [n.x + n.w / 2, sg > 0 ? n.y + n.h + 6 : n.y - 6]; };
|
|
110
|
+
var q0 = out(A), q1 = out(B), j = hz ? 1 : 0;
|
|
111
|
+
// 箱から同じ箱へ戻る辺:その側の辺の 1/4 と 3/4 の所から出入りする(小さな輪)
|
|
112
|
+
if (A === B){ var u = (hz ? A.h : A.w) / 4; q0[j] -= u; q1[j] += u; }
|
|
113
|
+
var lo = Math.min(q0[j], q1[j]), hi = Math.max(q0[j], q1[j]);
|
|
114
|
+
var ch = sg > 0 ? Math.max(q0[1 - j], q1[1 - j]) : Math.min(q0[1 - j], q1[1 - j]);
|
|
115
|
+
self.nodes.forEach(function(o){
|
|
116
|
+
var n = o.n, a0 = hz ? n.y : n.x, a1 = hz ? n.y + n.h : n.x + n.w;
|
|
117
|
+
if (a1 < lo - 12 || a0 > hi + 12) return;
|
|
118
|
+
var f = hz ? (sg > 0 ? n.x + n.w : n.x) : (sg > 0 ? n.y + n.h : n.y);
|
|
119
|
+
ch = sg > 0 ? Math.max(ch, f + 6) : Math.min(ch, f - 6);
|
|
120
|
+
});
|
|
121
|
+
ch += sg * 28;
|
|
122
|
+
var pts = hz ? [q0, [ch, q0[1]], [ch, q1[1]], q1] : [q0, [q0[0], ch], [q1[0], ch], q1];
|
|
123
|
+
return {pts: pts, poly: self.poly(pts), hz: hz, sg: sg, ch: ch};
|
|
124
|
+
}
|
|
125
|
+
// 線の形を先に全部決める(辺の字は、ほかの辺の線と先に置いた字を避けて置くので)
|
|
126
|
+
var es = data.edges || [];
|
|
127
|
+
// 同じ 2 つの箱の行きと帰りで、どちらも shift も loop も書いていなければ、それぞれ 10 px ずらす(2 本の間は 20 px)
|
|
128
|
+
var autoShift = function(e){
|
|
129
|
+
return !e.shift && !e.loop && es.some(function(f){ return f !== e && f.from === e.to && f.to === e.from && !f.shift && !f.loop; });
|
|
130
|
+
};
|
|
131
|
+
var geo = es.map(function(e){
|
|
132
|
+
var a = byId[e.from], b = byId[e.to];
|
|
133
|
+
if (!a || !b) return null;
|
|
134
|
+
var dx = b.cx - a.cx, dy = b.cy - a.cy, L = Math.hypot(dx, dy) || 1;
|
|
135
|
+
// 同じ箱へ戻る辺(loop なし)は、右に回る輪にする。中心の重なる 2 つの箱の辺は引けない
|
|
136
|
+
var lp = e.loop;
|
|
137
|
+
if (!lp && a === b){ ctx.report("data", "[flow] the edge " + JSON.stringify(e.from) + " → " + JSON.stringify(e.to) + " goes from a node to itself; it is drawn as a loop on the right (set loop to choose the side)"); lp = "right"; }
|
|
138
|
+
if (!lp && !dx && !dy){ ctx.report("data", "[flow] the edge " + JSON.stringify(e.from) + " → " + JSON.stringify(e.to) + " joins two nodes with the same centre (not drawn)"); return false; }
|
|
139
|
+
var p0 = lp ? null : edgePt(a.n, dx / L, dy / L, 6), p1 = lp ? null : edgePt(b.n, -dx / L, -dy / L, 6), route = null;
|
|
140
|
+
// Boxes apart along one axis: the edge ends at the middle of the target's facing side and starts on the source's facing
|
|
141
|
+
// side, as near the target's centre line as that side allows (a centre-to-centre line would enter a wide, flat target
|
|
142
|
+
// through its top or bottom, between stacked boxes)
|
|
143
|
+
var face = 0, sh = e.shift || (autoShift(e) ? 10 : 0); // face 1: left/right sides face each other, 2: top/bottom
|
|
144
|
+
if (!lp){
|
|
145
|
+
var A = a.n, B = b.n, gx = Math.max(B.x - A.x - A.w, A.x - B.x - B.w), gy = Math.max(B.y - A.y - A.h, A.y - B.y - B.h);
|
|
146
|
+
if (gx > 0 || gy > 0){
|
|
147
|
+
// shift runs along the facing sides (to the right of travel); the start follows the shifted end's line
|
|
148
|
+
var hz = gx >= gy, sg = hz ? Math.sign(dx) : Math.sign(dy), m = function(n){ return Math.min((hz ? n.h : n.w) / 4, 12); };
|
|
149
|
+
p1 = hz ? [b.cx - sg * (B.w / 2 + 6), b.cy + sg * sh] : [b.cx - sg * sh, b.cy - sg * (B.h / 2 + 6)];
|
|
150
|
+
if (A.shape === "diamond"){ var ux = p1[0] - a.cx, uy = p1[1] - a.cy, ul = Math.hypot(ux, uy) || 1; p0 = edgePt(A, ux / ul, uy / ul, 6); }
|
|
151
|
+
else p0 = hz ? [a.cx + sg * (A.w / 2 + 6), Math.max(A.y + m(A), Math.min(A.y + A.h - m(A), p1[1]))]
|
|
152
|
+
: [Math.max(A.x + m(A), Math.min(A.x + A.w - m(A), p1[0])), a.cy + sg * (A.h / 2 + 6)];
|
|
153
|
+
dx = p1[0] - p0[0]; dy = p1[1] - p0[1]; L = Math.hypot(dx, dy) || 1; face = hz ? 1 : 2;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (lp) route = loopRoute(lp, a.n, b.n);
|
|
157
|
+
if (route){ p0 = route.pts[0]; p1 = route.pts[3]; }
|
|
158
|
+
// shift:線に垂直に(進む向きの右へ)ずらす。行きと帰りの 2 本を並べるときに使う(向かい合う辺の間はもうずらしてある)
|
|
159
|
+
if (sh && !face){ var sx = -dy / L * sh, sy = dx / L * sh; p0 = [p0[0] + sx, p0[1] + sy]; p1 = [p1[0] + sx, p1[1] + sy]; }
|
|
160
|
+
// self-check: an end that leaves its box's side (a shift larger than the side) is reported, not silently drawn
|
|
161
|
+
var off = function(p, n){ return face === 1 ? p[1] < n.y || p[1] > n.y + n.h : face === 2 ? p[0] < n.x || p[0] > n.x + n.w : false; };
|
|
162
|
+
if (off(p1, b.n)) ctx.report("layout", "[flow] the edge " + JSON.stringify(e.from) + " → " + JSON.stringify(e.to) + " leaves the side of its box (shift " + sh + " is larger than the side allows); use a smaller shift or a taller box");
|
|
163
|
+
return {a: a, b: b, dx: dx, dy: dy, L: L, p0: p0, p1: p1, route: route, shift: sh};
|
|
164
|
+
});
|
|
165
|
+
// 線分(戻る辺は折れ線の 3 本)と、置いた字の箱 [x0, y0, x1, y1]
|
|
166
|
+
var segs = geo.map(function(q){ return !q ? [] : q.route ? [0, 1, 2].map(function(i){ return [q.route.pts[i], q.route.pts[i + 1]]; }) : [[q.p0, q.p1]]; });
|
|
167
|
+
var boxes = [], eids = {};
|
|
168
|
+
this.edges = es.map(function(e, ei){
|
|
169
|
+
var q = geo[ei];
|
|
170
|
+
if (q === false) return null; // 知らせてある
|
|
171
|
+
if (!q){ ctx.report("data", "[flow] an edge refers to an unknown node: " + JSON.stringify(e.from) + " → " + JSON.stringify(e.to) + " (not drawn)"); return null; }
|
|
172
|
+
var a = q.a, b = q.b, dx = q.dx, dy = q.dy, L = q.L, p0 = q.p0, p1 = q.p1, route = q.route;
|
|
173
|
+
var others = [].concat.apply([], segs.filter(function(_, j){ return j !== ei; }));
|
|
174
|
+
// kind:money(--emph の太線)、service(--term)、data(--muted の破線)。tone と dash を書けばそちらが勝つ
|
|
175
|
+
var kind = {money: ["emph", false, 3.5], service: ["term", false, 2.5], data: ["muted", true, 2.5]}[e.kind] || [null, false, 2.5];
|
|
176
|
+
var tn = e.tone || kind[0], dash = e.dash !== undefined ? e.dash : kind[1];
|
|
177
|
+
var col = tn ? (tone[tn] || tone.term)[0] : "var(--fg)";
|
|
178
|
+
// 辺の id は "from→to"。同じ from→to の 2 本目からは "#2"、"#3" …を付ける
|
|
179
|
+
var eid = String(e.from) + "\u2192" + String(e.to);
|
|
180
|
+
eids[eid] = (eids[eid] || 0) + 1; if (eids[eid] > 1) eid += "#" + eids[eid];
|
|
181
|
+
var pe = {"data-part": "edge", "data-part-id": eid, "data-part-from": String(e.from), "data-part-to": String(e.to)};
|
|
182
|
+
var g = D.el("g", Object.assign({opacity: 0}, pe), gE);
|
|
183
|
+
var line = route ? D.el("path", {d: "", fill: "none", "stroke-linejoin": "round", stroke: col, "stroke-width": kind[2], "stroke-dasharray": dash ? "8 6" : "none", "data-part-line": ""}, g)
|
|
184
|
+
: D.el("line", {x1: p0[0], y1: p0[1], x2: p0[0], y2: p0[1], stroke: col, "stroke-width": kind[2], "stroke-dasharray": dash ? "8 6" : "none", "data-part-line": ""}, g);
|
|
185
|
+
var head = D.el("path", {d: "M0,0L-16,-7L-16,7Z", fill: col}, g);
|
|
186
|
+
var lab = null, amt = null;
|
|
187
|
+
// 線の中点から、線に垂直な向き(上か右)へずらして置く。amount は反対の側(label がなければ同じ側)に太字で
|
|
188
|
+
var nx = -dy / L, ny = dx / L;
|
|
189
|
+
if (ny > 0 || (ny === 0 && nx < 0)){ nx = -nx; ny = -ny; }
|
|
190
|
+
// 字の箱が箱(node)に label-gap px より近いか、図の外に出るか、ほかの辺の線(4 px の間をとる)か先に置いた字に
|
|
191
|
+
// かかるか、自分の線とのあいだにほかの辺の線が入るなら、線から離していく(6 px ずつ、60 px まで)。
|
|
192
|
+
// それでも置けなければ線の反対の側で同じように試す(label は amount があるときは自分の側だけ。amount は両側)。
|
|
193
|
+
// どこにも置けなければ最初の位置に置いて知らせる(layout)。
|
|
194
|
+
// 幅は字から見積もる(base の textWidth:テーマの字で測った幅)ので、字の読み込みによらず同じ位置になる
|
|
195
|
+
var mid = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
|
|
196
|
+
var side = function(sg, text, attrs, both){
|
|
197
|
+
var fs = attrs["font-size"] || 24, base = e.offset !== undefined ? e.offset : 18, pos = null, anc0 = null, box0 = null, free = false;
|
|
198
|
+
var w = D.textWidth(text, fs, {font: self, mark: true});
|
|
199
|
+
var sides = both ? [sg, -sg] : [sg];
|
|
200
|
+
search: for (var si = 0; si < sides.length; si++){
|
|
201
|
+
var sgn = sides[si], anc = Math.abs(nx) < 0.3 ? "middle" : nx * sgn > 0 ? "start" : "end";
|
|
202
|
+
for (var extra = 0; extra <= 60; extra += 6){
|
|
203
|
+
var off = (base + extra) * sgn, mx = (p0[0] + p1[0]) / 2 + nx * off, my = (p0[1] + p1[1]) / 2 + ny * off;
|
|
204
|
+
var y = my + (ny * sgn < -0.3 ? 0 : ny * sgn > 0.3 ? 20 : 8);
|
|
205
|
+
var x0 = anc === "start" ? mx : anc === "end" ? mx - w : mx - w / 2, gp = P["label-gap"];
|
|
206
|
+
var bx = [x0, y - fs * 0.88, x0 + w, y + fs * 0.22], c = [(bx[0] + bx[2]) / 2, (bx[1] + bx[3]) / 2];
|
|
207
|
+
var hit = x0 < 0 || x0 + w > W || y - fs * 0.88 < 0 || y + fs * 0.22 > H || self.nodes.some(function(o){ var n = o.n;
|
|
208
|
+
return x0 < n.x + n.w + gp && x0 + w > n.x - gp && y - fs * 0.88 < n.y + n.h + gp && y + fs * 0.22 > n.y - gp; }) ||
|
|
209
|
+
boxes.some(function(r){ return bx[0] < r[2] + 4 && bx[2] > r[0] - 4 && bx[1] < r[3] + 4 && bx[3] > r[1] - 4; }) ||
|
|
210
|
+
others.some(function(sgm){ return segHitsBox(sgm, [bx[0] - 4, bx[1] - 4, bx[2] + 4, bx[3] + 4]) || segsCross(sgm, [mid, c]); });
|
|
211
|
+
if (!pos){ pos = [mx, y]; anc0 = anc; box0 = bx; }
|
|
212
|
+
if (!hit){ pos = [mx, y]; anc0 = anc; box0 = bx; free = true; break search; }
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (!free) ctx.report("layout", "[flow] no free place for the edge text " + JSON.stringify(text) + " (" + JSON.stringify(e.from) + " → " + JSON.stringify(e.to) + "): it touches a box, a line or another text; move the boxes apart or set offset");
|
|
216
|
+
boxes.push(box0);
|
|
217
|
+
return D.mtext(g, pos[0], pos[1], text, Object.assign({"text-anchor": anc0, "font-size": 24, opacity: 0}, attrs, {"data-part": "label", "data-part-id": eid, "data-part-of": "edge"}));
|
|
218
|
+
};
|
|
219
|
+
// shift でずらした辺は、ずらした側に書く(行きと帰りの字が同じ側に重ならない)
|
|
220
|
+
var sg = q.shift && (-dy * nx + dx * ny) * q.shift < 0 ? -1 : 1;
|
|
221
|
+
var hasAmt = e.amount !== undefined && e.amount !== "";
|
|
222
|
+
// 戻る辺の名前は回り道の長い線の外側に、金額は内側に。外側が図の外に出るなら名前も内側に
|
|
223
|
+
var rside = function(out, text, attrs){
|
|
224
|
+
var r = route, m = r.hz ? (r.pts[1][1] + r.pts[2][1]) / 2 : (r.pts[1][0] + r.pts[2][0]) / 2, o2 = out ? r.sg : -r.sg;
|
|
225
|
+
var tw = D.textWidth(text, 26, {font: self, mark: true});
|
|
226
|
+
if (out && (r.hz ? (o2 > 0 ? r.ch + 10 + tw > W : r.ch - 10 - tw < 0) : (o2 > 0 ? r.ch + 30 > H : r.ch - 34 < 0))) o2 = -o2;
|
|
227
|
+
var at2 = r.hz ? {x: r.ch + o2 * 10, y: m + 8, a: o2 > 0 ? "start" : "end"} : {x: m, y: r.ch + (o2 > 0 ? 30 : -10), a: "middle"};
|
|
228
|
+
var bx0 = at2.a === "start" ? at2.x : at2.a === "end" ? at2.x - tw : at2.x - tw / 2;
|
|
229
|
+
boxes.push([bx0, at2.y - 26 * 0.88, bx0 + tw, at2.y + 26 * 0.22]);
|
|
230
|
+
return D.mtext(g, +at2.x.toFixed(2), +at2.y.toFixed(2), text, Object.assign({"text-anchor": at2.a, "font-size": 24, opacity: 0}, attrs, {"data-part": "label", "data-part-id": eid, "data-part-of": "edge"}));
|
|
231
|
+
};
|
|
232
|
+
if (route){
|
|
233
|
+
if (e.label) lab = rside(true, e.label, {fill: tn ? col : "var(--fg)"});
|
|
234
|
+
if (hasAmt) amt = rside(!e.label, String(e.amount), {fill: col, "font-weight": 700, "font-size": 26});
|
|
235
|
+
} else {
|
|
236
|
+
if (e.label) lab = side(sg, e.label, {fill: tn ? col : "var(--fg)"}, !hasAmt);
|
|
237
|
+
if (hasAmt) amt = side(e.label ? -sg : sg, String(e.amount), {fill: col, "font-weight": 700, "font-size": 26}, true);
|
|
238
|
+
}
|
|
239
|
+
var step = e.step || Math.max(a.step, b.step);
|
|
240
|
+
// 同じ段階で出る箱があれば、その箱が出てから引く
|
|
241
|
+
var after = Math.max(a.step === step ? a.at + P.fade * 0.6 : 0, b.step === step ? b.at + P.fade * 0.6 : 0);
|
|
242
|
+
var at = e.at !== undefined ? e.at : after;
|
|
243
|
+
// pulse の段階と開始時刻:辺の段階なら引き終わってから、ほかの段階なら pulseAt(既定 0.2 秒)から
|
|
244
|
+
var pk = e.pulse === true ? [step] : Array.isArray(e.pulse) ? e.pulse : [];
|
|
245
|
+
var pulses = pk.map(function(k){ return {k: k, at: e.pulseAt !== undefined ? e.pulseAt : k === step ? +(at + P.draw).toFixed(3) : 0.2}; });
|
|
246
|
+
var dots = pulses.length ? Array.from({length: Math.max(1, P["pulse-n"])}, function(){ return D.el("circle", {r: kind[2] + 3.5, fill: col, stroke: "var(--bg)", "stroke-width": 2, opacity: 0}, gE); }) : [];
|
|
247
|
+
var o = {g: g, line: line, head: head, lab: lab, amt: amt, p0: p0, p1: p1, ang: Math.atan2(dy, dx) * 180 / Math.PI, step: step, at: at, pulses: pulses, dots: dots};
|
|
248
|
+
if (route) o.poly = route.poly;
|
|
249
|
+
return o;
|
|
250
|
+
}).filter(Boolean);
|
|
251
|
+
sk.flush(); // what the formulas have to report, once per kind (spec §6.2)
|
|
252
|
+
// 線分 s = [[x, y], [x, y]] が箱 r = [x0, y0, x1, y1] にかかるか(Liang–Barsky)
|
|
253
|
+
function segHitsBox(sg, r){
|
|
254
|
+
var x = sg[0][0], y = sg[0][1], ddx = sg[1][0] - x, ddy = sg[1][1] - y, t0 = 0, t1 = 1;
|
|
255
|
+
var pp = [-ddx, ddx, -ddy, ddy], qq = [x - r[0], r[2] - x, y - r[1], r[3] - y];
|
|
256
|
+
for (var i = 0; i < 4; i++){
|
|
257
|
+
if (pp[i] === 0){ if (qq[i] < 0) return false; continue; }
|
|
258
|
+
var u = qq[i] / pp[i];
|
|
259
|
+
if (pp[i] < 0){ if (u > t1) return false; if (u > t0) t0 = u; }
|
|
260
|
+
else { if (u < t0) return false; if (u < t1) t1 = u; }
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
// 2 つの線分が交わるか(端を除く)
|
|
265
|
+
function segsCross(s1, s2){
|
|
266
|
+
var o = function(a, b, c){ return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); };
|
|
267
|
+
var d1 = o(s2[0], s2[1], s1[0]), d2 = o(s2[0], s2[1], s1[1]), d3 = o(s1[0], s1[1], s2[0]), d4 = o(s1[0], s1[1], s2[1]);
|
|
268
|
+
return d1 * d2 < 0 && d3 * d4 < 0;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// 折れ線:点と累積の長さ(戻る辺)
|
|
272
|
+
poly(pts){
|
|
273
|
+
var L = [0];
|
|
274
|
+
for (var i = 1; i < pts.length; i++) L.push(L[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]));
|
|
275
|
+
return {pts: pts, L: L, len: L[L.length - 1] || 1};
|
|
276
|
+
}
|
|
277
|
+
// 折れ線の始めから長さ len の点と向き(度)。d:そこまでの線
|
|
278
|
+
polyAt(pl, len){
|
|
279
|
+
var pts = pl.pts, want = Math.max(0, Math.min(pl.len, len)), i = 1, d = "M" + pts[0][0].toFixed(2) + "," + pts[0][1].toFixed(2);
|
|
280
|
+
while (i < pts.length - 1 && pl.L[i] < want){ d += "L" + pts[i][0].toFixed(2) + "," + pts[i][1].toFixed(2); i++; }
|
|
281
|
+
var u = (want - pl.L[i - 1]) / ((pl.L[i] - pl.L[i - 1]) || 1), x = base.lerp(pts[i - 1][0], pts[i][0], u), y = base.lerp(pts[i - 1][1], pts[i][1], u);
|
|
282
|
+
return {x: x, y: y, ang: Math.atan2(pts[i][1] - pts[i - 1][1], pts[i][0] - pts[i - 1][0]) * 180 / Math.PI, d: d + "L" + x.toFixed(2) + "," + y.toFixed(2)};
|
|
283
|
+
}
|
|
284
|
+
// pulse の点の列が流れ終わるまでの長さ(点の間は 0.22 秒)
|
|
285
|
+
pulseLen(){ return this.props["pulse-dur"] + 0.22 * (Math.max(1, this.props["pulse-n"]) - 1); }
|
|
286
|
+
duration(k){
|
|
287
|
+
var P = this.props, d = 0, pl = this.pulseLen();
|
|
288
|
+
this.nodes.forEach(function(o){ if (o.step === k) d = Math.max(d, o.at + P.fade); });
|
|
289
|
+
this.edges.forEach(function(o){
|
|
290
|
+
if (o.step === k) d = Math.max(d, o.at + P.draw + (o.lab || o.amt ? 0.3 : 0));
|
|
291
|
+
o.pulses.forEach(function(q){ if (q.k === k) d = Math.max(d, q.at + pl); });
|
|
292
|
+
});
|
|
293
|
+
return d;
|
|
294
|
+
}
|
|
295
|
+
// pulse の開始時刻を口述原稿の {cue} に合わせられる(pulse のない図はこれまでどおり null)
|
|
296
|
+
cues(k){
|
|
297
|
+
var c = [];
|
|
298
|
+
this.edges.forEach(function(o){ o.pulses.forEach(function(q){ if (q.k === k && q.at > 0 && c.indexOf(q.at) < 0) c.push(q.at); }); });
|
|
299
|
+
return c.length ? c.sort(function(a, b){ return a - b; }) : null;
|
|
300
|
+
}
|
|
301
|
+
render(k, t, ctx){
|
|
302
|
+
var P = this.props, D = base, self = this, preview = !!ctx.preview, PV = 0;
|
|
303
|
+
// 先を薄く見せる表示:後の段階の箱と矢印(名前・金額も)を、最後の形のままテーマの --preview-opacity(なければ 0.45)で描く。
|
|
304
|
+
// pulse の点は今の段階のものだけ
|
|
305
|
+
if (preview) PV = base.previewOpacity(this);
|
|
306
|
+
var ahead = function(step){ return preview && step > k; };
|
|
307
|
+
var pr = function(step, at, dur){ return step < k || ahead(step) ? 1 : step > k ? 0 : D.prog(t, at, dur); };
|
|
308
|
+
this.nodes.forEach(function(o){
|
|
309
|
+
var e = pr(o.step, o.at, P.fade), s = D.lerp(0.92, 1, e);
|
|
310
|
+
o.g.setAttribute("opacity", ahead(o.step) ? PV.toFixed(3) : e.toFixed(3));
|
|
311
|
+
o.g.setAttribute("transform", "translate(" + o.cx + " " + o.cy + ") scale(" + s.toFixed(4) + ") translate(" + (-o.cx) + " " + (-o.cy) + ")");
|
|
312
|
+
});
|
|
313
|
+
this.edges.forEach(function(o){
|
|
314
|
+
var e = pr(o.step, o.at, P.draw);
|
|
315
|
+
if (o.poly){
|
|
316
|
+
// 戻る辺:折れ線を始めから引き、矢じりは先端について動く(線は矢じりの根元まで)
|
|
317
|
+
var want = e * o.poly.len, tip = self.polyAt(o.poly, want), hs2 = Math.min(1, want / 20);
|
|
318
|
+
o.line.setAttribute("d", want > 0 ? self.polyAt(o.poly, want - Math.min(14, want)).d : "");
|
|
319
|
+
o.head.setAttribute("transform", "translate(" + tip.x.toFixed(2) + " " + tip.y.toFixed(2) + ") rotate(" + tip.ang.toFixed(2) + ") scale(" + hs2.toFixed(4) + ")");
|
|
320
|
+
} else {
|
|
321
|
+
var tx = D.lerp(o.p0[0], o.p1[0], e), ty = D.lerp(o.p0[1], o.p1[1], e);
|
|
322
|
+
var L = Math.hypot(o.p1[0] - o.p0[0], o.p1[1] - o.p0[1]) || 1, back = Math.min(14, e * L);
|
|
323
|
+
// 線は矢じりの根元まで。矢じりは線の先端について動く
|
|
324
|
+
o.line.setAttribute("x2", (tx - (o.p1[0] - o.p0[0]) / L * back).toFixed(2));
|
|
325
|
+
o.line.setAttribute("y2", (ty - (o.p1[1] - o.p0[1]) / L * back).toFixed(2));
|
|
326
|
+
// 矢じりは線が 20px 伸びるまでに大きくなる(始めに箱からはみ出さない)
|
|
327
|
+
var hs = Math.min(1, e * L / 20);
|
|
328
|
+
o.head.setAttribute("transform", "translate(" + tx.toFixed(2) + " " + ty.toFixed(2) + ") rotate(" + o.ang.toFixed(2) + ") scale(" + hs.toFixed(4) + ")");
|
|
329
|
+
}
|
|
330
|
+
o.g.setAttribute("opacity", ahead(o.step) ? PV : e > 0 ? 1 : 0);
|
|
331
|
+
var lo = pr(o.step, o.at + P.draw * 0.8, 0.3).toFixed(3);
|
|
332
|
+
if (o.lab) o.lab.setAttribute("opacity", lo);
|
|
333
|
+
if (o.amt) o.amt.setAttribute("opacity", lo);
|
|
334
|
+
// pulse:今の段階に pulse があれば、点の列を (t - 開始) から置く。流れ終わった点と t = Infinity では出さない
|
|
335
|
+
var q = null;
|
|
336
|
+
o.pulses.forEach(function(x){ if (x.k === k) q = x; });
|
|
337
|
+
o.dots.forEach(function(dot, j){
|
|
338
|
+
var u = q && t !== Infinity ? (t - q.at - 0.22 * j) / P["pulse-dur"] : -1;
|
|
339
|
+
if (u <= 0 || u >= 1 || e < 1){ dot.setAttribute("opacity", 0); return; }
|
|
340
|
+
var w = D.prog(u, 0, 1);
|
|
341
|
+
if (o.poly){ var pp = self.polyAt(o.poly, w * o.poly.len); dot.setAttribute("cx", pp.x.toFixed(2)); dot.setAttribute("cy", pp.y.toFixed(2)); }
|
|
342
|
+
else { dot.setAttribute("cx", D.lerp(o.p0[0], o.p1[0], w).toFixed(2)); dot.setAttribute("cy", D.lerp(o.p0[1], o.p1[1], w).toFixed(2)); }
|
|
343
|
+
dot.setAttribute("opacity", Math.min(1, u * 8, (1 - u) * 8).toFixed(3));
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
});
|