kaizen-agent 1.49.0 → 1.50.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/agents/kaizen-reviewer.md +1 -1
- package/cli/hermes.ts +5 -2
- package/cli/notes.test.ts +1 -1
- package/cli/settings.test.ts +2 -0
- package/cli/settings.ts +2 -2
- package/cli/state.test.ts +24 -0
- package/cli/state.ts +18 -0
- package/cli/versions.test.ts +154 -0
- package/cli/versions.ts +272 -0
- package/cli/video.test.ts +64 -3
- package/cli/video.ts +111 -18
- package/cli/web.ts +15 -0
- package/package.json +1 -1
- package/skills/kaizen/README.md +5 -5
- package/skills/kaizen/SKILL.md +10 -14
- package/skills/kaizen/config.default.yml +3 -3
- package/skills/kaizen/spec-main.md +18 -16
- package/skills/kaizen/spec-plan.md +6 -6
- package/skills/kaizen/spec-review.md +2 -2
- package/skills/kaizen-help/SKILL.md +6 -5
- package/skills/media/kaizen-video/SKILL.md +20 -2
- package/skills/media/kaizen-video/canvas.html +241 -0
- package/skills/media/kaizen-video/examples/canvas-film/cat.txt +31 -0
- package/skills/media/kaizen-video/examples/canvas-film/film.json +460 -0
- package/skills/media/kaizen-video/examples/canvas-film/lines.json +10 -0
- package/skills/media/kaizen-video/examples/canvas-film/skip.txt +18 -0
- package/skills/media/kaizen-video/examples/canvas-film/talk.txt +23 -0
- package/skills/media/kaizen-video/examples/canvas-film/wow.txt +24 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/promo.json +17 -0
- package/skills/media/kaizen-video/examples/kaizen-promo/record.json +10 -0
- package/skills/media/kaizen-video/examples/notula-promo/promo.json +41 -0
- package/skills/media/kaizen-video/examples/notula-promo/record.json +135 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.php +20 -0
- package/skills/media/kaizen-video/examples/notula-promo/seed.py +38 -0
- package/skills/media/kaizen-video/presets/app-promo/CREDITS.txt +2 -0
- package/skills/media/kaizen-video/presets/app-promo/README.md +21 -0
- package/skills/media/kaizen-video/presets/app-promo/preset.json +7 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/end.html +25 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/hook.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/name.html +19 -0
- package/skills/media/kaizen-video/presets/app-promo/template/compositions/step.html +52 -0
- package/skills/media/kaizen-video/presets/app-promo/template/index.html +24 -0
- package/skills/media/kaizen-video/presets/film-cinematic-drama/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/CREDITS.txt +3 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/README.md +7 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/InstrumentSerif.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/fonts/SpaceMono.ttf +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/boing.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ding.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/ending.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/pop.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/reveal.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/shutter.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/stamp.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/tick.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/assets/sfx/whoosh.wav +0 -0
- package/skills/media/kaizen-video/presets/film-explainer-canvas/style.json +15 -0
- package/skills/media/kaizen-video/presets/film-fun-energetic/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-promo-booth/.hidden +1 -0
- package/skills/media/kaizen-video/presets/film-viral-social/.hidden +1 -0
- package/skills/media/kaizen-video/presets/tiktok-explainer/index.html +1 -1
- package/skills/media/kaizen-video/references/canvas.md +60 -0
- package/skills/media/kaizen-video/references/presets.md +31 -0
- package/skills/media/kaizen-video/references/promo.md +148 -0
- package/skills/media/kaizen-video/references/revisions.md +11 -2
- package/skills/media/kaizen-video/scripts/make_film.py +157 -4
- package/skills/media/kaizen-video/scripts/make_promo.py +297 -0
- package/skills/media/kaizen-video/scripts/make_tiktok.py +34 -6
- package/skills/media/kaizen-video/scripts/pixel.py +40 -0
- package/skills/media/kaizen-video/scripts/record.mjs +103 -0
- package/web/board/approvals.ts +2 -2
- package/web/board/cards.ts +4 -4
- package/web/board/icebox.ts +6 -5
- package/web/board/panel.ts +2 -2
- package/web/board.html +24 -9
- package/web/board.js +24 -24
- package/web/notebook.js +10 -10
- package/web/notebook.ts +5 -1
- package/web/notes.html +19 -3
- package/web/term.js +1 -1
- package/web/video.html +62 -12
- package/web/video.js +67 -56
- package/web/video.ts +266 -33
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kaizen-video
|
|
3
|
-
description: Make a publish-ready video from the user's own footage, or from nothing. Footage mode edits talking-head explainers for TikTok, Reels or Shorts. Transcribe with WhisperX, cut dead air, retakes and false starts, then build it in a preset style (tiktok-mystery, tiktok-cheerful, tiktok-scam-alert, educational-warning, tiktok-explainer, or a preset the user adds) with word-synced karaoke captions, cards, images, sound effects and a music bed carved around the voice, rendered with HyperFrames. From-scratch mode turns a prompt, story, screenshots, photos or a deck into a narrated film (script, TTS voiceover, music, sound effects, 9:16 or 16:9) in cinematic-drama, promo-booth, fun-energetic or
|
|
3
|
+
description: Make a publish-ready video from the user's own footage, or from nothing. Footage mode edits talking-head explainers for TikTok, Reels or Shorts. Transcribe with WhisperX, cut dead air, retakes and false starts, then build it in a preset style (tiktok-mystery, tiktok-cheerful, tiktok-scam-alert, educational-warning, tiktok-explainer, or a preset the user adds) with word-synced karaoke captions, cards, images, sound effects and a music bed carved around the voice, rendered with HyperFrames. From-scratch mode turns a prompt, story, screenshots, photos or a deck into a narrated film (script, TTS voiceover, music, sound effects, 9:16 or 16:9) in cinematic-drama, promo-booth, fun-energetic, viral-social or explainer-canvas (a camera that pans, zooms and follows over one canvas), with SRT, thumbnail, credits and revisions. Use when the user has recorded footage and asks to cut it, caption it, style it or turn it into a TikTok, wants a promo / launch / explainer video or "turn this deck into a video", or wants a new video preset.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Kaizen video
|
|
@@ -14,6 +14,7 @@ Run every script from the project folder. `S=<this skill>/scripts`; every script
|
|
|
14
14
|
Worked example config: [`examples/config.json`](examples/config.json).
|
|
15
15
|
|
|
16
16
|
Read before styling: [`references/presets.md`](references/presets.md) — the preset contract and how to add one.
|
|
17
|
+
A video about the user's product (an app, a site, a tool) uses the template preset `app-promo`: the real product filmed in use, framed in its own devices. Read [`references/promo.md`](references/promo.md); it also says how a new look becomes an approved preset.
|
|
17
18
|
|
|
18
19
|
## 0. Setup — once per machine
|
|
19
20
|
`$S/check.sh` lists what is missing (ffmpeg, Node, uv). `$S/setup.sh` installs WhisperX 3.8.6 into
|
|
@@ -40,6 +41,9 @@ nominal fps. Footage with someone else's account or comments in it: blur those a
|
|
|
40
41
|
`educational-warning` (bright, for health and consumer warnings), `tiktok-explainer` (dark editor look, the
|
|
41
42
|
speaker in a clip card, big headlines, numeral and tape scenes). Each preset's `README.md` has its look,
|
|
42
43
|
card types and config keys.
|
|
44
|
+
- **A film preset works here too** (`film-cinematic-drama`, `film-viral-social`, …): `make_tiktok.py` hands the cut to
|
|
45
|
+
`make_film.py` as one full-length footage beat, so the video gets that film style's grade, captions, music and
|
|
46
|
+
loudness. Cards from `beats` are not drawn in a film style. See *Crossing over* in `references/presets.md`.
|
|
43
47
|
- **New style:** copy the closest preset to the project's `presets/<style>/` and change its `index.html`
|
|
44
48
|
(grade, fonts, card designs, transitions) and assets. See `references/presets.md`.
|
|
45
49
|
- **Reference video:** analyze it first and keep it in the project's `references/`: specs with ffprobe, cuts
|
|
@@ -80,7 +84,21 @@ the whole video and spot-checking the cut edges.
|
|
|
80
84
|
|
|
81
85
|
# From scratch
|
|
82
86
|
|
|
83
|
-
A film is data in `videos/<name>/`: `film.json` (storyboard, brand, `format` `"9x16"`, `"16x9"` or `"4x5"` (Instagram feed), `preset
|
|
87
|
+
A film is data in `videos/<name>/`: `film.json` (storyboard, brand, `format` `"9x16"`, `"16x9"` or `"4x5"` (Instagram feed), `preset` (a film preset, or any footage preset such as `tiktok-explainer`: see *Crossing over* in `references/presets.md`), `style` (overrides of the preset's style.json), `hook` (for a footage preset), and `platforms`, which the Video page in `kaizen web` keeps), `lines.json` (narration with emotion tags), `words.json` (word timings, generated), `inputs/` (the user's material), voice files `vNN.mp3`. `S=<this skill>/scripts`, run from the project folder. Worked example: [`examples/sample-film/`](examples/sample-film/). Run `$S/check.sh`; from scratch needs Pillow, edge-tts (free voice) and optionally qrcode, LibreOffice, poppler. No WhisperX.
|
|
88
|
+
|
|
89
|
+
**Camera moves (`film-explainer-canvas`):** for an explainer that pans, zooms and follows things across one canvas,
|
|
90
|
+
like a motion-graphics edit, use a canvas preset and choreograph it in film.json. Read
|
|
91
|
+
[`references/canvas.md`](references/canvas.md) first.
|
|
92
|
+
|
|
93
|
+
**Writing for a footage preset** (a brief in `tiktok-*` or `educational-warning`): it is a fast explainer, not a film.
|
|
94
|
+
Set film.json `"hook"` (a hook that lands in 3 s), write lines as 2–5-word phrases with punctuation between them, keep
|
|
95
|
+
every `title` to 14 characters or fewer (a short keyword; the rest goes in `sub`), and give each beat two or three
|
|
96
|
+
`"pics"` so the picture scenes that follow its headline change every couple of seconds.
|
|
97
|
+
|
|
98
|
+
**Pictures when the user brought none:** draw them as pixel art rather than leaving scenes empty. Write a grid and
|
|
99
|
+
palette (`$S/pixel.py`'s docstring has the format), render with `python3 $S/pixel.py art.txt <name>.png`, keep one
|
|
100
|
+
palette per film, and make a mascot (a transparent PNG, set as film.json `"mascot"`) when the preset shows one.
|
|
101
|
+
Add "Pixel art: drawn for this video (no third-party source)" to the video's `CREDITS.txt`.
|
|
84
102
|
|
|
85
103
|
Read before producing: [`references/production.md`](references/production.md) (publish-grade, QA), [`references/script.md`](references/script.md) (**how to write the narration**), [`references/revisions.md`](references/revisions.md), [`references/licensing.md`](references/licensing.md) (**before publishing**), and the Film presets in [`references/presets.md`](references/presets.md).
|
|
86
104
|
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="{{LANG}}" data-resolution="{{RES}}">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width={{W}}, height={{H}}" />
|
|
6
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
|
|
7
|
+
<script src="film-data.js"></script>
|
|
8
|
+
<style>
|
|
9
|
+
/*FONTS*/
|
|
10
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
11
|
+
html, body { width: {{W}}px; height: {{H}}px; overflow: hidden; }
|
|
12
|
+
#root { position: relative; width: 100%; height: 100%; overflow: hidden; }
|
|
13
|
+
.fill { position: absolute; inset: 0; }
|
|
14
|
+
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
|
|
15
|
+
.el { position: absolute; }
|
|
16
|
+
.frame { border: 6px solid var(--fg); border-radius: 28px; overflow: hidden; background: #1a1816; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
|
|
17
|
+
.frame img, .el > img { width: 100%; height: 100%; display: block; }
|
|
18
|
+
.pixel img { image-rendering: pixelated; }
|
|
19
|
+
.chip { position: absolute; left: 18px; top: 16px; padding: 4px 12px; border-radius: 8px; background: rgba(12,11,10,.75); color: var(--accent); font-size: 26px; }
|
|
20
|
+
.label { margin-top: 14px; text-align: center; color: var(--accent); font-size: 30px; }
|
|
21
|
+
.strip { background: #141210; border-top: 10px dashed #2a2622; border-bottom: 10px dashed #2a2622; display: flex; align-items: center; }
|
|
22
|
+
.strip .cell { position: relative; flex: none; display: flex; align-items: center; justify-content: center; }
|
|
23
|
+
.strip .q { font-weight: 900; color: var(--fg); }
|
|
24
|
+
.playhead { position: absolute; top: -40px; bottom: -40px; width: 6px; background: var(--red); }
|
|
25
|
+
.playhead::before { content: ""; position: absolute; left: -15px; top: -4px; border: 18px solid transparent; border-top-color: var(--red); border-bottom: 0; }
|
|
26
|
+
.playhead .tc { position: absolute; left: 50%; bottom: -70px; transform: translateX(-50%); font-size: 40px; color: var(--accent); opacity: 0; white-space: nowrap; }
|
|
27
|
+
.num { line-height: .85; font-weight: 900; letter-spacing: -0.04em; }
|
|
28
|
+
.num .d { position: absolute; left: 0; top: 0; }
|
|
29
|
+
.num .o { color: transparent; -webkit-text-stroke: 6px var(--accent); }
|
|
30
|
+
.num .f { position: absolute; left: 0; top: 0; color: var(--accent); clip-path: inset(100% 0 0 0); }
|
|
31
|
+
.tape { background: var(--accent); color: var(--bg); font-weight: 900; text-align: center; padding: 18px 30px; box-shadow: 0 14px 40px rgba(0,0,0,.5); text-transform: uppercase; line-height: 1; }
|
|
32
|
+
.stamp { position: absolute; left: 50%; top: 50%; padding: 6px 26px; border: 10px solid var(--red); color: var(--red); font-weight: 900; text-transform: uppercase;
|
|
33
|
+
transform: translate(-50%, -20%) rotate(-12deg); opacity: 0; white-space: nowrap; }
|
|
34
|
+
.acc { color: var(--accent); }
|
|
35
|
+
#streaks { inset: -30%;
|
|
36
|
+
background: linear-gradient(115deg, transparent 38%, rgba(239,230,214,.045) 44%, transparent 50%), linear-gradient(115deg, transparent 58%, rgba(247,169,59,.05) 62%, transparent 67%); }
|
|
37
|
+
#captions { position: absolute; left: 90px; right: 90px; top: 1460px; height: 260px; }
|
|
38
|
+
.chunk { position: absolute; inset: 0; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 0 22px; opacity: 0; }
|
|
39
|
+
.w { display: block; font-weight: 900; font-size: 78px; line-height: 1.08; letter-spacing: -2px; text-transform: lowercase; color: var(--fg); opacity: 0;
|
|
40
|
+
text-shadow: 0 6px 24px rgba(0,0,0,.9); }
|
|
41
|
+
#mascot { position: absolute; left: 30px; bottom: 60px; width: 230px; height: 230px; opacity: 0; }
|
|
42
|
+
#mascot img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; image-rendering: pixelated; }
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
<div id="root" data-composition-id="main" data-start="0" data-duration="{{DURATION}}" data-width="{{W}}" data-height="{{H}}">
|
|
47
|
+
<div id="streaks" class="fill"></div>
|
|
48
|
+
<div id="world"></div>
|
|
49
|
+
<div id="vignette" class="fill"></div>
|
|
50
|
+
<div id="mascot"></div>
|
|
51
|
+
<div id="captions"></div>
|
|
52
|
+
<!-- AUDIO -->
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
// A canvas film (film-data.js, written by make_film.py): one large canvas of elements, and a camera that moves
|
|
57
|
+
// over it beat by beat. Beats carry "cam" (where the camera goes when the beat starts) and "do" (actions on
|
|
58
|
+
// elements, each with an absolute time "t"). Everything is laid out once, then measured, then tweened on one
|
|
59
|
+
// paused timeline: no timers, so every frame is the same in preview and render.
|
|
60
|
+
document.fonts.ready.then(() => { // text boxes are measured below, so the fonts must be in first
|
|
61
|
+
const F = FILM, S = F.style, P = S.palette, FD = S.fonts, C = F.canvas, W = F.W, H = F.H;
|
|
62
|
+
const tl = gsap.timeline({ paused: true });
|
|
63
|
+
const root = document.getElementById("root"), world = document.getElementById("world");
|
|
64
|
+
for (const [k, v] of Object.entries({ bg: P.bg, fg: P.fg, muted: P.muted, accent: P.accent, red: P.red || "#ef4b3a" })) root.style.setProperty("--" + k, v);
|
|
65
|
+
root.style.background = P.bg;
|
|
66
|
+
Object.assign(world.style, { width: C.w + "px", height: C.h + "px" });
|
|
67
|
+
const esc = s => String(s ?? "").replace(/[&<>"]/g, c => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
68
|
+
const rich = s => esc(s).replace(/\*([^*]+)\*/g, '<span class="acc">$1</span>').replace(/\n/g, "<br>"); // *word* = accent
|
|
69
|
+
const FONT = { head: `"${FD.display}"`, serif: `"${FD.body}"`, mono: `"${FD.mono || FD.display}"` };
|
|
70
|
+
const COLOR = { fg: "var(--fg)", accent: "var(--accent)", muted: "var(--muted)", red: "var(--red)", bg: "var(--bg)" };
|
|
71
|
+
// A canvas is layered on purpose (a card over a row, a timecode under its playhead), so layout checks allow it.
|
|
72
|
+
const $ = (cls, css, html = "", parent = world) => {
|
|
73
|
+
const e = document.createElement("div"); e.className = cls; Object.assign(e.style, css); e.innerHTML = html; parent.append(e);
|
|
74
|
+
for (const k of ["overflow", "overlap", "occlusion"]) e.setAttribute("data-layout-allow-" + k, "");
|
|
75
|
+
return e;
|
|
76
|
+
};
|
|
77
|
+
const nodes = {}; // element id (and "strip/2" for a strip's cell) -> DOM node
|
|
78
|
+
|
|
79
|
+
// 1. Lay out every element at its canvas position.
|
|
80
|
+
const DRAW = {
|
|
81
|
+
text(e) {
|
|
82
|
+
return $("el", { width: e.w ? e.w + "px" : "auto", whiteSpace: e.w ? "normal" : "nowrap", fontFamily: FONT[e.font || "head"], fontWeight: (e.font || "head") === "head" ? 900 : 400,
|
|
83
|
+
fontSize: (e.size || 96) + "px", lineHeight: e.font === "serif" ? 1.1 : 0.98, letterSpacing: (e.font || "head") === "head" ? "-0.03em" : 0, color: COLOR[e.color || "fg"],
|
|
84
|
+
textAlign: e.align || "left" }, rich(e.text));
|
|
85
|
+
},
|
|
86
|
+
img(e) {
|
|
87
|
+
const n = $("el" + (e.frame ? " frame" : "") + (e.pixel ? " pixel" : ""), { width: e.w + "px", height: e.h + "px" },
|
|
88
|
+
`<img src="${esc(e.img)}" style="object-fit:${e.fit || (e.frame ? "cover" : "contain")}" data-layout-allow-overflow>` + (e.chip ? `<div class="chip" style="font-family:${FONT.mono}">${esc(e.chip)}</div>` : ""));
|
|
89
|
+
if (e.label) $("label", { fontFamily: FONT.serif, position: "absolute", left: 0, right: 0, top: "100%" }, esc(e.label), n);
|
|
90
|
+
return n;
|
|
91
|
+
},
|
|
92
|
+
card(e) {
|
|
93
|
+
return $("el frame", { width: e.w + "px", height: e.h + "px", display: "flex", alignItems: "center", justifyContent: "center", fontFamily: FONT.head, fontWeight: 900,
|
|
94
|
+
fontSize: (e.size || 140) + "px", color: COLOR[e.color || "fg"], background: e.fill ? COLOR[e.fill] : "#1a1816" }, rich(e.text));
|
|
95
|
+
},
|
|
96
|
+
strip(e) {
|
|
97
|
+
const fw = e.fw || 220, fh = e.fh || 300, gap = e.gap || 26, n = e.frames.length;
|
|
98
|
+
const s = $("el strip", { width: n * (fw + gap) + gap + "px", height: fh + 70 + "px", paddingLeft: gap + "px", gap: gap + "px" });
|
|
99
|
+
e.frames.forEach((fr, i) => {
|
|
100
|
+
const cell = $("cell frame" + (e.pixel ? " pixel" : ""), { width: fw + "px", height: fh + "px", borderWidth: "4px", borderRadius: "14px" },
|
|
101
|
+
fr.img ? `<img src="${esc(fr.img)}" style="object-fit:cover" data-layout-allow-overflow>` : `<div class="q" data-layout-allow-occlusion data-layout-allow-overlap style="font-size:${fh * 0.45}px;font-family:${FONT.head}">${esc(fr.text ?? "?")}</div>`, s);
|
|
102
|
+
if (fr.chip) $("chip", { fontFamily: FONT.mono, fontSize: "20px" }, esc(fr.chip), cell);
|
|
103
|
+
nodes[`${e.id}/${i}`] = cell;
|
|
104
|
+
});
|
|
105
|
+
if (e.playhead != null) {
|
|
106
|
+
const ph = $("playhead", { left: gap + e.playhead * (fw + gap) + fw / 2 + "px" }, "", s);
|
|
107
|
+
e.frames.forEach((fr, i) => $("tc", { fontFamily: FONT.mono }, esc(fr.tc ?? `0:${String(i).padStart(2, "0")}`), ph).dataset.i = i);
|
|
108
|
+
s.dataset.fw = fw + gap;
|
|
109
|
+
nodes[e.id + "/playhead"] = ph;
|
|
110
|
+
}
|
|
111
|
+
return s;
|
|
112
|
+
},
|
|
113
|
+
numeral(e) {
|
|
114
|
+
// Every value this numeral morphs to is drawn now, stacked; morphs swap which one shows.
|
|
115
|
+
const vals = [String(e.value), ...F.beats.flatMap(b => (b.do || []).filter(a => a.el === e.id && a.act === "morph").map(a => String(a.to)))];
|
|
116
|
+
const n = $("el num", { fontFamily: FONT.head, fontSize: (e.size || 900) + "px", width: (e.w || e.size * 0.75 || 700) + "px", height: (e.size || 900) * 0.9 + "px" });
|
|
117
|
+
vals.forEach((v, i) => { const d = $("d", { opacity: i ? 0 : 1 }, `<span class="o" data-layout-ignore>${esc(v)}</span><span class="f">${esc(v)}</span>`, n); d.dataset.v = v; });
|
|
118
|
+
return n;
|
|
119
|
+
},
|
|
120
|
+
tape(e) {
|
|
121
|
+
const n = $("el tape", { width: (e.w || 1000) + "px", fontFamily: FONT.head, fontSize: (e.size || 86) + "px" }, rich(e.text));
|
|
122
|
+
if (e.stamp) $("stamp", { fontFamily: FONT.head, fontSize: (e.stampSize || 150) + "px" }, esc(e.stamp), n);
|
|
123
|
+
return n;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
C.elements.forEach(e => {
|
|
127
|
+
const n = (DRAW[e.kind] || DRAW.text)(e);
|
|
128
|
+
Object.assign(n.style, { left: e.x + "px", top: e.y + "px" });
|
|
129
|
+
if (e.rot) gsap.set(n, { rotation: e.rot });
|
|
130
|
+
if (e.hidden) gsap.set(n, { opacity: 0 });
|
|
131
|
+
nodes[e.id] = n;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// 2. Measure once, before anything moves: every target is a box in canvas coordinates.
|
|
135
|
+
const box = id => {
|
|
136
|
+
const n = nodes[id];
|
|
137
|
+
if (!n) throw new Error(`canvas: no element "${id}"`);
|
|
138
|
+
const r = n.getBoundingClientRect(), w0 = world.getBoundingClientRect();
|
|
139
|
+
return { x: r.left - w0.left, y: r.top - w0.top, w: r.width, h: r.height };
|
|
140
|
+
};
|
|
141
|
+
const BOX = Object.fromEntries(Object.keys(nodes).map(id => [id, box(id)]));
|
|
142
|
+
const moved = {}; // element id -> its current offset from where it was laid out
|
|
143
|
+
const centre = id => { const b = BOX[id], m = moved[id] || { x: 0, y: 0 }; return [b.x + b.w / 2 + m.x, b.y + b.h / 2 + m.y]; };
|
|
144
|
+
|
|
145
|
+
// 3. Camera: one transform on #world, framing a point at 42% of the height (the captions live below it).
|
|
146
|
+
let zoom = 1;
|
|
147
|
+
const fit = id => { const b = BOX[id]; return Math.min((W * 0.86) / b.w, (H * 0.5) / b.h, 3); };
|
|
148
|
+
const camTo = (t, c) => {
|
|
149
|
+
const [cx, cy] = Array.isArray(c.to) ? c.to : centre(c.to);
|
|
150
|
+
zoom = c.zoom ?? (Array.isArray(c.to) ? zoom : fit(c.to));
|
|
151
|
+
const [ox, oy] = c.offset || [0, 0];
|
|
152
|
+
const pose = { x: W / 2 - (cx + ox) * zoom, y: H * 0.42 - (cy + oy) * zoom, scale: zoom };
|
|
153
|
+
if (t === 0 || c.dur === 0) tl.set(world, pose, t);
|
|
154
|
+
else tl.to(world, { ...pose, duration: c.dur ?? 0.8, ease: c.ease || "power3.inOut" }, t);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// 4. Beats and actions, in time order so camera follows and moves stack correctly.
|
|
158
|
+
const events = [];
|
|
159
|
+
F.beats.forEach((b, i) => {
|
|
160
|
+
if (b.cam) events.push({ t: i ? b.start : 0, cam: b.cam });
|
|
161
|
+
(b.do || []).forEach(a => events.push({ t: a.t, act: a }));
|
|
162
|
+
});
|
|
163
|
+
events.sort((p, q) => p.t - q.t);
|
|
164
|
+
const ACT = {
|
|
165
|
+
move(a, t) {
|
|
166
|
+
const [x0, y0] = centre(a.el), [x1, y1] = Array.isArray(a.to) ? a.to : centre(a.to), m = moved[a.el] || { x: 0, y: 0 };
|
|
167
|
+
const dx = m.x + x1 - x0, dy = m.y + y1 - y0, d = a.dur ?? 0.9, lift = a.lift ?? 1.08;
|
|
168
|
+
const mid = { x: m.x + (dx - m.x) / 2, y: m.y + (dy - m.y) / 2 - (a.arc || 0), scale: lift, zIndex: 5 };
|
|
169
|
+
tl.to(nodes[a.el], { keyframes: [{ ...mid, duration: d / 2, ease: "power2.out" }, { x: dx, y: dy, scale: 1, duration: d / 2, ease: "power2.in" }], ease: "none" }, t);
|
|
170
|
+
moved[a.el] = { x: dx, y: dy };
|
|
171
|
+
if (a.follow) camTo(t, { to: [x1, y1], zoom: a.zoom ?? zoom, dur: d, ease: "power2.inOut" });
|
|
172
|
+
},
|
|
173
|
+
pop(a, t) { tl.fromTo(nodes[a.el], { opacity: 0, scale: 0.2 }, { opacity: 1, scale: 1, duration: a.dur ?? 0.45, ease: "back.out(2.2)", immediateRender: false }, t); },
|
|
174
|
+
fade(a, t) { tl.to(nodes[a.el], { opacity: a.to ?? 1, duration: a.dur ?? 0.4, ease: "none" }, t); },
|
|
175
|
+
glow(a, t) { tl.to(nodes[a.el], { boxShadow: `0 0 0 10px ${P.accent}, 0 30px 80px rgba(0,0,0,.7)`, scale: a.scale ?? 1.06, duration: 0.3, ease: "power2.out" }, t); },
|
|
176
|
+
scrub(a, t) {
|
|
177
|
+
const ph = nodes[a.el + "/playhead"], step = +ph.parentNode.dataset.fw, from = a.from ?? 0, to = a.to, d = a.dur ?? Math.abs(to - from) * 0.4;
|
|
178
|
+
tl.fromTo(ph, { x: (from - (C.elements.find(e => e.id === a.el).playhead || 0)) * step }, { x: (to - (C.elements.find(e => e.id === a.el).playhead || 0)) * step, duration: d, ease: "power1.inOut" }, t);
|
|
179
|
+
ph.querySelectorAll(".tc").forEach(tc => tl.set(tc, { opacity: 0 }, t)); // a new scrub starts clean
|
|
180
|
+
ph.querySelectorAll(".tc").forEach(tc => {
|
|
181
|
+
const i = +tc.dataset.i, lo = Math.min(from, to), hi = Math.max(from, to);
|
|
182
|
+
if (i < lo || i > hi) return;
|
|
183
|
+
const at = t + (d * Math.abs(i - from)) / Math.max(1, Math.abs(to - from));
|
|
184
|
+
tl.set(tc, { opacity: 1 }, at);
|
|
185
|
+
if (i !== to) tl.set(tc, { opacity: 0 }, at + d / Math.max(1, Math.abs(to - from)));
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
morph(a, t) {
|
|
189
|
+
const ds = [...nodes[a.el].querySelectorAll(".d")], cur = ds.find(d => d.dataset.cur) || ds[0], next = ds.find(d => d.dataset.v === String(a.to) && d !== cur);
|
|
190
|
+
delete cur.dataset.cur; next.dataset.cur = 1;
|
|
191
|
+
tl.to(cur, { opacity: 0, scale: 0.7, duration: 0.18, ease: "power2.in" }, t)
|
|
192
|
+
.fromTo(next, { opacity: 0, scale: 1.35 }, { opacity: 1, scale: 1, duration: 0.35, ease: "back.out(1.8)", immediateRender: false }, t + 0.15);
|
|
193
|
+
if (a.fill !== false) tl.fromTo(next.querySelector(".f"), { clipPath: "inset(100% 0 0 0)" }, { clipPath: "inset(0% 0 0 0)", duration: 0.8, ease: "power2.inOut", immediateRender: false }, t + 0.3);
|
|
194
|
+
},
|
|
195
|
+
fill(a, t) {
|
|
196
|
+
const d = [...nodes[a.el].querySelectorAll(".d")].find(x => x.dataset.cur) || nodes[a.el].querySelector(".d");
|
|
197
|
+
tl.fromTo(d.querySelector(".f"), { clipPath: "inset(100% 0 0 0)" }, { clipPath: "inset(0% 0 0 0)", duration: a.dur ?? 1, ease: "power2.inOut", immediateRender: false }, t);
|
|
198
|
+
},
|
|
199
|
+
stamp(a, t) {
|
|
200
|
+
const n = nodes[a.el];
|
|
201
|
+
tl.fromTo(n, { opacity: 0, scale: 1.6, rotation: (C.elements.find(e => e.id === a.el).rot || 0) - 8 },
|
|
202
|
+
{ opacity: 1, scale: 1, rotation: C.elements.find(e => e.id === a.el).rot || 0, duration: 0.25, ease: "power4.out", immediateRender: false }, t);
|
|
203
|
+
const st = n.querySelector(".stamp");
|
|
204
|
+
if (st) tl.fromTo(st, { opacity: 0, scale: 2.4 }, { opacity: 1, scale: 1, duration: 0.18, ease: "power4.in", immediateRender: false }, t + 0.35);
|
|
205
|
+
},
|
|
206
|
+
shake(a, t) { tl.to(world, { keyframes: [{ x: "+=14" }, { x: "-=28" }, { x: "+=22" }, { x: "-=8" }], duration: 0.28, ease: "none" }, t); },
|
|
207
|
+
};
|
|
208
|
+
events.forEach(ev => {
|
|
209
|
+
if (ev.cam) camTo(ev.t, ev.cam);
|
|
210
|
+
else (ACT[ev.act.act] || (() => { throw new Error(`canvas: unknown action "${ev.act.act}"`); }))(ev.act, ev.t);
|
|
211
|
+
});
|
|
212
|
+
tl.fromTo("#streaks", { x: -60 }, { x: 60, duration: F.total, ease: "none" }, 0);
|
|
213
|
+
|
|
214
|
+
// 5. Mascot in the corner, screen-fixed.
|
|
215
|
+
if (F.mascot) {
|
|
216
|
+
const m = document.getElementById("mascot");
|
|
217
|
+
m.innerHTML = `<img src="${esc(F.mascot)}" alt="">`;
|
|
218
|
+
tl.fromTo(m, { opacity: 0, scale: 0.3 }, { opacity: 1, scale: 1, duration: 0.4, ease: "back.out(2.4)" }, 0.3);
|
|
219
|
+
for (let k = 0; 0.8 + k * 0.6 < F.total; k++) tl.to(m, { y: k % 2 ? 0 : -14, duration: 0.6, ease: "sine.inOut" }, 0.8 + k * 0.6);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 6. Kinetic captions, screen-fixed: each word pops in as it is spoken, orange while spoken.
|
|
223
|
+
const cap = document.getElementById("captions");
|
|
224
|
+
F.captions.forEach(c => {
|
|
225
|
+
const ch = document.createElement("div"); ch.className = "chunk"; cap.append(ch);
|
|
226
|
+
c.words.forEach(w => {
|
|
227
|
+
const s = document.createElement("span"); s.className = "w"; s.textContent = w.w; s.style.fontFamily = FONT.head; ch.append(s);
|
|
228
|
+
tl.fromTo(s, { opacity: 0, y: 24, scale: 0.8 }, { opacity: 1, y: 0, scale: 1, duration: 0.16, ease: "back.out(2)", immediateRender: false }, w.s)
|
|
229
|
+
.set(s, { color: P.accent }, w.s).set(s, { color: P.fg }, w.e);
|
|
230
|
+
});
|
|
231
|
+
tl.set(ch, { opacity: 1 }, c.s).set(ch, { opacity: 0 }, c.e);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
const vg = document.getElementById("vignette");
|
|
235
|
+
vg.style.background = `radial-gradient(ellipse 85% 70% at 50% 45%, transparent 55%, rgba(0,0,0,${S.grade.vignette}) 100%)`;
|
|
236
|
+
window.__timelines = window.__timelines || {};
|
|
237
|
+
window.__timelines["main"] = tl; // registered only once the build is complete
|
|
238
|
+
});
|
|
239
|
+
</script>
|
|
240
|
+
</body>
|
|
241
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
K #2a1a12
|
|
2
|
+
O #f2963a
|
|
3
|
+
D #c96a1e
|
|
4
|
+
W #ffffff
|
|
5
|
+
P #f07a8c
|
|
6
|
+
H #3a3a46
|
|
7
|
+
G #6b6b7a
|
|
8
|
+
C #e8645a
|
|
9
|
+
|
|
10
|
+
...K..............K...
|
|
11
|
+
..KOK............KOK..
|
|
12
|
+
..KODK..........KDOK..
|
|
13
|
+
..KODDK........KDDOK..
|
|
14
|
+
..KOOOOKKKKKKKKOOOOK..
|
|
15
|
+
.HHKOOOOOOOOOOOOOOKHH.
|
|
16
|
+
HGGKOOOOOOOOOOOOOOKGGH
|
|
17
|
+
HGGKOOKKOOOOOOKKOOKGGH
|
|
18
|
+
HGGKOKWKKOOOOKWKKOKGGH
|
|
19
|
+
HGGKOKKKKOOOOKKKKOKGGH
|
|
20
|
+
HGGKOOKKOOOOOOKKOOKGGH
|
|
21
|
+
.HHKOCCOOOPPOOOCCOKHH.
|
|
22
|
+
...KOOOOOOKKOOOOOOK...
|
|
23
|
+
...KOOOOOKOOKOOOOOK...
|
|
24
|
+
....KOOOOOOOOOOOOK....
|
|
25
|
+
.....KKOOOOOOOOKK.....
|
|
26
|
+
......KDOOOOOODK......
|
|
27
|
+
.....KOOOWWWWOOOK.....
|
|
28
|
+
.....KOOWWWWWWOOK.....
|
|
29
|
+
.....KOOWWWWWWOOK.....
|
|
30
|
+
.....KOOOWWWWOOOK.....
|
|
31
|
+
......KKKK..KKKK......
|