egatari 0.6.11 → 0.6.12-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/egatari.mjs +4 -3
- package/components.lock.json +30 -15
- package/components2.lock.json +201 -1
- package/fonts/@fontsource/fraunces/400.css +29 -0
- package/fonts/@fontsource/fraunces/700.css +29 -0
- package/fonts/@fontsource/fraunces/LICENSE +93 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-ext-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-latin-ext-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-vietnamese-400-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/files/fraunces-vietnamese-700-normal.woff2 +0 -0
- package/fonts/@fontsource/fraunces/package.json +6 -0
- package/kit/check-messages.mjs +18 -7
- package/kit/check.mjs +12 -4
- package/kit/core/article-render.mjs +5 -5
- package/kit/core/build-core.mjs +25 -9
- package/kit/core/check-parity.mjs +1 -1
- package/kit/core/check-rules.mjs +2 -2
- package/kit/core/check-source.mjs +3 -0
- package/kit/core/colab-core.mjs +1 -1
- package/kit/core/kicker.mjs +42 -0
- package/kit/core/layout-scan.mjs +19 -7
- package/kit/core/llm-pack-data.mjs +8 -8
- package/kit/core/llm-pack.mjs +2 -2
- package/kit/core/theme-shapes.mjs +3 -1
- package/kit/core/themes-list.mjs +2 -0
- package/kit/instruction-version.json +1 -1
- package/kit/layouts.css +8 -0
- package/kit/player.json +1 -1
- package/kit/player.lock.json +2 -2
- package/package.json +2 -1
- package/themes/asagi/theme.json +1 -1
- package/themes/asagi/tokens.css +6 -0
- package/themes/bengara/theme.json +13 -0
- package/themes/bengara/tokens.css +66 -0
- package/themes/business/theme.json +1 -1
- package/themes/business/tokens.css +6 -0
- package/themes/default/theme.json +1 -1
- package/themes/default/tokens.css +9 -0
- package/themes/kogecha/theme.json +1 -1
- package/themes/kogecha/tokens.css +6 -0
- package/themes/kokugo/theme.json +1 -1
- package/themes/kokugo/tokens.css +6 -0
- package/themes/murasaki/theme.json +1 -1
- package/themes/murasaki/tokens.css +6 -0
- package/themes/sumi/theme.json +1 -1
- package/themes/sumi/tokens.css +8 -0
- package/themes/tokiwa/theme.json +1 -1
- package/themes/tokiwa/tokens.css +6 -0
- package/themes.lock.json +90 -24
- package/vendor/components/CATALOG.md +11 -11
- package/vendor/components/sha256/04626b77b3c683fd4c8e549339eca153615e021eb0e649c31291deb2dab30667/README.en.md +38 -0
- package/vendor/components/sha256/04626b77b3c683fd4c8e549339eca153615e021eb0e649c31291deb2dab30667/index.js +289 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/ABCJS-ADAPTER.md +101 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/LICENSE-abcjs.txt +21 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/chords.json +89 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/doremi.json +261 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/extras.json +192 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/kaeru.json +521 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/rhythm.json +248 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/fixtures/ties.json +360 -0
- package/vendor/components/sha256/0c4eb83646ab8027d40697db161eb952425db78c42b36291626214d5064b9498/index.js +508 -0
- package/vendor/components/sha256/0dc2a0945e7a4004278fcc9b8f02223bbb87f6269bffe3dd3ebeb3a78ce23d34/index.js +404 -0
- package/vendor/components/sha256/0e2e45b024bb2f37e82c83a4d9cd9f9c16b5dc4924dde81735c268a3d49f9d7f/index.js +97 -0
- package/vendor/components/sha256/0ef62e33d330f8e31ccb1f480b5e3b349769a142cc2737a9e6583d5eff9f56ca/index.js +919 -0
- package/vendor/components/sha256/1b33a252d51091e2d8cdea176f10268f128640bed3aa46da88d7de31ced59b44/README.en.md +48 -0
- package/vendor/components/sha256/1b33a252d51091e2d8cdea176f10268f128640bed3aa46da88d7de31ced59b44/index.js +384 -0
- package/vendor/components/sha256/1b767b6cf1855156872f87981a7c99f0161013499d6c4b21785624435db92078/README.en.md +34 -0
- package/vendor/components/sha256/1b767b6cf1855156872f87981a7c99f0161013499d6c4b21785624435db92078/index.js +244 -0
- package/vendor/components/sha256/3ace61e46a4555eab46ca8053db2fb76a874d4d5409bc5891cc449f43ef7e0bd/README.en.md +44 -0
- package/vendor/components/sha256/3ace61e46a4555eab46ca8053db2fb76a874d4d5409bc5891cc449f43ef7e0bd/index.js +304 -0
- package/vendor/components/sha256/4079077e03343995edc5e34b8bda0cf200dc6d854a52486fe0a6a4ceaf0d4b6f/README.en.md +44 -0
- package/vendor/components/sha256/4079077e03343995edc5e34b8bda0cf200dc6d854a52486fe0a6a4ceaf0d4b6f/index.js +203 -0
- package/vendor/components/sha256/40aaaaf988e7c32460ffaf5f18b5690ee28fd1fe7e879d8434d58283992bc554/README.en.md +37 -0
- package/vendor/components/sha256/40aaaaf988e7c32460ffaf5f18b5690ee28fd1fe7e879d8434d58283992bc554/index.js +438 -0
- package/vendor/components/sha256/442be174439d106ef462c19d598c407e86d5de3fcd4700ed54ae4147c4b9969c/README.en.md +24 -0
- package/vendor/components/sha256/442be174439d106ef462c19d598c407e86d5de3fcd4700ed54ae4147c4b9969c/index.js +103 -0
- package/vendor/components/sha256/48a776e7683e1aba8cad5aa4067914c017681efaa74f175066e0ab081bf3d013/index.js +351 -0
- package/vendor/components/sha256/4a9331635c2dd28e4b46108eaffe49c6d29cf626ecb900ac6e9029552be0cf49/index.js +607 -0
- package/vendor/components/sha256/5458baef7a30298cf4b0029331f13233d162403e686f9c20085dd2104cad7141/README.en.md +23 -0
- package/vendor/components/sha256/5458baef7a30298cf4b0029331f13233d162403e686f9c20085dd2104cad7141/index.js +120 -0
- package/vendor/components/sha256/586063d3a4e24e2995923811b2b9466bde86dbaafb3bcf103546d3f28159205a/index.js +812 -0
- package/vendor/components/sha256/5acc5f87e29f1170bc35dbee08087d0d03c1023969c6c1b1367a0f559d60e5ee/index.js +198 -0
- package/vendor/components/sha256/5c032594230fe688f661b6ccf27070c84f8c0e38611186280fb9c56d89ac3319/README.en.md +32 -0
- package/vendor/components/sha256/5c032594230fe688f661b6ccf27070c84f8c0e38611186280fb9c56d89ac3319/index.js +222 -0
- package/vendor/components/sha256/603de10f0ee50d07ec610e21b45b9db78d69376b4dfd2baba78595c1002e27ec/README.en.md +50 -0
- package/vendor/components/sha256/603de10f0ee50d07ec610e21b45b9db78d69376b4dfd2baba78595c1002e27ec/index.js +171 -0
- package/vendor/components/sha256/609e45a826d07a54cbbcbf4ce2ad6b5474dca1d0be394eb9fad895db4a73422f/README.en.md +51 -0
- package/vendor/components/sha256/609e45a826d07a54cbbcbf4ce2ad6b5474dca1d0be394eb9fad895db4a73422f/index.js +228 -0
- package/vendor/components/sha256/6364043cb31bbd86aacb7432af1a8affef8cae5c6efdbe13fbebd116fd51b91f/index.js +233 -0
- package/vendor/components/sha256/6f9f7283226d3534aa1cb4a47ba258204aa286ead01b25cdbde14119260bc702/README.en.md +66 -0
- package/vendor/components/sha256/6f9f7283226d3534aa1cb4a47ba258204aa286ead01b25cdbde14119260bc702/index.js +920 -0
- package/vendor/components/sha256/72edfd6678b22be0bb3e32b0d8cb0dfee403767e1eacac354d278d7318d03826/README.en.md +35 -0
- package/vendor/components/sha256/72edfd6678b22be0bb3e32b0d8cb0dfee403767e1eacac354d278d7318d03826/index.js +179 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/LICENSE-tabler.txt +21 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/index.js +4868 -0
- package/vendor/components/sha256/7482c50bea5ef7d72dc5d4afaddb8c4e725b5a83fa0c6175f9a9c556f23a4e10/names.txt +4808 -0
- package/vendor/components/sha256/7cb8948c550b66bf4b34a62e7b61385aaa79896e09d82ccb1846c0ac499ad352/README.en.md +40 -0
- package/vendor/components/sha256/7cb8948c550b66bf4b34a62e7b61385aaa79896e09d82ccb1846c0ac499ad352/index.js +348 -0
- package/vendor/components/sha256/87cc60da38d209cda449dd7c24171e287ac8184c5036ca04548ef9e2015c2d9e/README.en.md +42 -0
- package/vendor/components/sha256/87cc60da38d209cda449dd7c24171e287ac8184c5036ca04548ef9e2015c2d9e/index.js +268 -0
- package/vendor/components/sha256/8cb367c71c002c689defddc6f075be911d5485421715119b5515181e962a2401/index.js +121 -0
- package/vendor/components/sha256/97bfd6e79c7278c55153bf4c2330da0432cf0ee312baa11650e07cdd7912831d/index.js +354 -0
- package/vendor/components/sha256/a426e6a3f8f4593403ba63ecc4a3f1f41064f4016fd9fb8d51e7876bf8c6f573/README.en.md +40 -0
- package/vendor/components/sha256/a426e6a3f8f4593403ba63ecc4a3f1f41064f4016fd9fb8d51e7876bf8c6f573/index.js +348 -0
- package/vendor/components/sha256/c108119117042cacc65a35ec73fcab95a2a92b2a2797129f66e326783f8db178/index.js +465 -0
- package/vendor/components/sha256/c3fad2047cec6a2bd8a5b907f752e2addeeea2f373fd8115914552dcee0b2f6f/README.en.md +23 -0
- package/vendor/components/sha256/c3fad2047cec6a2bd8a5b907f752e2addeeea2f373fd8115914552dcee0b2f6f/index.js +289 -0
- package/vendor/components/sha256/c59f1ac3132fdf6f56e8880c866570cd7443f09eb8802b6e7af32675ad358edf/README.en.md +31 -0
- package/vendor/components/sha256/c59f1ac3132fdf6f56e8880c866570cd7443f09eb8802b6e7af32675ad358edf/index.js +236 -0
- package/vendor/components/sha256/d3a75f67160490db1831aaa8ac58ebc5f7ffb6a6fd21e2bdeaa6fe979bfaff7f/README.en.md +42 -0
- package/vendor/components/sha256/d3a75f67160490db1831aaa8ac58ebc5f7ffb6a6fd21e2bdeaa6fe979bfaff7f/index.js +488 -0
- package/vendor/components/sha256/d998b5db828427505e39cdae67676dc6480c791d6037152dec222ae81cdbba1f/index.js +484 -0
- package/vendor/components/sha256/ea17602aaecca64b672b3bc827965ff378cb460250177f7b66f73081a48d4e81/index.js +278 -0
- package/vendor/components/sha256/f9cef6dd9580a4f19aa09d47f736ab2391f5f585b20b16a62bd781398cb6b8ac/README.en.md +22 -0
- package/vendor/components/sha256/f9cef6dd9580a4f19aa09d47f736ab2391f5f585b20b16a62bd781398cb6b8ac/index.js +145 -0
- package/vendor/components-2/manifest-2.8.0.json +2199 -0
- package/vendor/themes/asagi/1.2.0/theme.json +14 -0
- package/vendor/themes/asagi/1.2.0/tokens.css +30 -0
- package/vendor/themes/business/1.2.0/theme.json +5 -0
- package/vendor/themes/business/1.2.0/tokens.css +41 -0
- package/vendor/themes/default/1.4.0/theme.json +4 -0
- package/vendor/themes/default/1.4.0/tokens.css +86 -0
- package/vendor/themes/kogecha/1.2.0/theme.json +10 -0
- package/vendor/themes/kogecha/1.2.0/tokens.css +29 -0
- package/vendor/themes/kokugo/1.2.0/theme.json +5 -0
- package/vendor/themes/kokugo/1.2.0/tokens.css +25 -0
- package/vendor/themes/murasaki/1.2.0/theme.json +10 -0
- package/vendor/themes/murasaki/1.2.0/tokens.css +25 -0
- package/vendor/themes/sumi/1.2.0/theme.json +10 -0
- package/vendor/themes/sumi/1.2.0/tokens.css +49 -0
- package/vendor/themes/tokiwa/1.2.0/theme.json +10 -0
- package/vendor/themes/tokiwa/1.2.0/tokens.css +27 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
// m-gendai:現代文の読解の図。傍線・二重傍線を引き、指示語から指す内容へ矢印を出し、段落を役割(主張・具体例・対比)の枠で囲んで線でつなぐ
|
|
2
|
+
// <m-gendai tate style="height:440px">
|
|
3
|
+
// @具体例#p1>p3
|
|
4
|
+
// 駅までの道を、私は{地図アプリ|#app}に頼って歩く。…{それ|>app}を閉じると、…
|
|
5
|
+
//
|
|
6
|
+
// @主張#p3
|
|
7
|
+
// 便利な道具は、私たちから=={迷う機会を奪う}==。…{迷うことこそが…営みなのである|_A}
|
|
8
|
+
// </m-gendai>
|
|
9
|
+
// 段落は空行で区切る。段落の頭の行「@役割#名前」で役割(主張・具体例・対比・反論・結論など、自由な言葉)と名前を付け、
|
|
10
|
+
// 「>名前」(その段落を支える・つながる。矢印)か「~名前」(対比。両向きの線)で別の段落とつなぐ。
|
|
11
|
+
// 本文の中:__語句__ 傍線、==語句== 二重傍線、{語句|しるし,…}(しるし:_A 傍線と記号 A、=B 二重傍線と記号 B、#名前 指す先、>名前 指示語)
|
|
12
|
+
// 段階(phases の順。中身のないものは飛ばす。既定は marks refs roles):marks 傍線 → refs 指示語の矢印 → roles 段落の枠と線
|
|
13
|
+
// 線と枠は、字の位置を測って SVG で描く(部品の中の座標。描く度に測るので、呼び出しの順によらない)
|
|
14
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・prog・previewOpacity を使い、プレイヤーのグローバルは使わない。
|
|
15
|
+
// 書き方の誤りは ctx.report("data", "[gendai] …") で知らせる(1.x の console.warn("m-gendai: …") の代わり)。
|
|
16
|
+
// 読み取り(parse)は試験のために static testing に出す(ほかのパーツは読まない)
|
|
17
|
+
egatariParts.define({name: "gendai", version: "2.0.3", requires: {base: "1.2.0"}, element: "m-gendai"}, function(deps){
|
|
18
|
+
"use strict";
|
|
19
|
+
var base = deps.base;
|
|
20
|
+
var D = base;
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------- 読み取り
|
|
23
|
+
// parse(文字列) → {paras: [{role, id, to, rel, runs: [{t, line, label, id, ref}]}], warnings}
|
|
24
|
+
function parse(src){
|
|
25
|
+
var paras = [], warnings = [], blocks = String(src || "").replace(/\r/g, "").split(/\n\s*\n/);
|
|
26
|
+
blocks.forEach(function(b){
|
|
27
|
+
var lines = b.split("\n").map(function(l){ return l.trim(); }).filter(Boolean);
|
|
28
|
+
if (!lines.length) return;
|
|
29
|
+
var p = {role: "", id: "", to: "", rel: "", runs: []};
|
|
30
|
+
var m = /^@([^#>~\s]*)(?:#([^>~\s]+))?(?:([>~])(\S+))?\s*$/.exec(lines[0]);
|
|
31
|
+
if (m){ p.role = m[1]; p.id = m[2] || ""; p.rel = m[3] || ""; p.to = m[4] || ""; lines.shift(); }
|
|
32
|
+
p.runs = inline(lines.join(""), warnings);
|
|
33
|
+
paras.push(p);
|
|
34
|
+
});
|
|
35
|
+
var ids = {};
|
|
36
|
+
paras.forEach(function(p){ if (p.id) ids[p.id] = true; });
|
|
37
|
+
paras.forEach(function(p){ if (p.to && !ids[p.to]) warnings.push("段落「" + p.to + "」がない(@" + p.role + ")"); });
|
|
38
|
+
var anchors = {};
|
|
39
|
+
paras.forEach(function(p){ p.runs.forEach(function(r){ if (r.id) anchors[r.id] = true; }); });
|
|
40
|
+
paras.forEach(function(p){ p.runs.forEach(function(r){ if (r.ref && !anchors[r.ref]) warnings.push("指す先「#" + r.ref + "」がない(" + r.t + ")"); }); });
|
|
41
|
+
return {paras: paras, warnings: warnings};
|
|
42
|
+
}
|
|
43
|
+
// 本文の中のしるし → 字の並び(runs)。run = {t, line: 0 | 1 | 2(傍線・二重傍線), label, id, ref}
|
|
44
|
+
function inline(s, warnings){
|
|
45
|
+
var runs = [], re = /__(.+?)__|==(.+?)==|\{([^{}|]+)\|([^{}]*)\}/g, last = 0, m;
|
|
46
|
+
var plain = function(t){ if (t) runs.push({t: t, line: 0, label: "", id: "", ref: ""}); };
|
|
47
|
+
while ((m = re.exec(s))){
|
|
48
|
+
plain(s.slice(last, m.index)); last = re.lastIndex;
|
|
49
|
+
if (m[1] !== undefined){ runs.push({t: m[1], line: 1, label: "", id: "", ref: ""}); continue; }
|
|
50
|
+
if (m[2] !== undefined){ runs.push({t: m[2], line: 2, label: "", id: "", ref: ""}); continue; }
|
|
51
|
+
var r = {t: m[3], line: 0, label: "", id: "", ref: ""};
|
|
52
|
+
m[4].split(/[,,、]/).map(function(f){ return f.trim(); }).filter(Boolean).forEach(function(f){
|
|
53
|
+
if (f[0] === "_"){ r.line = 1; r.label = f.slice(1); }
|
|
54
|
+
else if (f[0] === "="){ r.line = 2; r.label = f.slice(1); }
|
|
55
|
+
else if (f[0] === "#") r.id = f.slice(1);
|
|
56
|
+
else if (f[0] === ">") r.ref = f.slice(1);
|
|
57
|
+
else warnings.push("知らないしるし「" + f + "」(" + m[3] + ")");
|
|
58
|
+
});
|
|
59
|
+
runs.push(r);
|
|
60
|
+
}
|
|
61
|
+
plain(s.slice(last));
|
|
62
|
+
// 残った { } __ ==:閉じていないか、入れ子にしたしるし(しるしは入れ子にできない。{語句|=,#名前} のように 1 つにまとめる)
|
|
63
|
+
runs.forEach(function(r){ if (/[{}]|__|==/.test(r.t)) warnings.push("しるしの書き方が違う(閉じていない・入れ子):" + r.t); });
|
|
64
|
+
return runs;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ---------------------------------------------------------------- 部品
|
|
68
|
+
var ROLE_COLOR = function(role){ return /主張|結論|筆者/.test(role) ? "var(--emph)" : /対比|反論|対立/.test(role) ? "var(--accent2)" : /具体|例/.test(role) ? "var(--term)" : "var(--muted)"; };
|
|
69
|
+
var PH = ["marks", "refs", "roles"];
|
|
70
|
+
// 枠をつなぐ線は札(枠の上の名前)から札へ、札と枠の外の通り道(縦書きは札の上、横書きは札の左)を通す。
|
|
71
|
+
// 通り道は線ごとに段(level)を分け、間の段落を越える線ほど外の段を通る。段の数だけ場所を空ける(線が札や枠に重ならないように)
|
|
72
|
+
var CHIP = 34; // 札の高さ
|
|
73
|
+
var STUB = 22, STEP = 16; // 札から 1 段目までの距離、段の間
|
|
74
|
+
var LH_TATE = 2.4; // 縦書きの行の送り(傍線と記号 A の入る列の間を空ける)
|
|
75
|
+
return class extends base.MotionElement {
|
|
76
|
+
static partName = "gendai"; // the registry name (define meta name), for report prefixes
|
|
77
|
+
static testing = {parse: parse}; // for tools/test-kokugo.mjs only (no part reads it)
|
|
78
|
+
// データの形(kit/shape.js):JSON ではなく、要素の中に本文の字(段落は空行で区切る)
|
|
79
|
+
static shape = {text: true, example: "@主張#p1\n便利な道具は、私たちから==迷う機会を奪う==。"};
|
|
80
|
+
static props = {
|
|
81
|
+
size: {type: "number", default: 28, doc: "本文の字の大きさ(px)"},
|
|
82
|
+
tate: {type: "bool", default: false, doc: "縦書きにする(段落は右から左へ、枠をつなぐ線は上を通す)"},
|
|
83
|
+
phases: {type: "string", default: "marks refs roles", doc: "ステップの並び(marks 傍線・refs 指示語・roles 段落の枠から選ぶ。中身のないものは飛ばす)"},
|
|
84
|
+
draw: {type: "number", default: 0.7, doc: "線 1 本を引く秒数"},
|
|
85
|
+
};
|
|
86
|
+
get model(){ if (!this._m) this._m = parse(this._src !== undefined ? this._src : this.textContent); return this._m; }
|
|
87
|
+
get phaseList(){
|
|
88
|
+
var m = this.model, has = {
|
|
89
|
+
marks: m.paras.some(function(p){ return p.runs.some(function(r){ return r.line; }); }),
|
|
90
|
+
refs: m.paras.some(function(p){ return p.runs.some(function(r){ return r.ref; }); }),
|
|
91
|
+
roles: m.paras.some(function(p){ return p.role; })};
|
|
92
|
+
return String(this.props.phases || "").split(/[\s,]+/).filter(function(x){ return PH.indexOf(x) >= 0 && has[x]; });
|
|
93
|
+
}
|
|
94
|
+
get steps(){ return this.getAttribute("steps") !== null ? +this.getAttribute("steps") : this.phaseList.length; }
|
|
95
|
+
phaseStep(name){ return this.phaseList.indexOf(name) + 1; }
|
|
96
|
+
mount(ctx){
|
|
97
|
+
var self = this, P = this.props, tate = P.tate;
|
|
98
|
+
this._src = this.textContent;
|
|
99
|
+
var m = this.model;
|
|
100
|
+
m.warnings.forEach(function(w){ ctx.report("data", "[gendai] " + w); });
|
|
101
|
+
this.textContent = "";
|
|
102
|
+
this.classList.add("plot");
|
|
103
|
+
this.style.display = "block"; this.style.position = "relative";
|
|
104
|
+
this.style.fontFamily = "var(--font-mincho)";
|
|
105
|
+
var W =this.clientWidth || 1184, H = this.clientHeight || 440;
|
|
106
|
+
var roles = m.paras.some(function(p){ return p.role; });
|
|
107
|
+
// つなぐ線の段:つなぐ段落の間の短いものから順に、重なる線より 1 つ外の段へ
|
|
108
|
+
var pIdx = {};
|
|
109
|
+
m.paras.forEach(function(p, i){ if (p.id) pIdx[p.id] = i; });
|
|
110
|
+
var spans = m.paras.map(function(p, i){ return p.to && pIdx[p.to] !== undefined ? {i: i, lo: Math.min(i, pIdx[p.to]), hi: Math.max(i, pIdx[p.to])} : null; }).filter(Boolean)
|
|
111
|
+
.sort(function(a, b){ return (a.hi - a.lo) - (b.hi - b.lo) || a.lo - b.lo; });
|
|
112
|
+
var levelOf = {}, placed = [], nLev = 0;
|
|
113
|
+
spans.forEach(function(o){
|
|
114
|
+
var lv = 1;
|
|
115
|
+
placed.forEach(function(q){ if (q.lo < o.hi && o.lo < q.hi) lv = Math.max(lv, q.lv + 1); });
|
|
116
|
+
o.lv = lv; placed.push(o); levelOf[o.i] = lv; nLev = Math.max(nLev, lv);
|
|
117
|
+
});
|
|
118
|
+
this.nLev = nLev;
|
|
119
|
+
// 通り道と札の場所:縦書きは上に(札 + 段)、横書きは左に(段)と上に(札)
|
|
120
|
+
var lane = nLev ? STUB + (nLev - 1) * STEP + 10 : 0;
|
|
121
|
+
this.padTop = tate ? (roles ? CHIP + lane + 10 : 20) : (roles ? CHIP + 10 : 20);
|
|
122
|
+
this.padLeft = tate ? 0 : (nLev ? lane - 2 : 4);
|
|
123
|
+
// 重ね順:塗り(指す先の淡い色)→ 字 → 線・枠・矢印
|
|
124
|
+
this.back = D.el("svg", {width: W, height: H, viewBox: "0 0 " + W + " " + H, "aria-hidden": "true", style: "position:absolute;left:0;top:0;overflow:visible;pointer-events:none"}, this);
|
|
125
|
+
var text = document.createElement("div");
|
|
126
|
+
text.style.cssText = "position:absolute;inset:0;font-size:" + P.size + "px;line-height:" + (tate ? LH_TATE : 1.85) + ";padding-top:" + this.padTop + "px;" + (tate ? "writing-mode:vertical-rl;" : "padding-left:" + this.padLeft + "px;");
|
|
127
|
+
this.appendChild(text);
|
|
128
|
+
this.front = D.el("svg", {width: W, height: H, viewBox: "0 0 " + W + " " + H, "aria-hidden": "true", style: "position:absolute;left:0;top:0;overflow:visible;pointer-events:none"}, this);
|
|
129
|
+
this.text = text;
|
|
130
|
+
var byId = {};
|
|
131
|
+
this.paras = m.paras.map(function(p, pi){
|
|
132
|
+
var d = document.createElement("div");
|
|
133
|
+
// 枠の内側の余白と、段落の間(枠の名前の札が入る)
|
|
134
|
+
// 横書きは次の段落の札が前の枠に掛からないように空ける
|
|
135
|
+
d.style.cssText = "padding:10px 14px;text-indent:1em;" + (tate ? "margin:0 0 0 22px;" : "margin:0 0 " + (roles ? CHIP + 12 : 22) + "px 0;");
|
|
136
|
+
text.appendChild(d);
|
|
137
|
+
var P2 = {p: p, el: d, spans: []};
|
|
138
|
+
p.runs.forEach(function(r){
|
|
139
|
+
if (!r.line && !r.id && !r.ref){ d.appendChild(document.createTextNode(r.t)); return; }
|
|
140
|
+
var s = document.createElement("span"); s.textContent = r.t; d.appendChild(s);
|
|
141
|
+
P2.spans.push({r: r, el: s});
|
|
142
|
+
if (r.id) byId[r.id] = s;
|
|
143
|
+
});
|
|
144
|
+
return P2;
|
|
145
|
+
});
|
|
146
|
+
this.byId = byId;
|
|
147
|
+
// 傍線(引く順に)
|
|
148
|
+
this.lines = [];
|
|
149
|
+
this.paras.forEach(function(P2){ P2.spans.forEach(function(s){ if (s.r.line){
|
|
150
|
+
var g = D.el("g", {}, self.front), o = {el: s.el, r: s.r, g: g, segs: [], lab: null};
|
|
151
|
+
if (s.r.label) o.lab = D.el("text", {"font-size": 24, "font-weight": 700, fill: "var(--emph)", "text-anchor": "middle", opacity: 0}, g);
|
|
152
|
+
if (o.lab) o.lab.textContent = s.r.label;
|
|
153
|
+
self.lines.push(o);
|
|
154
|
+
} }); });
|
|
155
|
+
// 指示語 → 指す先
|
|
156
|
+
this.refs = [];
|
|
157
|
+
this.paras.forEach(function(P2){ P2.spans.forEach(function(s){ if (s.r.ref && byId[s.r.ref]){
|
|
158
|
+
self.refs.push({from: s.el, to: byId[s.r.ref],
|
|
159
|
+
fill: D.el("g", {opacity: 0}, self.back),
|
|
160
|
+
box: D.el("g", {opacity: 0}, self.front),
|
|
161
|
+
path: D.el("path", {fill: "none", stroke: "var(--emph)", "stroke-width": 3, "stroke-linecap": "round", pathLength: 1, "stroke-dasharray": 1, "stroke-dashoffset": 1}, self.front),
|
|
162
|
+
head: D.el("path", {d: "M0,0L-14,-7L-14,7Z", fill: "var(--emph)", opacity: 0}, self.front)});
|
|
163
|
+
} }); });
|
|
164
|
+
// 段落の枠・札・つなぐ線
|
|
165
|
+
var pById = {};
|
|
166
|
+
this.paras.forEach(function(P2){ if (P2.p.id) pById[P2.p.id] = P2; });
|
|
167
|
+
this.boxes = this.paras.filter(function(P2){ return P2.p.role; }).map(function(P2){
|
|
168
|
+
var c = ROLE_COLOR(P2.p.role);
|
|
169
|
+
var rect = D.el("rect", {fill: "none", stroke: c, "stroke-width": 2.5, rx: 10, pathLength: 1, "stroke-dasharray": 1, "stroke-dashoffset": 1}, self.front);
|
|
170
|
+
var chip = D.el("g", {opacity: 0}, self.front);
|
|
171
|
+
var cr = D.el("rect", {fill: "var(--bg)", stroke: c, "stroke-width": 2, rx: 14, height: 34}, chip);
|
|
172
|
+
var ct = D.el("text", {"font-size": 24, "font-weight": 700, fill: c, "text-anchor": "middle"}, chip);
|
|
173
|
+
ct.textContent = P2.p.role;
|
|
174
|
+
return {P2: P2, c: c, rect: rect, chip: chip, cr: cr, ct: ct};
|
|
175
|
+
});
|
|
176
|
+
this.links = this.paras.filter(function(P2){ return P2.p.to && pById[P2.p.to]; }).map(function(P2){
|
|
177
|
+
var c = P2.p.rel === "~" ? "var(--accent2)" : "var(--muted)";
|
|
178
|
+
return {a: P2, b: pById[P2.p.to], rel: P2.p.rel, c: c, lv: levelOf[self.paras.indexOf(P2)] || 1,
|
|
179
|
+
path: D.el("path", {fill: "none", stroke: c, "stroke-width": 2.5, "stroke-dasharray": P2.p.rel === "~" ? "none" : "none", pathLength: 1}, self.front),
|
|
180
|
+
h1: D.el("path", {d: "M0,0L-13,-6.5L-13,6.5Z", fill: c, opacity: 0}, self.front),
|
|
181
|
+
h0: P2.p.rel === "~" ? D.el("path", {d: "M0,0L-13,-6.5L-13,6.5Z", fill: c, opacity: 0}, self.front) : null};
|
|
182
|
+
});
|
|
183
|
+
// 読み上げ:本文はそのまま読める字(role="figure" の中身)。名前は最後の形の読解のしるし(傍線・指示語・段落の役割とつながり。
|
|
184
|
+
// phases にある段階のものだけ)を 1 文で。線と枠の SVG は aria-hidden。作者の aria-label があればそれを使う(上書きしない)
|
|
185
|
+
if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
|
|
186
|
+
this.setAttribute("role", "figure");
|
|
187
|
+
if (!this._aria) this.setAttribute("aria-label", this.summary());
|
|
188
|
+
}
|
|
189
|
+
// 最後の形の読解のしるしを 1 文で(読み上げの名前)
|
|
190
|
+
summary(){
|
|
191
|
+
var m = this.model, ph = this.phaseList, out = [], anchors = {};
|
|
192
|
+
m.paras.forEach(function(p){ p.runs.forEach(function(r){ if (r.id) anchors[r.id] = r.t; }); });
|
|
193
|
+
var runs = [].concat.apply([], m.paras.map(function(p){ return p.runs; }));
|
|
194
|
+
if (ph.indexOf("marks") >= 0) out.push(runs.filter(function(r){ return r.line; }).map(function(r){ return (r.line === 2 ? "二重傍線" : "傍線") + (r.label ? " " + r.label : "") + "「" + r.t + "」"; }).join("、"));
|
|
195
|
+
if (ph.indexOf("refs") >= 0) out.push(runs.filter(function(r){ return r.ref && anchors[r.ref] !== undefined; }).map(function(r){ return "指示語「" + r.t + "」は「" + anchors[r.ref] + "」を指す"; }).join("、"));
|
|
196
|
+
if (ph.indexOf("roles") >= 0){
|
|
197
|
+
var byId = {};
|
|
198
|
+
m.paras.forEach(function(p){ if (p.id) byId[p.id] = p; });
|
|
199
|
+
var links = m.paras.filter(function(p){ return p.to && byId[p.to]; }).map(function(p){ return (p.role || "段落") + (p.rel === "~" ? " ↔ " : " → ") + (byId[p.to].role || "段落"); });
|
|
200
|
+
out.push("段落の役割:" + m.paras.map(function(p){ return p.role; }).filter(Boolean).join("・") + (links.length ? "(" + links.join("、") + ")" : ""));
|
|
201
|
+
}
|
|
202
|
+
out = out.filter(Boolean);
|
|
203
|
+
return "現代文の読解" + (out.length ? ":" + out.join("。") : "");
|
|
204
|
+
}
|
|
205
|
+
// 要素の字の箱(行ごと)を部品の座標で。部品の外側の拡大(舞台の scale・段階の translate)によらない
|
|
206
|
+
rects(e){
|
|
207
|
+
var R = this.getBoundingClientRect(), sc = R.width / (this.offsetWidth || 1) || 1;
|
|
208
|
+
return [].map.call(e.getClientRects(), function(r){ return {l: (r.left - R.left) / sc, t: (r.top - R.top) / sc, r: (r.right - R.left) / sc, b: (r.bottom - R.top) / sc}; })
|
|
209
|
+
.filter(function(r){ return r.r - r.l > 0.5 && r.b - r.t > 0.5; });
|
|
210
|
+
}
|
|
211
|
+
box(e){ var r = this.rects(e), o = null; r.forEach(function(x){ o = o ? {l: Math.min(o.l, x.l), t: Math.min(o.t, x.t), r: Math.max(o.r, x.r), b: Math.max(o.b, x.b)} : x; }); return o; }
|
|
212
|
+
duration(k){
|
|
213
|
+
var name = this.phaseList[k - 1], P = this.props;
|
|
214
|
+
if (name === "marks") return this.lines.length * P.draw * 0.8 + 0.3;
|
|
215
|
+
if (name === "refs") return this.refs.length * (P.draw + 0.3) + 0.2;
|
|
216
|
+
if (name === "roles") return this.boxes.length * 0.35 + P.draw + (this.links.length ? 0.3 + P.draw : 0);
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
render(k, t, ctx){
|
|
220
|
+
var self = this, P = this.props, tate = P.tate;
|
|
221
|
+
var at = function(name){ var s = self.phaseStep(name); if (!s) return -1; return k > s ? Infinity : k < s ? -1 : t; };
|
|
222
|
+
var pr = function(tt, a, d){ return tt < 0 ? 0 : D.prog(tt, a, d); };
|
|
223
|
+
var tm = at("marks"), trf = at("refs"), tro = at("roles");
|
|
224
|
+
// 先の段階を薄く見せる表示(授業の表示):後の段階の傍線・指示語の囲みと矢印・段落の枠と札とつなぐ線を、
|
|
225
|
+
// 引き終えた形のまま --preview-opacity の濃さで出す
|
|
226
|
+
var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 0.45;
|
|
227
|
+
var later = function(name){ return preview && self.phaseStep(name) > k; };
|
|
228
|
+
var fM = later("marks"), fR = later("refs"), fO = later("roles");
|
|
229
|
+
if (fM) tm = Infinity;
|
|
230
|
+
if (fR) trf = Infinity;
|
|
231
|
+
if (fO) tro = Infinity;
|
|
232
|
+
var f1 = function(x){ return x.toFixed(1); };
|
|
233
|
+
// ---- 傍線:縦書きは字の右、横書きは字の下。二重傍線は 2 本。行をまたぐときは行ごとに順に引く
|
|
234
|
+
this.lines.forEach(function(o, j){
|
|
235
|
+
var e = pr(tm, j * P.draw * 0.8, P.draw), rs = self.rects(o.el), total = 0;
|
|
236
|
+
rs.forEach(function(r){ total += tate ? r.b - r.t : r.r - r.l; });
|
|
237
|
+
while (o.g.childNodes.length > (o.lab ? 1 : 0)) o.g.removeChild(o.g.lastChild);
|
|
238
|
+
if (fM) o.g.setAttribute("opacity", PV); else o.g.removeAttribute("opacity");
|
|
239
|
+
var left = e * total;
|
|
240
|
+
rs.forEach(function(r){
|
|
241
|
+
var len = tate ? r.b - r.t : r.r - r.l, d = Math.max(0, Math.min(len, left)); left -= len;
|
|
242
|
+
if (d <= 0) return;
|
|
243
|
+
for (var q = 0; q < o.r.line; q++){
|
|
244
|
+
var off = 3 + q * 5;
|
|
245
|
+
var attrs = tate ? {x1: f1(r.r + off), x2: f1(r.r + off), y1: f1(r.t), y2: f1(r.t + d)} : {x1: f1(r.l), x2: f1(r.l + d), y1: f1(r.b + off), y2: f1(r.b + off)};
|
|
246
|
+
attrs.stroke = "var(--emph)"; attrs["stroke-width"] = 2.2;
|
|
247
|
+
D.el("line", attrs, o.g);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
if (o.lab && rs.length){
|
|
251
|
+
var r0 = rs[0];
|
|
252
|
+
// 記号(A など)は線の始まりの外:縦書きは線の右の列の間で始まりより上、横書きは線の下の行の間
|
|
253
|
+
// 縦書きは線のすぐ右(列の間の、自分の列に寄ったところ)に、線の始まりから下へ
|
|
254
|
+
if (tate){ o.lab.setAttribute("x", f1(r0.r + 3 + o.r.line * 5 + 7)); o.lab.setAttribute("y", f1(r0.t + 22)); }
|
|
255
|
+
else { o.lab.setAttribute("x", f1(r0.l + 10)); o.lab.setAttribute("y", f1(r0.b + 3 + o.r.line * 5 + 20)); }
|
|
256
|
+
o.lab.setAttribute("opacity", pr(tm, j * P.draw * 0.8, 0.3).toFixed(3));
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
// ---- 指示語:指示語を四角で囲み、指す先に淡い色を敷き、指示語から指す先へ矢印
|
|
260
|
+
this.refs.forEach(function(o, j){
|
|
261
|
+
var a0 = j * (P.draw + 0.3), eb = pr(trf, a0, 0.3), ea = pr(trf, a0 + 0.25, P.draw);
|
|
262
|
+
var A = self.box(o.from), B = self.box(o.to);
|
|
263
|
+
while (o.box.firstChild) o.box.removeChild(o.box.firstChild);
|
|
264
|
+
while (o.fill.firstChild) o.fill.removeChild(o.fill.firstChild);
|
|
265
|
+
if (!A || !B){ o.box.setAttribute("opacity", 0); return; }
|
|
266
|
+
if (fR) eb = ea = PV;
|
|
267
|
+
D.el("rect", {x: f1(A.l - 3), y: f1(A.t - 2), width: f1(A.r - A.l + 6), height: f1(A.b - A.t + 4), rx: 5, fill: "none", stroke: "var(--emph)", "stroke-width": 2.5}, o.box);
|
|
268
|
+
self.rects(o.to).forEach(function(r){ D.el("rect", {x: f1(r.l - 2), y: f1(r.t), width: f1(r.r - r.l + 4), height: f1(r.b - r.t), rx: 4, fill: "var(--emph-tint)"}, o.fill); });
|
|
269
|
+
o.box.setAttribute("opacity", eb.toFixed(3)); o.fill.setAttribute("opacity", ea.toFixed(3));
|
|
270
|
+
// 矢印:指す先の行(字の箱)のうち指示語に近いものへ。同じ列(行)なら列の右(行の上)に弧、違えば列の頭(行の上)の側を通す
|
|
271
|
+
var ac = {x: (A.l + A.r) / 2, y: (A.t + A.b) / 2}, Bn = null, bd = Infinity;
|
|
272
|
+
self.rects(o.to).forEach(function(r){ var d = Math.hypot((r.l + r.r) / 2 - ac.x, (r.t + r.b) / 2 - ac.y); if (d < bd){ bd = d; Bn = r; } });
|
|
273
|
+
var x0, y0, x1, y1, cx, cy, same = tate ? Math.abs((Bn.l + Bn.r) / 2 - ac.x) < 6 : Math.abs((Bn.t + Bn.b) / 2 - ac.y) < 6;
|
|
274
|
+
if (tate && same){ var up = Bn.b <= A.t; x0 = A.r + 4; y0 = up ? A.t + 4 : A.b - 4; x1 = Bn.r + 4; y1 = up ? Bn.b - 4 : Bn.t + 4; cx = Math.max(x0, x1) + 44; cy = (y0 + y1) / 2; }
|
|
275
|
+
else if (tate){ x0 = ac.x; y0 = A.t - 4; x1 = (Bn.l + Bn.r) / 2; y1 = Bn.t - 4; cx = (x0 + x1) / 2; cy = Math.min(y0, y1) - 60; }
|
|
276
|
+
else if (same){ x0 = ac.x; y0 = A.t - 2; x1 = (Bn.l + Bn.r) / 2; y1 = Bn.t - 2; cx = (x0 + x1) / 2; cy = Math.min(y0, y1) - 46; }
|
|
277
|
+
else { var above = Bn.b <= A.t; x0 = ac.x; y0 = above ? A.t - 2 : A.b + 2; x1 = (Bn.l + Bn.r) / 2; y1 = above ? Bn.b + 2 : Bn.t - 2; cx = (x0 + x1) / 2 + 40; cy = (y0 + y1) / 2; }
|
|
278
|
+
// 指示語と指す先が同じ段落なら、弧の膨らみをその段落の枠の内側にとどめる(2 次曲線の頂は端と制御点の中ほど)
|
|
279
|
+
var para = o.from.parentNode === o.to.parentNode ? self.box(o.from.parentNode) : null, pad = 6;
|
|
280
|
+
if (para){
|
|
281
|
+
var mid = function(a, b){ return (a + b) / 2; };
|
|
282
|
+
if (cy < mid(y0, y1)) cy = Math.max(cy, 2 * (para.t + pad) - mid(y0, y1));
|
|
283
|
+
if (cx > mid(x0, x1)) cx = Math.min(cx, 2 * (para.r - pad) - mid(x0, x1));
|
|
284
|
+
}
|
|
285
|
+
o.path.setAttribute("d", "M" + f1(x0) + "," + f1(y0) + "Q" + f1(cx) + "," + f1(cy) + " " + f1(x1) + "," + f1(y1));
|
|
286
|
+
o.path.setAttribute("stroke-dashoffset", (fR ? 0 : 1 - ea).toFixed(4));
|
|
287
|
+
o.path.setAttribute("opacity", fR ? PV : ea > 0 ? 1 : 0);
|
|
288
|
+
o.head.setAttribute("transform", "translate(" + f1(x1) + " " + f1(y1) + ") rotate(" + (Math.atan2(y1 - cy, x1 - cx) * 180 / Math.PI).toFixed(1) + ")");
|
|
289
|
+
o.head.setAttribute("opacity", fR ? PV : ea >= 0.98 ? 1 : 0);
|
|
290
|
+
});
|
|
291
|
+
// ---- 段落の枠:順に囲み、札を出し、最後につなぐ線
|
|
292
|
+
var nb = this.boxes.length, tLink = nb * 0.35 + P.draw;
|
|
293
|
+
var boxOf = {}, chipOf = {};
|
|
294
|
+
this.boxes.forEach(function(o, j){
|
|
295
|
+
var e = pr(tro, j * 0.35, P.draw), el = o.P2.el;
|
|
296
|
+
var x = el.offsetLeft, y = el.offsetTop, w = el.offsetWidth, h = el.offsetHeight;
|
|
297
|
+
// offset は .text の中の座標。.text は部品の左上にある
|
|
298
|
+
boxOf[o.P2.p.id || j] = {x: x, y: y, w: w, h: h};
|
|
299
|
+
o.rect.setAttribute("x", x); o.rect.setAttribute("y", y); o.rect.setAttribute("width", w); o.rect.setAttribute("height", h);
|
|
300
|
+
o.rect.setAttribute("stroke-dashoffset", (1 - e).toFixed(4));
|
|
301
|
+
o.rect.setAttribute("opacity", fO ? PV : e > 0 ? 1 : 0);
|
|
302
|
+
// 札:縦書きは枠の上の辺の右寄り、横書きは左上の角
|
|
303
|
+
var tw = Array.from(o.P2.p.role).length * 24 + 24;
|
|
304
|
+
var cx = tate ? x + w - tw / 2 - 12 : x + tw / 2 + 12, cy = tate ? y - 17 : y - 17;
|
|
305
|
+
o.cr.setAttribute("x", f1(cx - tw / 2)); o.cr.setAttribute("y", f1(cy - 17)); o.cr.setAttribute("width", tw);
|
|
306
|
+
o.ct.setAttribute("x", f1(cx)); o.ct.setAttribute("y", f1(cy + 8.5));
|
|
307
|
+
o.chip.setAttribute("opacity", (fO ? PV : pr(tro, j * 0.35 + P.draw * 0.5, 0.3)).toFixed(3));
|
|
308
|
+
chipOf[o.P2.p.id || j] = {l: cx - tw / 2, r: cx + tw / 2, t: cy - 17, b: cy + 17, at: []};
|
|
309
|
+
});
|
|
310
|
+
// 札に付く線の端:縦書きは札の上の辺に左から、横書きは札の左の辺に上から並べる。
|
|
311
|
+
// 相手が左(上)にある線を先に、段の低い順に。相手が右(下)にある線は後に、段の高い順に(縦の線が横の線を横切らないように)
|
|
312
|
+
var ends = [];
|
|
313
|
+
this.links.forEach(function(o){
|
|
314
|
+
var A = chipOf[o.a.p.id], B = chipOf[o.b.p.id];
|
|
315
|
+
if (!A || !B) return;
|
|
316
|
+
var ca = tate ? (A.l + A.r) / 2 : (A.t + A.b) / 2, cb = tate ? (B.l + B.r) / 2 : (B.t + B.b) / 2;
|
|
317
|
+
o.ea = {link: o, chip: A, dir: cb < ca ? -1 : 1}; o.eb = {link: o, chip: B, dir: ca < cb ? -1 : 1};
|
|
318
|
+
A.at.push(o.ea); B.at.push(o.eb); ends.push(A, B);
|
|
319
|
+
});
|
|
320
|
+
ends.forEach(function(C){
|
|
321
|
+
if (C.done) return; C.done = true;
|
|
322
|
+
C.at.sort(function(p, q){ return p.dir !== q.dir ? p.dir - q.dir : p.dir < 0 ? p.link.lv - q.link.lv : q.link.lv - p.link.lv; });
|
|
323
|
+
var n = C.at.length;
|
|
324
|
+
C.at.forEach(function(e, i){
|
|
325
|
+
if (tate){ e.x = C.l + (C.r - C.l) * (i + 1) / (n + 1); e.y = C.t - 1; }
|
|
326
|
+
else { e.x = C.l - 1; e.y = C.t + (C.b - C.t) * (i + 1) / (n + 1); }
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
this.links.forEach(function(o){
|
|
330
|
+
if (!o.ea){ o.path.setAttribute("opacity", 0); o.h1.setAttribute("opacity", 0); if (o.h0) o.h0.setAttribute("opacity", 0); return; }
|
|
331
|
+
var e = pr(tro, tLink, P.draw), d, ang1, ang0, x0 = o.ea.x, y0 = o.ea.y, x1 = o.eb.x, y1 = o.eb.y, rr = 8;
|
|
332
|
+
if (tate){
|
|
333
|
+
// 札の上の辺から上へ出て、段の高さを横に通り、相手の札の上の辺へ下りる(角は丸める)
|
|
334
|
+
var top = Math.min(o.ea.chip.t, o.eb.chip.t), yl = top - STUB - (o.lv - 1) * STEP, sx = x1 < x0 ? -1 : 1;
|
|
335
|
+
d = "M" + f1(x0) + "," + f1(y0) + "V" + f1(yl + rr) + "Q" + f1(x0) + "," + f1(yl) + " " + f1(x0 + sx * rr) + "," + f1(yl) +
|
|
336
|
+
"H" + f1(x1 - sx * rr) + "Q" + f1(x1) + "," + f1(yl) + " " + f1(x1) + "," + f1(yl + rr) + "V" + f1(y1);
|
|
337
|
+
ang1 = 90; ang0 = 90;
|
|
338
|
+
} else {
|
|
339
|
+
// 札の左の辺から左へ出て、段の位置を縦に通り、相手の札の左の辺へ
|
|
340
|
+
var lft = Math.min(o.ea.chip.l, o.eb.chip.l), xl = lft - STUB - (o.lv - 1) * STEP, sy = y1 < y0 ? -1 : 1;
|
|
341
|
+
d = "M" + f1(x0) + "," + f1(y0) + "H" + f1(xl + rr) + "Q" + f1(xl) + "," + f1(y0) + " " + f1(xl) + "," + f1(y0 + sy * rr) +
|
|
342
|
+
"V" + f1(y1 - sy * rr) + "Q" + f1(xl) + "," + f1(y1) + " " + f1(xl + rr) + "," + f1(y1) + "H" + f1(x1);
|
|
343
|
+
ang1 = 0; ang0 = 0;
|
|
344
|
+
}
|
|
345
|
+
o.path.setAttribute("d", d);
|
|
346
|
+
o.path.setAttribute("stroke-dasharray", "1"); o.path.setAttribute("stroke-dashoffset", (1 - e).toFixed(4));
|
|
347
|
+
o.path.setAttribute("opacity", fO ? PV : e > 0 ? 1 : 0);
|
|
348
|
+
o.h1.setAttribute("transform", "translate(" + f1(x1) + " " + f1(y1) + ") rotate(" + ang1 + ")");
|
|
349
|
+
o.h1.setAttribute("opacity", fO ? PV : e >= 0.98 ? 1 : 0);
|
|
350
|
+
if (o.h0){ o.h0.setAttribute("transform", "translate(" + f1(x0) + " " + f1(y0) + ") rotate(" + ang0 + ")"); o.h0.setAttribute("opacity", fO ? PV : e >= 0.98 ? 1 : 0); }
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
});
|
|
@@ -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`.
|