@cardenelabs/dragon 0.43.0 → 0.45.0
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/README.md +21 -0
- package/dist/cli.cjs +6804 -5032
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +6804 -5032
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +7172 -5536
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +7171 -5537
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +12244 -10449
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +12244 -10449
- package/dist/index.js.map +1 -1
- package/dist/{ink-B6s_SMXG.d.cts → ink-DeDtzaTL.d.cts} +27 -3
- package/dist/{ink-B6s_SMXG.d.ts → ink-DeDtzaTL.d.ts} +27 -3
- package/dist/light/chunk-6ZUKJ3VO.js +489 -0
- package/dist/light/chunk-6ZUKJ3VO.js.map +1 -0
- package/dist/light/chunk-CLS6JVKK.cjs +84 -0
- package/dist/light/chunk-CLS6JVKK.cjs.map +1 -0
- package/dist/light/chunk-JNSHZTPF.js +1141 -0
- package/dist/light/chunk-JNSHZTPF.js.map +1 -0
- package/dist/light/chunk-OUQ44P45.cjs +489 -0
- package/dist/light/chunk-OUQ44P45.cjs.map +1 -0
- package/dist/light/chunk-VRAW7VAQ.cjs +1141 -0
- package/dist/light/chunk-VRAW7VAQ.cjs.map +1 -0
- package/dist/light/chunk-YDKPEKGZ.js +84 -0
- package/dist/light/chunk-YDKPEKGZ.js.map +1 -0
- package/dist/light/git-C4RVNFT6.js +637 -0
- package/dist/light/git-C4RVNFT6.js.map +1 -0
- package/dist/light/git-I7D7RIW2.cjs +637 -0
- package/dist/light/git-I7D7RIW2.cjs.map +1 -0
- package/dist/light/index.cjs +9885 -0
- package/dist/light/index.cjs.map +1 -0
- package/dist/light/index.d.cts +976 -0
- package/dist/light/index.d.ts +976 -0
- package/dist/light/index.js +9885 -0
- package/dist/light/index.js.map +1 -0
- package/dist/light/lineup-FAIKTH3Y.cjs +283 -0
- package/dist/light/lineup-FAIKTH3Y.cjs.map +1 -0
- package/dist/light/lineup-YEG4HHEI.js +283 -0
- package/dist/light/lineup-YEG4HHEI.js.map +1 -0
- package/dist/light/state-P3LIVI3K.js +335 -0
- package/dist/light/state-P3LIVI3K.js.map +1 -0
- package/dist/light/state-ZZUK6AQT.cjs +335 -0
- package/dist/light/state-ZZUK6AQT.cjs.map +1 -0
- package/dist/light/time-64DJKYAL.cjs +719 -0
- package/dist/light/time-64DJKYAL.cjs.map +1 -0
- package/dist/light/time-B5WUQOFP.js +719 -0
- package/dist/light/time-B5WUQOFP.js.map +1 -0
- package/dist/light/tree-5HPREYW2.js +478 -0
- package/dist/light/tree-5HPREYW2.js.map +1 -0
- package/dist/light/tree-66EH4QVI.cjs +478 -0
- package/dist/light/tree-66EH4QVI.cjs.map +1 -0
- package/dist/node.cjs +1932 -680
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1932 -680
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +14 -2
- package/src/api.ts +71 -0
- package/src/field-messages.ts +6 -0
- package/src/figure-text.ts +4 -0
- package/src/index.ts +6 -65
- package/src/kinds/all.ts +16 -0
- package/src/kinds/git.ts +3 -0
- package/src/kinds/lineup.ts +3 -0
- package/src/kinds/registry.ts +46 -0
- package/src/kinds/state.ts +2 -0
- package/src/kinds/time.ts +3 -0
- package/src/kinds/tree.ts +3 -0
- package/src/layout/git.ts +0 -1
- package/src/layout/lineup.ts +218 -0
- package/src/layout/time.ts +0 -1
- package/src/layout/tree.ts +0 -1
- package/src/light.ts +31 -0
- package/src/look/values.ts +31 -2
- package/src/messages.ts +54 -0
- package/src/parser.ts +123 -1
- package/src/player-global.ts +3 -0
- package/src/player.ts +1 -1
- package/src/printer.ts +30 -1
- package/src/render/draw.ts +731 -0
- package/src/render/lineup.ts +184 -0
- package/src/render/parts.ts +19 -7
- package/src/render/svg.ts +4 -697
- package/src/render/time.ts +1 -4
- package/src/render/tree.ts +3 -2
- package/src/schema.ts +52 -4
- package/src/schemas/diagram.schema.json +145 -22
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +14 -0
- package/src/view.ts +1 -1
- package/src/words.ts +15 -2
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 列の図 (#3239) を描く部品。見た目の元は step 2 で本人が選んだ見本の「列の図」。
|
|
3
|
+
*
|
|
4
|
+
* 列の地と字は下の層に、チップと封と札は上の層に描く。チップが別の列へ滑る時に、途中の列の地の下へ隠れないため。
|
|
5
|
+
* チップは席に居る間ごとに 1 つの部品で、座った時に滑り始める所から席へ滑るか、弾んで現れる。席を離れる時は、同じ段で別の席へ滑るなら滑り始める時に一瞬で替わり、
|
|
6
|
+
* 別の席へ滑らないなら消えていく。
|
|
7
|
+
* 封は列の左から右へ伸び、覆い終えた時に列のチップを隠す。開ける時はチップを出してから封を消す。
|
|
8
|
+
* 列を選ぶと選んだ列の縁に色が付き、ほかの列を薄くする。薄くした列は、後の段で並びを書き換えるか選ぶと濃く戻る。
|
|
9
|
+
*/
|
|
10
|
+
import type { LineupAt, LineupLayout, LineupPick, LineupSeal, LineupSeat } from "../layout/lineup";
|
|
11
|
+
import { EASE, LOOK, MOTION, TYPE } from "../look/values";
|
|
12
|
+
import type { Diagram } from "../schema";
|
|
13
|
+
import type { Timeline } from "../timeline";
|
|
14
|
+
import { ALWAYS, type Shown } from "./ink";
|
|
15
|
+
import type { Frame } from "./motion";
|
|
16
|
+
import { type Ctx, cs, esc, type SubChange, subLines, write } from "./parts";
|
|
17
|
+
|
|
18
|
+
const r1 = (v: number): number => Math.round(v * 100) / 100;
|
|
19
|
+
|
|
20
|
+
/** 席から `(dx, dy)` ずらして大きさを `scale` 倍にした時の `transform` */
|
|
21
|
+
const place = (dx: number, dy: number, scale = 1): string => `translate(${r1(dx)}px,${r1(dy)}px) scale(${scale})`;
|
|
22
|
+
|
|
23
|
+
/** `span` から `holes` の間を抜いた間 */
|
|
24
|
+
const without = (span: Shown, holes: Shown[]): Shown[] =>
|
|
25
|
+
holes.reduce<Shown[]>((rest, [x, y]) => rest.flatMap(([a, b]): Shown[] => (y <= a || x >= b ? [[a, b]] : [...(a < x ? ([[a, x]] as Shown[]) : []), ...(y < b ? ([[y, b]] as Shown[]) : [])])), [span]);
|
|
26
|
+
|
|
27
|
+
export function drawLineup(layout: LineupLayout, diagram: Diagram, timeline: Timeline, ctx: Ctx, subs: Map<string, SubChange[]>): { lanes: string; chips: string } {
|
|
28
|
+
const { m } = ctx;
|
|
29
|
+
const N = LOOK.lineup;
|
|
30
|
+
const cut = MOTION.lineup.cut;
|
|
31
|
+
const timeOf = (at: LineupAt): { start: number; drawn: number } => timeline.edges.find((t) => t.step === at.step && t.event === at.event) ?? { start: 0, drawn: 0 };
|
|
32
|
+
const items = new Map((diagram.lineup?.items ?? []).map((item) => [item.id, item]));
|
|
33
|
+
|
|
34
|
+
// 列ごとの、薄くなるか濃く戻る時刻。列を選ぶ時に薄くし、並びを書き換えるか選ぶ時に濃く戻す
|
|
35
|
+
const turns = new Map<string, [number, boolean][]>(layout.lanes.map((lane) => [lane.id, []]));
|
|
36
|
+
const faint = new Set<string>();
|
|
37
|
+
const turn = (id: string, at: number, to: boolean): void => {
|
|
38
|
+
if (faint.has(id) === to) return;
|
|
39
|
+
if (to) faint.add(id);
|
|
40
|
+
else faint.delete(id);
|
|
41
|
+
turns.get(id)?.push([at, to]);
|
|
42
|
+
};
|
|
43
|
+
for (const time of [...timeline.edges].sort((a, b) => a.start - b.start)) {
|
|
44
|
+
const e = diagram.steps[time.step]?.events[time.event];
|
|
45
|
+
if (e?.type === "line") turn(e.box, time.start, false);
|
|
46
|
+
if (e?.type === "pick") for (const lane of layout.lanes) turn(lane.id, time.start, lane.id !== e.box);
|
|
47
|
+
}
|
|
48
|
+
/** 列の濃さの動き。薄くならない列は `undefined` */
|
|
49
|
+
const fadeOf = (id: string): string | undefined => {
|
|
50
|
+
const list = turns.get(id) ?? [];
|
|
51
|
+
if (list.length === 0) return undefined;
|
|
52
|
+
const frames: Frame[] = [[0, { opacity: 1 }]];
|
|
53
|
+
let now: number = 1;
|
|
54
|
+
for (const [t, to] of list) {
|
|
55
|
+
const next = to ? N.faint : 1;
|
|
56
|
+
frames.push([t, { opacity: now }, EASE.inOut], [t + MOTION.fade, { opacity: next }]);
|
|
57
|
+
now = next;
|
|
58
|
+
}
|
|
59
|
+
frames.push([m.last, { opacity: now }, EASE.inOut], [m.total, { opacity: 1 }]);
|
|
60
|
+
return m.kf(frames);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** 封が列を隠す間。覆い終えてから開けるまで */
|
|
64
|
+
const closedOf = (seal: LineupSeal): Shown => [timeOf(seal).drawn, seal.until ? timeOf(seal.until).start : Number.POSITIVE_INFINITY];
|
|
65
|
+
|
|
66
|
+
/** 列のチップを隠す動き。封の無い列は `undefined` */
|
|
67
|
+
const hideOf = (seals: LineupSeal[]): string | undefined => {
|
|
68
|
+
if (seals.length === 0) return undefined;
|
|
69
|
+
const frames: Frame[] = [[0, { opacity: 1 }]];
|
|
70
|
+
for (const seal of seals) {
|
|
71
|
+
const [a, b] = closedOf(seal);
|
|
72
|
+
frames.push([a, { opacity: 1 }], [a + cut, { opacity: 0 }]);
|
|
73
|
+
if (seal.until) frames.push([b, { opacity: 0 }], [b + cut, { opacity: 1 }]);
|
|
74
|
+
}
|
|
75
|
+
frames.push([m.total - cut, { opacity: seals.at(-1)?.until ? 1 : 0 }], [m.total, { opacity: 1 }]);
|
|
76
|
+
return m.kf(frames);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const sealKf = (seal: LineupSeal): string => {
|
|
80
|
+
const { start, drawn } = timeOf(seal);
|
|
81
|
+
const none = { opacity: 0, transform: "scaleX(0)" };
|
|
82
|
+
const end: Frame[] = seal.until
|
|
83
|
+
? [
|
|
84
|
+
[timeOf(seal.until).start, { opacity: 1 }, EASE.inOut],
|
|
85
|
+
[timeOf(seal.until).start + MOTION.fade, { opacity: 0 }],
|
|
86
|
+
[m.total, { opacity: 0 }],
|
|
87
|
+
]
|
|
88
|
+
: [
|
|
89
|
+
[m.last, { opacity: 1 }, EASE.inOut],
|
|
90
|
+
[m.total, { opacity: 0 }],
|
|
91
|
+
];
|
|
92
|
+
return m.kf([[0, none], [start - cut, none], [start, { opacity: 1, transform: "scaleX(0)" }, EASE.inOut], [drawn, { transform: "scaleX(1)" }], ...end]);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** 席を離れた同じ出来事で、別の席へ滑るチップか */
|
|
96
|
+
/**
|
|
97
|
+
* チップが席を離れる時刻と、別の席へ滑って離れるか。席を離れる段の中で、この席から滑り始めるチップが在れば、滑り始める時に一瞬で替わる。
|
|
98
|
+
* 列の並びを書き換える出来事と、別の列へ滑る出来事の順は問わない。どちらが先でも、同じチップが 2 枚見える間と、1 枚も見えない間を作らない
|
|
99
|
+
*/
|
|
100
|
+
const leaving = (c: LineupSeat): { at: number; moved: boolean } | undefined => {
|
|
101
|
+
if (!c.until) return undefined;
|
|
102
|
+
const until = c.until;
|
|
103
|
+
const next = layout.chips.find((n) => n !== c && n.id === c.id && n.step === until.step && n.from?.[0] === c.x && n.from?.[1] === c.y);
|
|
104
|
+
return next ? { at: timeOf(next).start, moved: true } : { at: timeOf(until).start, moved: false };
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const chipKf = (c: LineupSeat): string => {
|
|
108
|
+
const a = timeOf(c).start;
|
|
109
|
+
const rest = place(0, 0);
|
|
110
|
+
const frames: Frame[] = [];
|
|
111
|
+
if (c.from) {
|
|
112
|
+
const off = place(c.from[0] - c.x, c.from[1] - c.y);
|
|
113
|
+
frames.push([0, { opacity: 0, transform: off }], [a - cut, { opacity: 0, transform: off }], [a, { opacity: 1, transform: off }, EASE.inOut], [a + MOTION.lineup.slide, { transform: rest }]);
|
|
114
|
+
} else {
|
|
115
|
+
const off = place(0, 0, LOOK.popFrom);
|
|
116
|
+
frames.push([0, { opacity: 0, transform: off }], [a, { opacity: 0, transform: off }, EASE.pop], [a + MOTION.popFade, { opacity: 1, transform: rest }]);
|
|
117
|
+
}
|
|
118
|
+
const leaves = leaving(c);
|
|
119
|
+
if (leaves) {
|
|
120
|
+
frames.push([leaves.at, { opacity: 1 }, EASE.inOut], [leaves.at + (leaves.moved ? cut : MOTION.fade), { opacity: 0 }], [m.total, { opacity: 0 }]);
|
|
121
|
+
} else {
|
|
122
|
+
frames.push([m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]);
|
|
123
|
+
}
|
|
124
|
+
return m.kf(frames);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const chip = (c: LineupSeat, closed: Shown[]): string => {
|
|
128
|
+
const item = items.get(c.id);
|
|
129
|
+
const color = item?.color;
|
|
130
|
+
const rect = `<rect class="${color ? "dg-ln-chip" : "dg-ln-plain"}" x="${r1(c.x)}" y="${r1(c.y)}" width="${r1(c.w)}" height="${c.h}" rx="${N.chip.radius}"/>`;
|
|
131
|
+
const shown = without([timeOf(c).start + MOTION.lineup.slide, leaving(c)?.at ?? Number.POSITIVE_INFINITY], closed);
|
|
132
|
+
const text = item?.label === undefined ? "" : write(ctx.ink, color ? "dg-ln-t" : "dg-ln-tp", c.x + c.w / 2, c.y + c.h / 2 + LOOK.baseline.tag, item.label, TYPE.chip, shown, "middle");
|
|
133
|
+
return `<g class="dg-popc dg-a" data-lineup-chip="${esc(c.id)}" data-lineup-on="${esc(c.lane)}" data-lineup-seat="${c.index}" style="${color ? `${cs(color)};` : ""}${chipKf(c)}">${rect}${text}</g>`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** 選んだ列の縁の色が見える間。次に別の列を選ぶまで */
|
|
137
|
+
const ring = (pick: LineupPick, next: LineupPick | undefined, frame: string): string =>
|
|
138
|
+
`<g class="dg-a" data-lineup-ring="${esc(pick.lane)}" style="${m.vis(timeOf(pick).start, next ? timeOf(next).start : m.last)}">${frame}</g>`;
|
|
139
|
+
|
|
140
|
+
const faded = new Map(layout.lanes.map((lane) => [lane.id, fadeOf(lane.id)]));
|
|
141
|
+
|
|
142
|
+
const lanes = layout.lanes
|
|
143
|
+
.map((lane) => {
|
|
144
|
+
const rect = (cls: string, extra = ""): string => `<rect class="${cls}" x="${r1(lane.x)}" y="${r1(lane.y)}" width="${r1(lane.w)}" height="${lane.h}" rx="${N.radius}"${extra}/>`;
|
|
145
|
+
const rings = layout.picks.flatMap((pick, k) => (pick.lane === lane.id ? [ring(pick, layout.picks[k + 1], `${rect("dg-halo")}${rect("dg-on")}`)] : [])).join("");
|
|
146
|
+
const notes = subLines(lane, m, subs.get(lane.id) ?? [], lane.title.baseline, ctx.ink, lane.noteRight);
|
|
147
|
+
const fade = faded.get(lane.id);
|
|
148
|
+
return (
|
|
149
|
+
`<g${fade ? ' class="dg-a"' : ""} data-lineup-lane="${esc(lane.id)}" style="${cs(lane.color)}${fade ? `;${fade}` : ""}">` +
|
|
150
|
+
`${rect("dg-st", ` ${ctx.sh}`)}${rings}${write(ctx.ink, "dg-sn", lane.title.x, lane.title.baseline, lane.name, TYPE.boxName, ALWAYS)}${notes}</g>`
|
|
151
|
+
);
|
|
152
|
+
})
|
|
153
|
+
.join("");
|
|
154
|
+
|
|
155
|
+
const stripes = N.seal.stripe;
|
|
156
|
+
const pattern = `<defs><pattern id="dg-seal-${ctx.id}" patternUnits="userSpaceOnUse" width="${stripes * 2}" height="${stripes * 2}" patternTransform="rotate(45)"><rect class="dg-ln-sl" width="${stripes * 2}" height="${stripes * 2}"/><rect class="dg-ln-sd" width="${stripes}" height="${stripes * 2}"/></pattern></defs>`;
|
|
157
|
+
|
|
158
|
+
const chips = layout.lanes
|
|
159
|
+
.map((lane) => {
|
|
160
|
+
const seals = layout.seals.filter((s) => s.lane === lane.id);
|
|
161
|
+
const closed = seals.map(closedOf);
|
|
162
|
+
const seats = layout.chips.filter((c) => c.lane === lane.id).map((c) => chip(c, closed)).join("");
|
|
163
|
+
const hide = hideOf(seals);
|
|
164
|
+
const track = `<g${hide ? ' class="dg-a"' : ""} data-lineup-track="${esc(lane.id)}"${hide ? ` style="${hide}"` : ""}>${seats}</g>`;
|
|
165
|
+
const covers = seals
|
|
166
|
+
.map((s) => `<rect class="dg-ln-seal dg-a" data-lineup-seal="${esc(lane.id)}" x="${r1(s.x)}" y="${r1(s.y)}" width="${r1(s.w)}" height="${r1(s.h)}" rx="${N.seal.radius}" fill="url(#dg-seal-${ctx.id})" style="${sealKf(s)}"/>`)
|
|
167
|
+
.join("");
|
|
168
|
+
const stamps = layout.stamps
|
|
169
|
+
.filter((s) => s.lane === lane.id)
|
|
170
|
+
.map((s) => {
|
|
171
|
+
const at = timeOf(s).start;
|
|
172
|
+
const cx = s.x + s.w / 2;
|
|
173
|
+
const cy = s.y + s.h / 2;
|
|
174
|
+
const text = write(ctx.ink, "dg-ln-st", cx, cy + LOOK.baseline.tag, s.text, TYPE.stamp, [[at, Number.POSITIVE_INFINITY]], "middle");
|
|
175
|
+
return `<g class="dg-popc dg-a" data-lineup-stamp="${esc(lane.id)}" style="${cs(N.stamp.color)};${m.pop(at)}"><g transform="rotate(${N.stamp.tilt} ${r1(cx)} ${r1(cy)})"><rect class="dg-ln-stamp" x="${r1(s.x)}" y="${r1(s.y)}" width="${r1(s.w)}" height="${s.h}" rx="${N.stamp.radius}"/>${text}</g></g>`;
|
|
176
|
+
})
|
|
177
|
+
.join("");
|
|
178
|
+
const fade = faded.get(lane.id);
|
|
179
|
+
return `<g${fade ? ` class="dg-a" style="${fade}"` : ""}>${track}${covers}${stamps}</g>`;
|
|
180
|
+
})
|
|
181
|
+
.join("");
|
|
182
|
+
|
|
183
|
+
return { lanes, chips: `${pattern}${chips}` };
|
|
184
|
+
}
|
package/src/render/parts.ts
CHANGED
|
@@ -87,6 +87,8 @@ export function arrowHead(points: Point[]): string {
|
|
|
87
87
|
export interface Ctx {
|
|
88
88
|
m: Motion;
|
|
89
89
|
t: Timeline;
|
|
90
|
+
/** 図の名前。図の中の定義 (影の filter、封の縞) の名札に使う */
|
|
91
|
+
id: string;
|
|
90
92
|
/** 影の filter を付ける属性 */
|
|
91
93
|
sh: string;
|
|
92
94
|
/** 最後の段の終わり */
|
|
@@ -97,6 +99,9 @@ export interface Ctx {
|
|
|
97
99
|
traces: Trace[];
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
/** 和文を含む字の、和文の字で描く時の字の形 */
|
|
103
|
+
export const sansOf = (t: TextStyle): TextStyle => ({ ...t, family: "sans" });
|
|
104
|
+
|
|
100
105
|
/**
|
|
101
106
|
* 字を 1 つ描き、字の四角と見えている間を `ink` に記録する (#3175)。`ink` を渡さない字 (寄って追う窓の頭の列) は記録しない。
|
|
102
107
|
* `anchor` を渡さない字は左端を `x` に置き、`text-anchor` を書かない
|
|
@@ -138,8 +143,11 @@ export function band(region: SceneRegion, ink: Ink[]): string {
|
|
|
138
143
|
/** 箱の下の小さな字の移り変わり。`[時刻, 字, class]` の並びで、最初は元の字。 */
|
|
139
144
|
export type SubChange = [number, string, string];
|
|
140
145
|
|
|
141
|
-
/**
|
|
142
|
-
|
|
146
|
+
/**
|
|
147
|
+
* 箱の下の小さな字。基準線を `y` に置き、起きたことに合わせて書き換わる。
|
|
148
|
+
* `right` を渡すと、箱の真ん中でなく字の右端を `right` に揃える (列の図の列の右上の字、#3239)
|
|
149
|
+
*/
|
|
150
|
+
export function subLines(box: SceneBox, m: Motion, changes: SubChange[], y: number, ink?: Ink[], right?: number): string {
|
|
143
151
|
const seq: SubChange[] = [[0, box.sub ?? "", "dg-ss"], ...changes];
|
|
144
152
|
return seq
|
|
145
153
|
.map(([t, text, cls], k) => {
|
|
@@ -147,7 +155,9 @@ function subLines(box: SceneBox, m: Motion, changes: SubChange[], y: number, ink
|
|
|
147
155
|
const anim = k === 0 ? (next === undefined ? "" : m.until(next - MOTION.untilFade)) : next === undefined ? m.rise(t) : m.rise(t, next - MOTION.untilFade);
|
|
148
156
|
if (text === "") return "";
|
|
149
157
|
const shown: Shown[] = [[k === 0 ? 0 : t, next === undefined ? Number.POSITIVE_INFINITY : next - MOTION.untilFade]];
|
|
150
|
-
|
|
158
|
+
const style = cls === "dg-ss" ? TYPE.boxSub : TYPE.boxSubStrong;
|
|
159
|
+
const drawn = right === undefined ? write(ink, cls, box.cx, y, text, style, shown, "middle") : write(ink, cls, right - textWidth(text, style), y, text, style, shown);
|
|
160
|
+
return `<g${anim ? ` class="dg-a" style="${anim}"` : ""}>${drawn}</g>`;
|
|
151
161
|
})
|
|
152
162
|
.join("");
|
|
153
163
|
}
|
|
@@ -256,11 +266,12 @@ export function lifeline(x: number, y1: number, y2: number): string {
|
|
|
256
266
|
* 線。点線で道を見せておき、その段で色の線を引いて、段の終わりまで流れる点で向きを見せる。
|
|
257
267
|
* 済んだ段は薄く残し、最後の段の後に通った道を全て濃くし直す。
|
|
258
268
|
* `past` を立てると (状態遷移図、#3171)、段が終わった後は色の線を消して灰の実線に替え、最後の段まで残す。
|
|
269
|
+
* `since` を渡すと (木の図の後から現れる箱へ向かう線、#3240)、点線の道をその時刻から出す。
|
|
259
270
|
*/
|
|
260
|
-
export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false): { base: string; lit: string } {
|
|
271
|
+
export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false, since = 0): { base: string; lit: string } {
|
|
261
272
|
const { m } = ctx;
|
|
262
|
-
//
|
|
263
|
-
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: ALWAYS });
|
|
273
|
+
// 点線の道は `since` から最後まで見えている。`since` が 0 なら初めから見えている
|
|
274
|
+
ctx.traces.push({ from: e.from, to: e.to, points: e.points, shown: since > 0 ? [[since, Number.POSITIVE_INFINITY]] : ALWAYS });
|
|
264
275
|
const d = pathOf(e.points);
|
|
265
276
|
const head = arrowHead(e.points);
|
|
266
277
|
const { start: a, drawn: b, end } = time;
|
|
@@ -298,8 +309,9 @@ export function edge(e: SceneEdge, time: EdgeTime, ctx: Ctx, past = false): { ba
|
|
|
298
309
|
[m.total, { opacity: 0, "stroke-dashoffset": run }],
|
|
299
310
|
]);
|
|
300
311
|
const grey = past ? m.kf([[0, { opacity: 0 }], [end, { opacity: 0 }, EASE.inOut], [end + 0.4, { opacity: 1 }], [m.last, { opacity: 1 }, EASE.inOut], [m.total, { opacity: 0 }]]) : "";
|
|
312
|
+
const path = `<path class="dg-e" d="${d}"/><path class="dg-eh" d="${head}"/>`;
|
|
301
313
|
return {
|
|
302
|
-
base: `<
|
|
314
|
+
base: `${since > 0 ? `<g class="dg-a" style="${m.vis(since)}">${path}</g>` : path}${past ? `<path class="dg-e-past dg-a" d="${d}" style="${grey}"/><path class="dg-eh-past dg-a" d="${head}" style="${grey}"/>` : ""}`,
|
|
303
315
|
lit: `<g style="${cs(e.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${d}" style="${line}"/><path class="dg-eh-on dg-a" d="${head}" style="${hk}"/><path class="dg-flow dg-a" d="${d}" style="${flow}"/></g>`,
|
|
304
316
|
};
|
|
305
317
|
}
|