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,233 @@
|
|
|
1
|
+
// m-seq:観測を 1 つずつ加えて、分布(事後分布など)と数値が更新されていく様子を見せる
|
|
2
|
+
// <m-seq per-step="2" style="height:400px"><script type="application/json">
|
|
3
|
+
// {"xs":[…], "steps":[{"dens":[…], "readout":{"n":0,"μ_n":0.00}}, {"dens":[…], "readout":{…}, "mark":1.2}, …],
|
|
4
|
+
// "xl":"*θ*", "yl":"密度", "yr":[0,2], "digits":{"n":0}, "markLabel":"*y*_n"}
|
|
5
|
+
// (JSON の終わり)</m-seq>
|
|
6
|
+
// steps[0] は始めの状態(段階 0)。steps[1..] が 1 回ずつの更新。1 段階に per-step 回の更新を、等しい時間枠で順に動かす。
|
|
7
|
+
// 今の分布は濃く、前の分布は薄い線で残す。右の欄に readout の数値(桁をそろえる)。mark は今回の観測の位置
|
|
8
|
+
// 2.0(Egatari spec §6.1 の部品):base の MotionElement・el・mtext・prog・lerp・previewOpacity と plot の Plot を使い、プレイヤーのグローバルは使わない
|
|
9
|
+
egatariParts.define({name: "seq", version: "2.0.5", requires: {base: "1.2.0", plot: "1.1.2"}, element: "m-seq"}, function(deps){
|
|
10
|
+
"use strict";
|
|
11
|
+
var base = deps.base, plot = deps.plot;
|
|
12
|
+
// 点列の d。null の所で線を切り、次の有限な点から M で引き直す(plot の p.d と同じ字。切れ目がなければ同じ d)
|
|
13
|
+
function pathOf(pts){
|
|
14
|
+
var d = "", pen = false;
|
|
15
|
+
pts.forEach(function(q){ if (q){ d += (pen ? "L" : "M") + q[0].toFixed(1) + "," + q[1].toFixed(1); pen = true; } else pen = false; });
|
|
16
|
+
return d;
|
|
17
|
+
}
|
|
18
|
+
// 線分 s = [[x, y], [x, y]] が箱 r = [x0, y0, x1, y1] にかかるか(Liang–Barsky)
|
|
19
|
+
function segHitsBox(s, r){
|
|
20
|
+
var x = s[0][0], y = s[0][1], dx = s[1][0] - x, dy = s[1][1] - y, t0 = 0, t1 = 1;
|
|
21
|
+
var pp = [-dx, dx, -dy, dy], qq = [x - r[0], r[2] - x, y - r[1], r[3] - y];
|
|
22
|
+
for (var i = 0; i < 4; i++){
|
|
23
|
+
if (pp[i] === 0){ if (qq[i] < 0) return false; continue; }
|
|
24
|
+
var u = qq[i] / pp[i];
|
|
25
|
+
if (pp[i] < 0){ if (u > t1) return false; if (u > t0) t0 = u; }
|
|
26
|
+
else { if (u < t0) return false; if (u < t1) t1 = u; }
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
// 灰色の線の名前の置き場所:その線の上に、線の点を中心にして置く(字は背景色の縁取りで線を切るので、どの線の名前か読める)。
|
|
31
|
+
// bd(字を置ける範囲)の中で、置いた字(boxes)に重ならず、ほかの線(lines:点列の配列。cl の中だけ描かれる)にかかる数が最も少なく、
|
|
32
|
+
// 自分の線が字の高さの中に収まり(平らな所)、ほかの線から離れている所(40 px まで)。w は字の幅の見積もり、fs は字の大きさ。置けなければ null
|
|
33
|
+
function placeOn(own, w, fs, lines, boxes, bd, cl){
|
|
34
|
+
var best = null, bc = Infinity;
|
|
35
|
+
var hits = function(L, r){
|
|
36
|
+
var q = [Math.max(r[0], cl[0]), Math.max(r[1], cl[1]), Math.min(r[2], cl[2]), Math.min(r[3], cl[3])];
|
|
37
|
+
if (q[0] >= q[2] || q[1] >= q[3]) return false;
|
|
38
|
+
for (var i = 1; i < L.length; i++) if (L[i - 1] && L[i] && segHitsBox([L[i - 1], L[i]], q)) return true;
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
for (var j = 0; j < own.length; j += 3){
|
|
42
|
+
var q = own[j];
|
|
43
|
+
if (!q || q[0] < cl[0] || q[0] > cl[2] || q[1] < cl[1] || q[1] > cl[3]) continue; // 描かれている点だけ
|
|
44
|
+
// 横軸や上の端に沿う線では、字を範囲の中へ上下にずらす(線のすぐ上・下になる)
|
|
45
|
+
var y = q[1] + fs * 0.33;
|
|
46
|
+
y = Math.max(bd[1] + fs * 0.88, Math.min(bd[3] - fs * 0.22, y));
|
|
47
|
+
var r = [q[0] - w / 2, y - fs * 0.88, q[0] + w / 2, y + fs * 0.22];
|
|
48
|
+
if (r[0] < bd[0] || r[2] > bd[2]) continue;
|
|
49
|
+
if (boxes.some(function(b){ return r[0] < b[2] + 6 && b[0] < r[2] + 6 && r[1] < b[3] + 4 && b[1] < r[3] + 4; })) continue;
|
|
50
|
+
// ほかの線にかかれば 1 本につき 1000。自分の線が字の幅の間に字の高さより大きく上下すれば 300
|
|
51
|
+
var c = 0, r3 = [r[0] - 3, r[1] - 3, r[2] + 3, r[3] + 3], gap = 40, lo = Infinity, hi = -Infinity;
|
|
52
|
+
own.forEach(function(z){ if (z && z[0] >= r[0] && z[0] <= r[2]){ lo = Math.min(lo, z[1]); hi = Math.max(hi, z[1]); } });
|
|
53
|
+
if (hi - lo > fs * 0.9) c += 300;
|
|
54
|
+
lines.forEach(function(L){
|
|
55
|
+
if (L === own) return;
|
|
56
|
+
if (hits(L, r3)){ c += 1000; return; }
|
|
57
|
+
L.forEach(function(z){
|
|
58
|
+
if (z && z[0] >= cl[0] && z[0] <= cl[2] && z[1] >= cl[1] && z[1] <= cl[3]) gap = Math.min(gap, Math.hypot(Math.max(r[0] - z[0], 0, z[0] - r[2]), Math.max(r[1] - z[1], 0, z[1] - r[3])));
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
c += 40 - gap + (hi - lo) / fs;
|
|
62
|
+
if (c < bc){ bc = c; best = {x: q[0], y: y, box: r}; }
|
|
63
|
+
}
|
|
64
|
+
return best;
|
|
65
|
+
}
|
|
66
|
+
return class extends base.MotionElement {
|
|
67
|
+
static partName = "seq"; // the registry name (define meta name), for report prefixes
|
|
68
|
+
// データの形(kit/shape.js)。軸の設定(xl yl yr など)も JSON に書ける
|
|
69
|
+
static shape = {
|
|
70
|
+
schema: {type: "object", required: ["xs", "steps"], properties: {
|
|
71
|
+
xs: {type: "array", minItems: 2, items: {type: "number"}},
|
|
72
|
+
steps: {type: "array", minItems: 1, items: {type: "object", required: ["dens"], properties: {dens: {type: "array", items: {type: "number"}}, readout: {type: "object"}, mark: {type: "number"}}}},
|
|
73
|
+
digits: {type: "object"}, markLabel: {type: "string"}}},
|
|
74
|
+
example: {xs: [-2, -1, 0, 1, 2], steps: [{dens: [0.05, 0.24, 0.4, 0.24, 0.05], readout: {n: 0}}, {dens: [0.02, 0.2, 0.5, 0.2, 0.02], readout: {n: 1}, mark: 0.3}]},
|
|
75
|
+
};
|
|
76
|
+
static props = {
|
|
77
|
+
"per-step": {type: "number", default: 1, doc: "1 ステップで動かす更新の回数"},
|
|
78
|
+
slot: {type: "number", default: 0.9, doc: "更新 1 回の秒数(cues はこの間隔)"},
|
|
79
|
+
xr: {type: "json", default: null, doc: "横軸の範囲(既定は xs の端)"}, yr: {type: "json", default: [0, 1]},
|
|
80
|
+
xt: {type: "json", default: []}, yt: {type: "json", default: []},
|
|
81
|
+
xf: {type: "number", default: undefined}, yf: {type: "number", default: undefined},
|
|
82
|
+
xl: {type: "string", default: ""}, yl: {type: "string", default: ""},
|
|
83
|
+
digits: {type: "number", default: 2, doc: "数値の小数の桁数(data.digits で名前ごとに上書き)"},
|
|
84
|
+
panel: {type: "number", default: 250, doc: "右の数値の欄の幅(px)"},
|
|
85
|
+
ghosts: {type: "number", default: 99, doc: "残す前の分布の数"},
|
|
86
|
+
};
|
|
87
|
+
// 属性があれば属性、なければ data の同名の値、なければ既定
|
|
88
|
+
opt(name){ var d = this.data || {}; return this.hasAttribute(name) || d[name] === undefined ? this.props[name] : d[name]; }
|
|
89
|
+
get updates(){ return Math.max(0, ((this.data || {}).steps || []).length - 1); }
|
|
90
|
+
get steps(){ return this.getAttribute("steps") !== null ? +this.getAttribute("steps") : Math.ceil(this.updates / this.props["per-step"]); }
|
|
91
|
+
mount(ctx){
|
|
92
|
+
var D = base, self = this, data = this.data, xs = data.xs;
|
|
93
|
+
this.classList.add("plot"); this.style.display = "block";
|
|
94
|
+
var xr = this.opt("xr") || [xs[0], xs[xs.length - 1]], pw = this.opt("panel");
|
|
95
|
+
var p = this.p = plot.Plot(this, {xr: xr, yr: this.opt("yr"), xt: this.opt("xt"), yt: this.opt("yt"), xf: this.opt("xf"), yf: this.opt("yf"),
|
|
96
|
+
xl: this.opt("xl"), yl: this.opt("yl"), m: {l: 86, r: pw + 16, t: 24, b: 64}});
|
|
97
|
+
// 密度の点列(px)。有限でない値(NaN・±Infinity・足りない値)の点は null で、線はそこで切る
|
|
98
|
+
this.pts = function(dens){ return xs.map(function(x, i){ var X = p.x(x), Y = p.y(dens[i]); return typeof dens[i] === "number" && isFinite(X) && isFinite(Y) ? [X, Y] : null; }); };
|
|
99
|
+
var bad = [];
|
|
100
|
+
data.steps.forEach(function(s, i){ if (self.pts(s.dens).indexOf(null) >= 0) bad.push(i); });
|
|
101
|
+
if (bad.length) ctx.report("data", "[seq] steps " + bad.join(", ") + ": dens has values that are not finite numbers (NaN, ±Infinity or missing for some xs); the curve is broken there");
|
|
102
|
+
// 塗り(今の分布の下)→ 前の分布の薄い線 → 今の分布の線 の順に重ねる
|
|
103
|
+
this.area = D.el("path", {fill: "var(--term-tint)", stroke: "none", "clip-path": p.clip}, p.svg);
|
|
104
|
+
var gG = D.el("g", {"clip-path": p.clip}, p.svg);
|
|
105
|
+
this.ghostEls = data.steps.map(function(s){
|
|
106
|
+
var e = D.el("path", {fill: "none", stroke: "var(--line)", "stroke-width": 2.5, opacity: 0}, gG);
|
|
107
|
+
e.setAttribute("d", pathOf(self.pts(s.dens)));
|
|
108
|
+
return e;
|
|
109
|
+
});
|
|
110
|
+
this.cur = D.el("path", {fill: "none", stroke: "var(--term)", "stroke-width": 3.5, "stroke-linejoin": "round", "clip-path": p.clip}, p.svg);
|
|
111
|
+
// 観測の印:今回は縦の点線と名前、前の観測は横軸の上の小さな点
|
|
112
|
+
this.dots = data.steps.map(function(s){
|
|
113
|
+
return s.mark === undefined ? null : D.el("circle", {cx: p.x(s.mark), cy: p.H - p.m.b - 7, r: 6, fill: "var(--muted)", opacity: 0}, p.svg);
|
|
114
|
+
});
|
|
115
|
+
this.markLine = D.el("line", {x1: 0, x2: 0, y1: p.m.t + 34, y2: p.H - p.m.b, stroke: "var(--emph)", "stroke-width": 2.5, "stroke-dasharray": "7 6", opacity: 0}, p.svg);
|
|
116
|
+
this.markLab = D.mtext(p.svg, 0, p.m.t + 24, data.markLabel || "", {"text-anchor": "middle", fill: "var(--emph)", "font-size": 26, opacity: 0});
|
|
117
|
+
// 数値の欄(名前は左寄せ、値は右寄せ。等幅の数字)
|
|
118
|
+
var keys = Object.keys(data.steps[0].readout || {}), px = p.W - pw + 8, px2 = p.W - 8;
|
|
119
|
+
D.el("rect", {x: px - 8, y: p.m.t, width: pw, height: 40 + keys.length * 44, rx: 10, fill: "var(--term-tint)", stroke: "var(--line)", "stroke-width": 1.5}, p.svg);
|
|
120
|
+
this.rows = keys.map(function(key, j){
|
|
121
|
+
var y = p.m.t + 44 + j * 44;
|
|
122
|
+
D.mtext(p.svg, px + 12, y, key, {"font-size": 28});
|
|
123
|
+
var v = D.el("text", {x: px2 - 12, y: y, "text-anchor": "end", "font-size": 28, style: "font-variant-numeric:tabular-nums;font-feature-settings:'tnum'"}, p.svg);
|
|
124
|
+
return {key: key, el: v, dg: (data.digits || {})[key] !== undefined ? data.digits[key] : self.props.digits};
|
|
125
|
+
});
|
|
126
|
+
// readout に書いていない名前は、前の値のまま出す(1 回だけ知らせる)
|
|
127
|
+
var miss = [];
|
|
128
|
+
keys.forEach(function(key){
|
|
129
|
+
var at = []; data.steps.forEach(function(s, i){ if ((s.readout || {})[key] === undefined) at.push(i); });
|
|
130
|
+
if (at.length) miss.push(JSON.stringify(key) + " (steps " + at.join(", ") + ")");
|
|
131
|
+
});
|
|
132
|
+
if (miss.length) ctx.report("data", "[seq] readout has no value for " + miss.join(", ") + "; the previous value is shown");
|
|
133
|
+
// 灰色の線(前の分布)の名前「n = 3」:最後の段階で残る線に、--muted の 24px で線の上に(背景色で縁取って)書く。
|
|
134
|
+
// 5 本以上なら最初と最後だけ。n は readout の n(*n* など、字が n の名前)の値、なければ更新の回数。
|
|
135
|
+
// 置き場所は最後の段階の形(今の線・灰色の線・観測の印)で決め、その線が灰色で見えている間だけ出す
|
|
136
|
+
var last = this.updates, G = this.props.ghosts, fs = 24, nk = null;
|
|
137
|
+
keys.forEach(function(key){ if (nk === null && key.replace(/[*_^]/g, "") === "n") nk = key; });
|
|
138
|
+
var wOf = function(str){ return D.textWidth(str, fs, {font: self, mark: true}); }; // base の textWidth(記法の * _ ^ を除く)
|
|
139
|
+
var shown = [];
|
|
140
|
+
for (var i = Math.max(0, last - G); i < last; i++) shown.push(i);
|
|
141
|
+
if (shown.length > 4) shown = [shown[0], shown[shown.length - 1]];
|
|
142
|
+
var gp = data.steps.map(function(s){ return self.pts(s.dens); });
|
|
143
|
+
var lines = [gp[last]].concat(gp.slice(Math.max(0, last - G), last)), lm = data.steps[last].mark, boxes = [];
|
|
144
|
+
if (lm !== undefined && last > 0){
|
|
145
|
+
lines.push([[p.x(lm), p.m.t + 34], [p.x(lm), p.H - p.m.b]]);
|
|
146
|
+
var mw = wOf(data.markLabel || "") * 26 / 24;
|
|
147
|
+
boxes.push([p.x(lm) - mw / 2, p.m.t + 24 - 26 * 0.88, p.x(lm) + mw / 2, p.m.t + 24 + 26 * 0.22]);
|
|
148
|
+
}
|
|
149
|
+
data.steps.forEach(function(s, i){ if (s.mark !== undefined && i < last) boxes.push([p.x(s.mark) - 6, p.H - p.m.b - 13, p.x(s.mark) + 6, p.H - p.m.b - 1]); });
|
|
150
|
+
var bd = [p.m.l + 4, 4, p.W - pw - 16, p.H - p.m.b - 2], cl = [p.m.l, p.m.t - 4, p.W - pw - 16, p.H - p.m.b];
|
|
151
|
+
this.glabs = [];
|
|
152
|
+
shown.forEach(function(i){
|
|
153
|
+
var v = nk !== null ? (data.steps[i].readout || {})[nk] : i;
|
|
154
|
+
if (v === undefined) v = i;
|
|
155
|
+
var dg = nk !== null && (data.digits || {})[nk] !== undefined ? data.digits[nk] : 0;
|
|
156
|
+
var str = (nk !== null ? nk : "*n*") + " = " + (typeof v === "number" ? v.toFixed(dg).replace("-", "−") : String(v));
|
|
157
|
+
var at = placeOn(gp[i], wOf(str), fs, lines, boxes, bd, cl);
|
|
158
|
+
if (!at){ ctx.report("layout", "[seq] no free place for the name of the grey curve " + JSON.stringify(str) + " (not drawn)"); return; }
|
|
159
|
+
boxes.push(at.box);
|
|
160
|
+
self.glabs.push({i: i, el: D.mtext(p.svg, +at.x.toFixed(1), +at.y.toFixed(1), str, {"text-anchor": "middle", fill: "var(--muted)", stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", "font-size": fs, opacity: 0})});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
// 段階 i までで readout の key に最後に書かれた値(なければ undefined)
|
|
164
|
+
valAt(i, key){ var S = this.data.steps; for (; i >= 0; i--){ var v = (S[i].readout || {})[key]; if (v !== undefined) return v; } return undefined; }
|
|
165
|
+
// 段階 k が受け持つ更新の番号 [first, last]
|
|
166
|
+
span(k){ var P = this.props["per-step"]; return [(k - 1) * P + 1, Math.min(k * P, this.updates)]; }
|
|
167
|
+
duration(k){ if (k < 1) return 0; var s = this.span(k); return Math.max(0, s[1] - s[0] + 1) * this.props.slot; }
|
|
168
|
+
cues(k){
|
|
169
|
+
if (k < 1) return null;
|
|
170
|
+
var s = this.span(k), out = [];
|
|
171
|
+
for (var j = 0; j <= s[1] - s[0]; j++) out.push(+(j * this.props.slot).toFixed(4));
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
render(k, t, ctx){
|
|
175
|
+
var D = base, S = this.data.steps, p = this.p, slot = this.props.slot;
|
|
176
|
+
var preview = !!ctx.preview, PV = preview ? base.previewOpacity(this) : 1;
|
|
177
|
+
|
|
178
|
+
// 今の更新の番号 idx と、その更新の進み具合 e(0 なら一つ前の状態、1 なら更新後)
|
|
179
|
+
var idx = 0, e = 1, tm = 0;
|
|
180
|
+
if (k >= 1){
|
|
181
|
+
var s = this.span(k), n = s[1] - s[0] + 1;
|
|
182
|
+
if (t === Infinity){ idx = s[1]; tm = Infinity; }
|
|
183
|
+
else { var j = Math.max(0, Math.min(n - 1, Math.floor(t / slot))); idx = s[0] + j; tm = t - j * slot; }
|
|
184
|
+
e = D.prog(tm, 0, slot * 0.8);
|
|
185
|
+
}
|
|
186
|
+
var a = S[Math.max(0, idx - 1)], b = S[idx];
|
|
187
|
+
// 前後のどちらかが有限でなければ補間せず、動き終わり(e = 1)は後の値、始め(e = 0)は前の値
|
|
188
|
+
var dens = this.data.xs.map(function(_, i){
|
|
189
|
+
var A = a.dens[i], B = b.dens[i];
|
|
190
|
+
return typeof A === "number" && typeof B === "number" && isFinite(A) && isFinite(B) ? D.lerp(A, B, e) : e >= 1 ? B : e <= 0 ? A : NaN;
|
|
191
|
+
});
|
|
192
|
+
// 線は有限な区間ごとに引き、塗りも区間ごとに横軸まで閉じる(切れ目がなければ今までと同じ d)
|
|
193
|
+
var q = this.pts(dens), d = pathOf(q), ar = "", y0 = p.y(0).toFixed(1);
|
|
194
|
+
for (var i = 0; i < q.length; i++){
|
|
195
|
+
if (!q[i]) continue;
|
|
196
|
+
var j = i; while (j + 1 < q.length && q[j + 1]) j++;
|
|
197
|
+
ar += pathOf(q.slice(i, j + 1)) + "L" + q[j][0].toFixed(1) + "," + y0 + "L" + q[i][0].toFixed(1) + "," + y0 + "Z";
|
|
198
|
+
i = j;
|
|
199
|
+
}
|
|
200
|
+
this.cur.setAttribute("d", d);
|
|
201
|
+
this.area.setAttribute("d", ar);
|
|
202
|
+
var G = this.props.ghosts, last = this.updates, end = this.span(k)[1];
|
|
203
|
+
// 先の段階を薄く見せる表示(授業の表示):後の段階の終わりの分布を今の線の色で、後の観測の点とともに、
|
|
204
|
+
// テーマの --preview-opacity の濃さに(途中の分布は重ねない)
|
|
205
|
+
var ahead = function(i){ return preview && i > Math.max(idx, k >= 1 ? end : 0); };
|
|
206
|
+
this.ghostEls.forEach(function(g, i){
|
|
207
|
+
var f = ahead(i) && i === last;
|
|
208
|
+
var col = f ? "var(--term)" : "var(--line)";
|
|
209
|
+
// style は base.el と同じ書き方で書く(style.stroke に代入すると "stroke: var(--x);" になり、作った直後と字が変わる)
|
|
210
|
+
g.setAttribute("style", "stroke:" + col + ";");
|
|
211
|
+
g.setAttribute("opacity", f ? PV : i < idx && i >= idx - G ? 1 : 0);
|
|
212
|
+
});
|
|
213
|
+
this.dots.forEach(function(c, i){ if (c) c.setAttribute("opacity", ahead(i) ? PV : i < idx ? 1 : 0); });
|
|
214
|
+
var mo = b.mark !== undefined && idx > 0 ? D.prog(tm, 0, 0.25) : 0;
|
|
215
|
+
// 印のない段階では作った直後の位置(0)に戻す(前の段階の位置を残さない。docs/contract.md §3)
|
|
216
|
+
var mx = b.mark !== undefined ? p.x(b.mark) : 0;
|
|
217
|
+
this.markLine.setAttribute("x1", mx); this.markLine.setAttribute("x2", mx); this.markLab.setAttribute("x", mx);
|
|
218
|
+
this.markLine.setAttribute("opacity", mo.toFixed(3));
|
|
219
|
+
this.markLab.setAttribute("opacity", mo.toFixed(3));
|
|
220
|
+
var self = this, ia = Math.max(0, idx - 1);
|
|
221
|
+
this.rows.forEach(function(r){
|
|
222
|
+
// 書いていない値は前の段階の値(桁もそろえる)
|
|
223
|
+
var va = self.valAt(ia, r.key), vb = self.valAt(idx, r.key), v;
|
|
224
|
+
if (typeof va === "number" && typeof vb === "number") v = D.lerp(va, vb, e);
|
|
225
|
+
else v = e < 0.5 && va !== undefined ? va : vb;
|
|
226
|
+
v = typeof v === "number" ? v.toFixed(r.dg).replace("-", "−") : String(v);
|
|
227
|
+
r.el.textContent = v === "−0" || /^−0\.0*$/.test(v) ? v.slice(1) : v;
|
|
228
|
+
});
|
|
229
|
+
// 灰色の線の名前は、その線が灰色で見えている間だけ
|
|
230
|
+
this.glabs.forEach(function(o){ o.el.setAttribute("opacity", !ahead(o.i) && o.i < idx && o.i >= idx - G ? 1 : 0); });
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: Timeline; events one by one; periods as bands, overlaps stacked; end exclusive ("1912" = start of 1912)
|
|
3
|
+
steps: event count (default 1 per step in time order; per-step n each; node step wins)
|
|
4
|
+
props:
|
|
5
|
+
orient: h or v
|
|
6
|
+
scale: time or even
|
|
7
|
+
per-step: events per step (0 = all)
|
|
8
|
+
size: label px (shrinks to 24)
|
|
9
|
+
dur: event appear (s)
|
|
10
|
+
stagger: event offset (s)
|
|
11
|
+
unit: ticks: day, week, month
|
|
12
|
+
today: today line (YYYY-MM-DD)
|
|
13
|
+
example: {"nodes": [{"id": "a", "label": "Meiji Restoration", "when": "1868", "whenLabel": "Meiji 1"}, {"id": "b", "label": "Constitution", "when": "1889", "note": "Feb 11"}, {"id": "c", "label": "Sino-Japanese War", "when": "1894", "end": "1895", "tone": "emph"}]}
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
History, lives, schedules. No coordinates; content and times only.
|
|
17
|
+
|
|
18
|
+
Child JSON: `{"nodes": [...], "edges": [...]}` (`edges` optional).
|
|
19
|
+
|
|
20
|
+
- `when`: number (`1868`, `-500`, `0.5`) or `"YYYY"` `"YYYY-MM"` `"YYYY-MM-DD"`; shown as the date line
|
|
21
|
+
- `whenLabel`: text replacing the date ("Meiji 1"); `when` still sets position
|
|
22
|
+
- `label` (`\n`) or `tex` (KaTeX)
|
|
23
|
+
- `note`: small last line in the box (`--muted`); after the name for periods/milestones
|
|
24
|
+
- `tone`: `term` (default), `emph`, `muted`, `accent2`, `series-1..4`
|
|
25
|
+
- `end`: period, a band below the axis; name inside (or beside); `\n` names thicken it
|
|
26
|
+
- `end` is exclusive: Meiji 1868–1912 and Taishō 1912–1926 share a row; through December = next month (`"2027-01"`)
|
|
27
|
+
- `lane`: named group of rows ("Eras", "Authors"); overlaps stack within; `lane` without `end` = milestone (◆)
|
|
28
|
+
- `step`, `at` (start s)
|
|
29
|
+
- `edges`: extra links (`from` `to` `label` `tone` `dash` `step`); dashed arrows (`dash: false` solid)
|
|
30
|
+
- Schedules: `after: ["id", …]` (arrow end→start), `progress` (0–100 %); `today` line; tick `unit`
|
|
31
|
+
- `after` only between periods and milestones; `today` needs a period
|
|
32
|
+
|
|
33
|
+
Layout:
|
|
34
|
+
|
|
35
|
+
- `orient`: `h` (default) or `v`; `scale`: `time` (default) or `even` (very uneven gaps)
|
|
36
|
+
- Events (no `end` or `lane`): axis dot plus date-and-name box, alternating sides (`v`: left/right); 2 rows when crowded
|
|
37
|
+
- With periods: round ticks; event boxes all above the axis
|
|
38
|
+
- Steps: time order, periods and events together; the axis comes with the first
|
|
39
|
+
- `variant`: `fade` (default), `draw` (lines first, bands drawn), `grow` (boxes grow, bands stretch); same steps and end
|
|
40
|
+
- Show later steps faintly (`ctx.preview`): later items faint
|
|
41
|
+
- `cues(k)`: start times of 2nd+ items in a step (for `{cue}`)
|
|
42
|
+
|
|
43
|
+
The demo is `demo.html`; the schedule is fictional, years are history.
|
|
44
|
+
|
|
45
|
+
<!-- llm: omit -->
|
|
46
|
+
Notes
|
|
47
|
+
|
|
48
|
+
- Box and tick widths estimated from characters (CJK 1, digits 0.6, Latin 0.62)
|
|
49
|
+
- No fit: names shrink from `size` by 2px to 24px, then `ctx.report("size", …)`
|
|
50
|
+
- No `Date` (leap years computed); months and days as positions in the year
|
|
51
|
+
- Band names sit in the band's `g`
|
|
52
|
+
- Axis `--muted` 5 px; lane dividers `--line`; links and `edges` `--muted` 3 px
|
|
53
|
+
- Motion: boxes and bands move ≤ 12 px from the axis side, within `fade` time (conventions §1.2)
|
|
54
|
+
<!-- llm: end -->
|
|
55
|
+
|
|
56
|
+
<!-- llm: omit -->
|
|
57
|
+
Schedules (`after`, `progress`, `today`, `unit`)
|
|
58
|
+
|
|
59
|
+
- Any `after`: one row per task in each lane (written order). Arrows only between periods and milestones (others reported)
|
|
60
|
+
- Arrows (`--muted` 3px, right-angled) from a task's end to the next one's start; drawn with the later task; avoid crossing bands where possible
|
|
61
|
+
- A last milestone gets room for its name; arrows to bands whose name is left of the start enter at the edge
|
|
62
|
+
- `progress`: band filled darker from the start; "70%" shown if room; outside 0–100 clamped and reported
|
|
63
|
+
- `today`: only with periods (else reported); small triangle and vertical line (`--accent2`, 3px), "Today" below; range widens to include it
|
|
64
|
+
- `unit`: default month (≤ 4 years with months/days) or round numbers. `day`: 1–2 days or 1–8 weeks (Mondays); `week`: 1–26 weeks; `month`: 1–120 months; finest step whose 24px labels don't overlap; minor ticks unlabeled. Day/week labels "11/2"; `day` shades weekends (`--line`)
|
|
65
|
+
- No plan-vs-actual bands yet
|
|
66
|
+
<!-- llm: end -->
|