Teaser video source: scripted terminal timeline, procedural music, render script (media/teaser)
HTML/CSS/JS timeline rendered frame by frame in headless Chrome, original music synthesized with OfflineAudioContext, ffmpeg encode + loudnorm. Outputs go to media/teaser/out (gitignored); poster.jpg is the end card.
This commit is contained in:
parent
c94387f06c
commit
b142cf6d21
9 changed files with 1154 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,3 +6,4 @@ node_modules/
|
||||||
*.jks
|
*.jks
|
||||||
*.p12
|
*.p12
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
media/teaser/out/
|
||||||
|
|
|
||||||
35
media/teaser/README.md
Normal file
35
media/teaser/README.md
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# storebound teaser (30-40 s social video)
|
||||||
|
|
||||||
|
A scripted terminal animation, not a screen recording. Every frame is a pure function of time, rendered from an
|
||||||
|
HTML/CSS/JS timeline in headless Chrome and encoded with ffmpeg. The music is original and synthesized from scratch in
|
||||||
|
the same browser (Web Audio `OfflineAudioContext`): no samples, no downloaded audio, nothing to license.
|
||||||
|
|
||||||
|
| file | what |
|
||||||
|
|---|---|
|
||||||
|
| `script.js` | the timeline: tempo (128 BPM, 20 bars = 37.5 s), scenes, terminal lines, prices, languages, blockers |
|
||||||
|
| `index.html` + `teaser.js` | the picture; `window.teaser.seek(t)` sets every element for time `t` |
|
||||||
|
| `music.js` | the music: arp, kick, hats, clap, offbeat bass, pad, impacts on the cuts, key clicks, riser |
|
||||||
|
| `render.ts` | frames -> ffmpeg (H.264 high, yuv420p, 30 fps), music -> loudnorm (-14 LUFS, -1.5 dBTP), mux, posters |
|
||||||
|
| `poster.jpg` | end card still (1920x1080, small) |
|
||||||
|
|
||||||
|
The terminal text is modelled on real storebound output for the demo game (`examples/demo-game`, placeholder ids,
|
||||||
|
dry runs); the price table values are illustrative. The store art is the demo game's real renders.
|
||||||
|
|
||||||
|
## Render
|
||||||
|
|
||||||
|
Needs Bun, ffmpeg and Playwright (repo devDependency; Playwright's Chromium or an installed Google Chrome).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# optional, for sharp store art: the demo renders (otherwise crops of docs/img/showcase.jpg are used)
|
||||||
|
cd examples/demo-game && bun serve.ts & bun ../../cli/index.ts shots capture && bun ../../cli/index.ts shots fonts && bun ../../cli/index.ts shots render
|
||||||
|
# from the repo root
|
||||||
|
bun media/teaser/render.ts # both formats + music, about 10 min
|
||||||
|
bun media/teaser/render.ts --only v # vertical only (h = horizontal)
|
||||||
|
bun media/teaser/render.ts --stills 2,12.5,30 # PNG stills in out/stills for a quick layout check
|
||||||
|
bun media/teaser/render.ts --serve --port 8750 # live preview: /index.html?w=1080&h=1920&play=1 (or &t=12.5)
|
||||||
|
```
|
||||||
|
|
||||||
|
Outputs (gitignored) in `media/teaser/out/`: `teaser-1080x1920.mp4` (X / TikTok / Reels), `teaser-1920x1080.mp4`
|
||||||
|
(X / YouTube), `-silent` variants, `poster-*.jpg`, `music.wav`.
|
||||||
|
|
||||||
|
Vertical layout keeps captions and key text inside the central 80% and leaves the bottom ~22% free for app overlays.
|
||||||
222
media/teaser/index.html
Normal file
222
media/teaser/index.html
Normal file
|
|
@ -0,0 +1,222 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>storebound teaser</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg: #0b1120; --bg-2: #0f172a; --surface: #131c2f; --line: #1e293b; --line-2: #334155;
|
||||||
|
--ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #94a3b8; --dim: #64748b;
|
||||||
|
--accent: #818cf8; --accent-2: #4f46e5; --accent-soft: #1e1b4b;
|
||||||
|
--api-bg: #14532d; --api-ink: #86efac;
|
||||||
|
--local-bg: #0c4a6e; --local-ink: #7dd3fc;
|
||||||
|
--ui-bg: #451a03; --ui-ink: #fcd34d;
|
||||||
|
--you-bg: #500724; --you-ink: #f9a8d4;
|
||||||
|
--red: #f87171; --red-bg: #450a0a; --green: #4ade80;
|
||||||
|
--sans: "SF Pro Display", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
html, body { margin: 0; padding: 0; background: var(--bg); overflow: hidden; }
|
||||||
|
#stage { position: relative; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans);
|
||||||
|
-webkit-font-smoothing: antialiased; }
|
||||||
|
#stage > * { position: absolute; }
|
||||||
|
|
||||||
|
/* background */
|
||||||
|
#bg { inset: 0; }
|
||||||
|
#bg .grid { position: absolute; inset: -80px; opacity: .55;
|
||||||
|
background-image: linear-gradient(rgba(148,163,184,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(148,163,184,.07) 1px, transparent 1px);
|
||||||
|
background-size: 64px 64px; }
|
||||||
|
#bg .glow { position: absolute; border-radius: 50%; filter: blur(40px); }
|
||||||
|
#bg .g1 { width: 900px; height: 900px; background: radial-gradient(circle, rgba(79,70,229,.55), rgba(79,70,229,0) 65%); }
|
||||||
|
#bg .g2 { width: 760px; height: 760px; background: radial-gradient(circle, rgba(129,140,248,.30), rgba(129,140,248,0) 65%); }
|
||||||
|
#bg .g3 { width: 640px; height: 640px; background: radial-gradient(circle, rgba(236,72,153,.18), rgba(236,72,153,0) 65%); }
|
||||||
|
#bg .vig { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(11,17,32,0) 45%, rgba(3,6,14,.85) 100%); }
|
||||||
|
#flash { inset: 0; background: #c7d2fe; opacity: 0; pointer-events: none; z-index: 50; mix-blend-mode: screen; }
|
||||||
|
|
||||||
|
/* captions */
|
||||||
|
#caption { z-index: 30; font-weight: 900; letter-spacing: -0.025em; line-height: 1.0; }
|
||||||
|
#caption .line { display: block; white-space: nowrap; }
|
||||||
|
#caption .w { display: inline-block; margin-right: .22em; will-change: transform; }
|
||||||
|
#caption .w:last-child { margin-right: 0; }
|
||||||
|
#caption .hl { color: var(--accent); }
|
||||||
|
#caption .hl.g { color: var(--green); }
|
||||||
|
#caption .sub { display: block; font-family: var(--mono); font-weight: 600; letter-spacing: 0; color: var(--muted); margin-top: 22px; }
|
||||||
|
#caption .big { font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
|
/* terminal */
|
||||||
|
#term { z-index: 10; border-radius: 26px; background: rgba(6,10,20,.92); border: 2px solid var(--line-2);
|
||||||
|
box-shadow: 0 40px 120px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(129,140,248,.10), 0 0 80px -20px rgba(79,70,229,.45);
|
||||||
|
overflow: hidden; transform-origin: 50% 50%; }
|
||||||
|
#term .bar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 2px solid var(--line);
|
||||||
|
background: rgba(19,28,47,.9); }
|
||||||
|
#term .dot { width: 16px; height: 16px; border-radius: 50%; background: #334155; }
|
||||||
|
#term .dot:nth-child(1) { background: #f87171; } #term .dot:nth-child(2) { background: #fbbf24; } #term .dot:nth-child(3) { background: #4ade80; }
|
||||||
|
#term .agent { margin-left: 14px; display: inline-flex; align-items: center; gap: 10px; padding: 6px 16px; border-radius: 999px;
|
||||||
|
background: var(--accent-soft); color: #c7d2fe; font: 700 22px/1 var(--sans); letter-spacing: .01em; }
|
||||||
|
#term .agent i { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
|
||||||
|
#term .title { margin-left: auto; color: var(--dim); font: 600 20px/1 var(--mono); }
|
||||||
|
#term .body { position: absolute; left: 0; right: 0; top: 64px; bottom: 0; padding: 22px 30px; font: 500 25px/1.5 var(--mono);
|
||||||
|
color: var(--ink-2); }
|
||||||
|
#term .pin { color: #e0e7ff; font-weight: 700; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 2px dashed var(--line); white-space: pre-wrap; }
|
||||||
|
#term .pin .gt { color: var(--accent); }
|
||||||
|
#term .lines { white-space: pre-wrap; word-break: break-word; overflow: hidden; }
|
||||||
|
#term .l { min-height: 1.5em; }
|
||||||
|
#term .cmd { color: #f8fafc; font-weight: 700; }
|
||||||
|
#term .cmd .ps { color: var(--green); }
|
||||||
|
#term .note { color: #a5b4fc; }
|
||||||
|
#term .tag { color: var(--accent); }
|
||||||
|
#term .t-play { color: #86efac; } #term .t-apple { color: #7dd3fc; } #term .t-shots { color: #fcd34d; } #term .t-check, #term .t-init, #term .t-validate { color: #c4b5fd; }
|
||||||
|
#term .dim { color: var(--dim); }
|
||||||
|
#term .bad { color: #fecaca; background: rgba(248,113,113,.18); border-radius: 6px; padding: 0 6px; font-weight: 700; }
|
||||||
|
#term .okk { color: #052e16; background: var(--green); border-radius: 6px; padding: 0 6px; font-weight: 700; }
|
||||||
|
#term .fixed { color: var(--dim); text-decoration: line-through; text-decoration-color: rgba(74,222,128,.7); text-decoration-thickness: 2px; }
|
||||||
|
#term .win { color: var(--green); font-weight: 800; }
|
||||||
|
#term .cur { display: inline-block; width: .6em; height: 1.1em; vertical-align: -0.18em; background: var(--accent); margin-left: 2px; }
|
||||||
|
|
||||||
|
/* panels */
|
||||||
|
.panel { z-index: 20; border-radius: 26px; background: linear-gradient(180deg, rgba(30,41,59,.97), rgba(19,28,47,.97));
|
||||||
|
border: 2px solid var(--line-2); box-shadow: 0 30px 80px -20px rgba(0,0,0,.85), 0 0 0 1px rgba(129,140,248,.18); padding: 26px 30px; opacity: 0; }
|
||||||
|
.panel h4 { margin: 0 0 4px; font: 800 30px/1.2 var(--sans); color: var(--ink); display: flex; align-items: center; gap: 14px; }
|
||||||
|
.panel .ph { margin: 0 0 18px; font: 500 20px/1.3 var(--sans); color: var(--muted); }
|
||||||
|
.pill { display: inline-flex; align-items: center; justify-content: center; padding: 5px 14px; border-radius: 999px; font: 800 18px/1 var(--sans); letter-spacing: .06em; }
|
||||||
|
.p-api { background: var(--api-bg); color: var(--api-ink); } .p-ui { background: var(--ui-bg); color: var(--ui-ink); }
|
||||||
|
.p-local { background: var(--local-bg); color: var(--local-ink); } .p-you { background: var(--you-bg); color: var(--you-ink); }
|
||||||
|
|
||||||
|
#prices table { width: 100%; border-collapse: collapse; font: 600 25px/1 var(--mono); font-variant-numeric: tabular-nums; }
|
||||||
|
#prices th { text-align: left; font: 700 17px/1 var(--sans); color: var(--dim); letter-spacing: .08em; text-transform: uppercase; padding: 0 0 12px; }
|
||||||
|
#prices th:nth-child(n+3), #prices td:nth-child(n+3) { text-align: right; }
|
||||||
|
#prices td { padding: 10px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
|
||||||
|
#prices tr.hot td { color: #fff; }
|
||||||
|
#prices tr.hot td:first-child { color: var(--accent); }
|
||||||
|
#prices .ov { margin-left: 8px; font: 800 13px/1 var(--sans); padding: 3px 7px; border-radius: 6px; background: var(--accent-soft); color: #c7d2fe; vertical-align: 3px; }
|
||||||
|
#prices .sum { margin-top: 14px; font: 600 20px/1.2 var(--sans); color: var(--muted); }
|
||||||
|
|
||||||
|
#langs .chips { display: flex; flex-wrap: wrap; gap: 12px; }
|
||||||
|
#langs .chip { font: 700 25px/1 var(--mono); padding: 12px 16px; border-radius: 14px; background: rgba(15,23,42,.9); color: #475569; border: 2px solid var(--line); }
|
||||||
|
#langs .chip.on { background: var(--accent-soft); color: #e0e7ff; border-color: var(--accent); }
|
||||||
|
#langs .count { margin-left: auto; font: 900 40px/1 var(--sans); color: var(--accent); font-variant-numeric: tabular-nums; }
|
||||||
|
|
||||||
|
#quest .row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); opacity: 0; }
|
||||||
|
#quest .row:first-of-type { border-top: 0; }
|
||||||
|
#quest .ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; }
|
||||||
|
#quest .ico svg { width: 26px; height: 26px; }
|
||||||
|
#quest .nm { font: 700 26px/1.15 var(--sans); color: var(--ink); }
|
||||||
|
#quest .ds { font: 500 18px/1.2 var(--sans); color: var(--muted); margin-top: 3px; }
|
||||||
|
#quest .pill { margin-left: auto; flex: none; }
|
||||||
|
|
||||||
|
/* store art */
|
||||||
|
#shots { inset: 0; z-index: 15; pointer-events: none; }
|
||||||
|
#shots .card { position: absolute; left: 0; top: 0; border-radius: 26px; overflow: hidden; opacity: 0;
|
||||||
|
box-shadow: 0 40px 90px -20px rgba(0,0,0,.9), 0 0 0 2px rgba(255,255,255,.12); background: #1e1b4b; }
|
||||||
|
#shots .card img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
||||||
|
#shots .lang { position: absolute; z-index: 3; font: 800 30px/1 var(--mono); padding: 12px 20px; border-radius: 999px; background: var(--accent); color: #0b1120; opacity: 0; transform: translateX(-50%); }
|
||||||
|
#sizes { z-index: 25; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
|
||||||
|
#sizes .sz { font: 700 22px/1 var(--sans); padding: 10px 16px; border-radius: 999px; background: rgba(15,23,42,.92); border: 2px solid var(--line-2); color: #64748b; opacity: 0; }
|
||||||
|
#sizes .sz.on { color: #0b1120; background: #fcd34d; border-color: #fcd34d; }
|
||||||
|
|
||||||
|
/* end cards */
|
||||||
|
#submit, #brand { inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; opacity: 0; }
|
||||||
|
#submit .kick { font: 700 40px/1.2 var(--sans); color: var(--muted); }
|
||||||
|
#submit .btn { position: relative; margin: 46px 0 40px; padding: 40px 74px; border-radius: 999px; font: 800 70px/1 var(--sans); letter-spacing: -0.01em;
|
||||||
|
color: #fff; background: linear-gradient(180deg, #6366f1, #4338ca); box-shadow: 0 30px 90px -20px rgba(79,70,229,.9), inset 0 2px 0 rgba(255,255,255,.25), 0 0 0 3px rgba(165,180,252,.35); }
|
||||||
|
#submit .ring { position: absolute; inset: -16px; border-radius: 999px; border: 4px solid rgba(165,180,252,.6); opacity: 0; }
|
||||||
|
#submit .yours { font: 900 120px/1 var(--sans); letter-spacing: -0.03em; color: var(--you-ink); }
|
||||||
|
#submit .yours .pill { font-size: 30px; padding: 10px 20px; vertical-align: 26px; margin-left: 10px; }
|
||||||
|
#submit .fine { margin-top: 34px; font: 600 30px/1.3 var(--sans); color: var(--muted); }
|
||||||
|
#cursor { z-index: 45; width: 64px; height: 64px; opacity: 0; filter: drop-shadow(0 6px 10px rgba(0,0,0,.6)); }
|
||||||
|
|
||||||
|
#brand .mark { width: 200px; height: 200px; border-radius: 48px; background: linear-gradient(180deg, #6366f1, #4338ca); display: grid; place-items: center;
|
||||||
|
box-shadow: 0 30px 100px -20px rgba(79,70,229,.95), inset 0 3px 0 rgba(255,255,255,.25); }
|
||||||
|
#brand .mark svg { width: 120px; height: 120px; }
|
||||||
|
#brand .word { margin-top: 40px; font: 900 150px/1 var(--sans); letter-spacing: -0.045em; }
|
||||||
|
#brand .tag { margin-top: 30px; font: 600 42px/1.25 var(--sans); color: var(--ink-2); max-width: 860px; }
|
||||||
|
#brand .tag b { color: var(--accent); font-weight: 800; }
|
||||||
|
#brand .url { margin-top: 46px; font: 800 66px/1 var(--sans); color: var(--accent); letter-spacing: -0.01em; }
|
||||||
|
#brand .meta { margin-top: 24px; font: 700 34px/1 var(--sans); color: var(--muted); letter-spacing: .02em; }
|
||||||
|
#brand .inst { margin-top: 40px; font: 700 34px/1 var(--mono); padding: 22px 34px; border-radius: 20px; background: rgba(6,10,20,.92); border: 2px solid var(--line-2); color: var(--ink); }
|
||||||
|
#brand .inst span { color: var(--green); margin-right: 16px; }
|
||||||
|
#brand > * { will-change: transform, opacity; }
|
||||||
|
|
||||||
|
/* vertical 1080 x 1920 */
|
||||||
|
.v #caption { left: 80px; right: 80px; top: 250px; height: 330px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; text-align: center; font-size: 112px; }
|
||||||
|
.v #caption .sub { font-size: 30px; }
|
||||||
|
.v #term { left: 70px; width: 940px; top: 630px; height: 850px; }
|
||||||
|
.v #term .body { font-size: 28px; }
|
||||||
|
.v #term .pin { font-size: 26px; }
|
||||||
|
.v #quest { top: 900px; }
|
||||||
|
.v .panel { left: 104px; width: 872px; top: 1020px; }
|
||||||
|
.v #sizes { left: 110px; right: 110px; top: 1385px; }
|
||||||
|
|
||||||
|
/* horizontal 1920 x 1080 */
|
||||||
|
.h #caption { left: 120px; width: 760px; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: left; font-size: 108px; }
|
||||||
|
.h #caption .sub { font-size: 28px; }
|
||||||
|
.h #term { left: 900px; width: 920px; top: 110px; height: 860px; }
|
||||||
|
.h .panel { left: 950px; width: 820px; top: 470px; }
|
||||||
|
.h #quest { top: 330px; }
|
||||||
|
.h #sizes { left: 120px; width: 700px; top: 760px; justify-content: flex-start; }
|
||||||
|
.h #brand .word { font-size: 140px; }
|
||||||
|
.h #brand .mark { width: 170px; height: 170px; border-radius: 42px; }
|
||||||
|
.h #brand .mark svg { width: 102px; height: 102px; }
|
||||||
|
.h #brand .tag { max-width: 1200px; margin-top: 24px; }
|
||||||
|
.h #brand .url { margin-top: 36px; }
|
||||||
|
.h #brand .inst { margin-top: 32px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="stage">
|
||||||
|
<div id="bg"><div class="grid"></div><div class="glow g1"></div><div class="glow g2"></div><div class="glow g3"></div><div class="vig"></div></div>
|
||||||
|
|
||||||
|
<div id="term">
|
||||||
|
<div class="bar"><span class="dot"></span><span class="dot"></span><span class="dot"></span>
|
||||||
|
<span class="agent"><i></i>your AI agent</span><span class="title">prism-puddle · scripted demo</span></div>
|
||||||
|
<div class="body"><div class="pin"></div><div class="lines"></div></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="prices" class="panel">
|
||||||
|
<h4>Regional prices <span class="pill p-api">API</span></h4>
|
||||||
|
<p class="ph">USD base · Play converts per region · your overrides</p>
|
||||||
|
<table><thead><tr><th>region</th><th>cur</th><th>remove_ads</th><th>drops_500</th></tr></thead><tbody></tbody></table>
|
||||||
|
<div class="sum"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="langs" class="panel">
|
||||||
|
<h4>Store listings <span class="pill p-api">API</span><span class="count">0/14</span></h4>
|
||||||
|
<p class="ph">title · short + full description · keywords · per language</p>
|
||||||
|
<div class="chips"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="quest" class="panel">
|
||||||
|
<h4>Store questionnaires</h4>
|
||||||
|
<p class="ph">API where the stores have one · a skill where they do not</p>
|
||||||
|
<div class="rows"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="shots"></div>
|
||||||
|
<div id="sizes"></div>
|
||||||
|
|
||||||
|
<div id="caption"></div>
|
||||||
|
|
||||||
|
<div id="submit">
|
||||||
|
<div class="kick">storebound never presses Submit.</div>
|
||||||
|
<div class="btn"><span class="ring"></span>Submit for review</div>
|
||||||
|
<div class="yours">your click.<span class="pill p-you">YOU</span></div>
|
||||||
|
<div class="fine">Play: Send changes for review · App Store: Submit for Review</div>
|
||||||
|
</div>
|
||||||
|
<svg id="cursor" viewBox="0 0 32 32" aria-hidden="true"><path d="M6 3 L6 25 L11.5 20 L15.5 29 L19.5 27.2 L15.6 18.6 L23 18.2 Z" fill="#fff" stroke="#0b1120" stroke-width="2" stroke-linejoin="round"/></svg>
|
||||||
|
|
||||||
|
<div id="brand">
|
||||||
|
<div class="mark"><svg viewBox="0 0 32 32" aria-hidden="true"><path d="M16 7v12M10.5 12.5 16 7l5.5 5.5M8 18v5.5h16V18" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg></div>
|
||||||
|
<div class="word">storebound</div>
|
||||||
|
<div class="tag">From zero to <b>“Submit for review”</b><br>on Google Play and the App Store.</div>
|
||||||
|
<div class="url">storebound.dev</div>
|
||||||
|
<div class="meta">open source · MIT</div>
|
||||||
|
<div class="inst"><span>$</span>bunx storebound init</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="flash"></div>
|
||||||
|
</div>
|
||||||
|
<script type="module" src="teaser.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
242
media/teaser/music.js
Normal file
242
media/teaser/music.js
Normal file
|
|
@ -0,0 +1,242 @@
|
||||||
|
// Original teaser music, synthesized from nothing with the Web Audio API (OfflineAudioContext): no samples, no
|
||||||
|
// downloaded audio. 128 BPM, F minor, tight 16th arpeggio, kick / hats / clap, offbeat bass, a pad, impacts on every
|
||||||
|
// scene cut (script.js CUTS), key clicks on every typed character, a riser into the end card. Deterministic (seeded).
|
||||||
|
// renderWav() returns a 32-bit float stereo WAV (48 kHz) as base64; render.ts masters it with ffmpeg loudnorm.
|
||||||
|
import { BAR, BEAT, CUTS, DURATION, keyTimes, scene } from './script.js';
|
||||||
|
|
||||||
|
const SR = 48000;
|
||||||
|
const midi = m => 440 * Math.pow(2, (m - 69) / 12);
|
||||||
|
function rng(seed) { // mulberry32
|
||||||
|
let a = seed >>> 0;
|
||||||
|
return () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
|
||||||
|
}
|
||||||
|
|
||||||
|
// chords per bar (root midi in octave 3, intervals)
|
||||||
|
const CH = { Fm: [53, [0, 3, 7]], Db: [49, [0, 4, 7]], Ab: [56, [0, 4, 7]], Eb: [51, [0, 4, 7]] };
|
||||||
|
const BARS = ['Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Fm', 'Db', 'Ab', 'Eb', 'Eb', 'Db', 'Eb', 'Fm', 'Eb', 'Fm'];
|
||||||
|
const ARP = [0, 2, 4, 3, 5, 4, 2, 3, 0, 2, 4, 6, 5, 4, 3, 2];
|
||||||
|
|
||||||
|
export async function renderMusic() {
|
||||||
|
const ctx = new OfflineAudioContext({ numberOfChannels: 2, length: Math.ceil(DURATION * SR) + SR, sampleRate: SR });
|
||||||
|
const R = rng(20261010);
|
||||||
|
|
||||||
|
// shared noise
|
||||||
|
const noise = ctx.createBuffer(2, SR * 3, SR);
|
||||||
|
for (let c = 0; c < 2; c++) { const d = noise.getChannelData(c); for (let i = 0; i < d.length; i++) d[i] = R() * 2 - 1; }
|
||||||
|
|
||||||
|
// reverb impulse
|
||||||
|
const ir = ctx.createBuffer(2, Math.floor(SR * 2.6), SR);
|
||||||
|
for (let c = 0; c < 2; c++) { const d = ir.getChannelData(c); for (let i = 0; i < d.length; i++) d[i] = (R() * 2 - 1) * Math.pow(1 - i / d.length, 3.2); }
|
||||||
|
|
||||||
|
// buses
|
||||||
|
const comp = ctx.createDynamicsCompressor();
|
||||||
|
comp.threshold.value = -14; comp.knee.value = 6; comp.ratio.value = 3.5; comp.attack.value = 0.004; comp.release.value = 0.16;
|
||||||
|
const master = ctx.createGain(); master.gain.value = 0.7;
|
||||||
|
master.connect(comp); comp.connect(ctx.destination);
|
||||||
|
const verb = ctx.createConvolver(); verb.buffer = ir;
|
||||||
|
const verbIn = ctx.createGain(); verbIn.gain.value = 0.5; verbIn.connect(verb); verb.connect(master);
|
||||||
|
const duck = ctx.createGain(); duck.connect(master); // sidechained group: pad, bass, arp
|
||||||
|
const drums = ctx.createGain(); drums.gain.value = 0.9; drums.connect(master);
|
||||||
|
|
||||||
|
const arpBus = ctx.createGain(); arpBus.gain.value = 0.55;
|
||||||
|
const arpLP = ctx.createBiquadFilter(); arpLP.type = 'lowpass'; arpLP.Q.value = 6;
|
||||||
|
arpBus.connect(arpLP); arpLP.connect(duck);
|
||||||
|
// stereo echo on the arp
|
||||||
|
for (const [time, pan] of [[BEAT * 0.75, -0.6], [BEAT * 1.5, 0.6]]) {
|
||||||
|
const dl = ctx.createDelay(2); dl.delayTime.value = time;
|
||||||
|
const fb = ctx.createGain(); fb.gain.value = 0.28;
|
||||||
|
const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = 2600;
|
||||||
|
const p = ctx.createStereoPanner(); p.pan.value = pan;
|
||||||
|
const wet = ctx.createGain(); wet.gain.value = 0.32;
|
||||||
|
arpLP.connect(dl); dl.connect(lp); lp.connect(fb); fb.connect(dl); lp.connect(wet); wet.connect(p); p.connect(duck);
|
||||||
|
}
|
||||||
|
const arpVerb = ctx.createGain(); arpVerb.gain.value = 0.18; arpLP.connect(arpVerb); arpVerb.connect(verbIn);
|
||||||
|
|
||||||
|
// arp filter: closed intro, open drop, wide on the riser, dark under the Submit card, bright on the brand
|
||||||
|
const f = arpLP.frequency;
|
||||||
|
const at = s => scene(s).start;
|
||||||
|
f.setValueAtTime(420, 0);
|
||||||
|
f.exponentialRampToValueAtTime(2400, at('config') - 0.02);
|
||||||
|
f.setValueAtTime(3000, at('config'));
|
||||||
|
f.linearRampToValueAtTime(3400, at('submit') - BAR);
|
||||||
|
f.exponentialRampToValueAtTime(7000, at('submit') - 0.01);
|
||||||
|
f.setValueAtTime(900, at('submit'));
|
||||||
|
f.exponentialRampToValueAtTime(1800, at('brand') - 0.01);
|
||||||
|
f.setValueAtTime(4200, at('brand'));
|
||||||
|
f.setValueAtTime(4200, at('brand') + BAR * 2);
|
||||||
|
f.exponentialRampToValueAtTime(800, DURATION);
|
||||||
|
|
||||||
|
const env = (g, t, a, peak, d, end = 0.0005) => {
|
||||||
|
g.gain.setValueAtTime(0, t); g.gain.linearRampToValueAtTime(peak, t + a); g.gain.exponentialRampToValueAtTime(end, t + a + d);
|
||||||
|
};
|
||||||
|
const noiseSrc = (t, dur, off = R() * 1.5) => { const s = ctx.createBufferSource(); s.buffer = noise; s.start(t, off, dur); return s; };
|
||||||
|
|
||||||
|
// ---- voices ----
|
||||||
|
function kick(t, g = 1) {
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sine';
|
||||||
|
o.frequency.setValueAtTime(155, t); o.frequency.exponentialRampToValueAtTime(44, t + 0.11);
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.002, 1.0 * g, 0.42);
|
||||||
|
o.connect(v); v.connect(drums); o.start(t); o.stop(t + 0.5);
|
||||||
|
const n = noiseSrc(t, 0.01); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 3500;
|
||||||
|
const nv = ctx.createGain(); env(nv, t, 0.001, 0.22 * g, 0.012); n.connect(hp); hp.connect(nv); nv.connect(drums);
|
||||||
|
duck.gain.setValueAtTime(0.28, t); duck.gain.linearRampToValueAtTime(1, t + 0.22);
|
||||||
|
}
|
||||||
|
function hat(t, g, pan) {
|
||||||
|
const n = noiseSrc(t, 0.06); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = 7500;
|
||||||
|
const p = ctx.createStereoPanner(); p.pan.value = pan;
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.001, g, 0.04); n.connect(hp); hp.connect(v); v.connect(p); p.connect(drums);
|
||||||
|
}
|
||||||
|
function clap(t, g = 0.4) {
|
||||||
|
const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 1300; bp.Q.value = 0.9;
|
||||||
|
const v = ctx.createGain(); v.gain.setValueAtTime(0, t);
|
||||||
|
for (let i = 0; i < 3; i++) { v.gain.setValueAtTime(g, t + i * 0.011); v.gain.exponentialRampToValueAtTime(g * 0.2, t + i * 0.011 + 0.009); }
|
||||||
|
v.gain.setValueAtTime(g * 0.8, t + 0.034); v.gain.exponentialRampToValueAtTime(0.0005, t + 0.2);
|
||||||
|
const n = noiseSrc(t, 0.25); n.connect(bp); bp.connect(v); v.connect(drums);
|
||||||
|
const s = ctx.createGain(); s.gain.value = 0.5; v.connect(s); s.connect(verbIn);
|
||||||
|
}
|
||||||
|
function snare(t, g) {
|
||||||
|
const n = noiseSrc(t, 0.12); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 1900; bp.Q.value = 0.7;
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.001, g, 0.09); n.connect(bp); bp.connect(v); v.connect(drums);
|
||||||
|
const o = ctx.createOscillator(); o.type = 'triangle'; o.frequency.setValueAtTime(240, t); o.frequency.exponentialRampToValueAtTime(160, t + 0.05);
|
||||||
|
const ov = ctx.createGain(); env(ov, t, 0.001, g * 0.5, 0.06); o.connect(ov); ov.connect(drums); o.start(t); o.stop(t + 0.12);
|
||||||
|
}
|
||||||
|
function arpNote(t, m, g = 0.12, len = 0.17) {
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.003, g, len); v.connect(arpBus);
|
||||||
|
for (const [type, det] of [['sawtooth', -7], ['square', 7]]) {
|
||||||
|
const o = ctx.createOscillator(); o.type = type; o.frequency.value = midi(m); o.detune.value = det;
|
||||||
|
const og = ctx.createGain(); og.gain.value = type === 'square' ? 0.5 : 0.8;
|
||||||
|
o.connect(og); og.connect(v); o.start(t); o.stop(t + len + 0.05);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function bass(t, m, g = 0.32, len = BEAT * 0.45) {
|
||||||
|
const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(900, t); lp.frequency.exponentialRampToValueAtTime(220, t + len); lp.Q.value = 4;
|
||||||
|
const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + 0.004); v.gain.setValueAtTime(g, t + len * 0.7); v.gain.linearRampToValueAtTime(0, t + len);
|
||||||
|
lp.connect(v); v.connect(duck);
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.connect(lp); o.start(t); o.stop(t + len + 0.02);
|
||||||
|
const sub = ctx.createOscillator(); sub.type = 'sine'; sub.frequency.value = midi(m - 12);
|
||||||
|
const sg = ctx.createGain(); sg.gain.value = 0.9; sub.connect(sg); sg.connect(v); sub.start(t); sub.stop(t + len + 0.02);
|
||||||
|
}
|
||||||
|
function pad(t, dur, notes, g = 0.05, cutoff = 1500) {
|
||||||
|
const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.value = cutoff; lp.Q.value = 0.7;
|
||||||
|
const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + 0.25); v.gain.setValueAtTime(g, t + dur - 0.1); v.gain.linearRampToValueAtTime(0, t + dur + 0.25);
|
||||||
|
lp.connect(v); v.connect(duck);
|
||||||
|
const s = ctx.createGain(); s.gain.value = 0.6; v.connect(s); s.connect(verbIn);
|
||||||
|
for (const m of notes) for (const det of [-9, 9]) {
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.detune.value = det;
|
||||||
|
const p = ctx.createStereoPanner(); p.pan.value = det < 0 ? -0.4 : 0.4;
|
||||||
|
o.connect(p); p.connect(lp); o.start(t); o.stop(t + dur + 0.3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function impact(t, big = false) {
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sine';
|
||||||
|
o.frequency.setValueAtTime(big ? 120 : 100, t); o.frequency.exponentialRampToValueAtTime(32, t + (big ? 0.9 : 0.5));
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.003, big ? 0.95 : 0.6, big ? 1.3 : 0.6); o.connect(v); v.connect(master); o.start(t); o.stop(t + 1.6);
|
||||||
|
const n = noiseSrc(t, 2.0); const hp = ctx.createBiquadFilter(); hp.type = 'highpass'; hp.frequency.value = big ? 1800 : 3200;
|
||||||
|
const nv = ctx.createGain(); env(nv, t, 0.002, big ? 0.32 : 0.16, big ? 1.8 : 0.9); n.connect(hp); hp.connect(nv); nv.connect(master);
|
||||||
|
const s = ctx.createGain(); s.gain.value = big ? 0.7 : 0.4; nv.connect(s); s.connect(verbIn);
|
||||||
|
}
|
||||||
|
function stab(t, name, g = 0.09) {
|
||||||
|
const [root, iv] = CH[name];
|
||||||
|
const notes = [root - 12, ...iv.map(i => root + i), ...iv.map(i => root + 12 + i)];
|
||||||
|
const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(5000, t); lp.frequency.exponentialRampToValueAtTime(600, t + 1.4);
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.004, g, 1.6); lp.connect(v); v.connect(master);
|
||||||
|
const s = ctx.createGain(); s.gain.value = 0.8; v.connect(s); s.connect(verbIn);
|
||||||
|
for (const m of notes) for (const det of [-11, 0, 11]) {
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.value = midi(m); o.detune.value = det;
|
||||||
|
o.connect(lp); o.start(t); o.stop(t + 1.8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function whoosh(t, dur, g = 0.22, from = 500, to = 7000) {
|
||||||
|
const n = noiseSrc(t, dur + 0.05); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.Q.value = 2.2;
|
||||||
|
bp.frequency.setValueAtTime(from, t); bp.frequency.exponentialRampToValueAtTime(to, t + dur);
|
||||||
|
const v = ctx.createGain(); v.gain.setValueAtTime(0.0001, t); v.gain.exponentialRampToValueAtTime(g, t + dur * 0.95); v.gain.linearRampToValueAtTime(0, t + dur);
|
||||||
|
n.connect(bp); bp.connect(v); v.connect(master);
|
||||||
|
}
|
||||||
|
function riser(t, dur, g = 0.07) {
|
||||||
|
whoosh(t, dur, 0.3, 300, 9000);
|
||||||
|
const o = ctx.createOscillator(); o.type = 'sawtooth'; o.frequency.setValueAtTime(midi(53), t); o.frequency.exponentialRampToValueAtTime(midi(77), t + dur);
|
||||||
|
const lp = ctx.createBiquadFilter(); lp.type = 'lowpass'; lp.frequency.setValueAtTime(800, t); lp.frequency.exponentialRampToValueAtTime(6000, t + dur);
|
||||||
|
const v = ctx.createGain(); v.gain.setValueAtTime(0, t); v.gain.linearRampToValueAtTime(g, t + dur); v.gain.linearRampToValueAtTime(0, t + dur + 0.02);
|
||||||
|
o.connect(lp); lp.connect(v); v.connect(master); o.start(t); o.stop(t + dur + 0.05);
|
||||||
|
}
|
||||||
|
function key(t, g) {
|
||||||
|
const n = noiseSrc(t, 0.02); const bp = ctx.createBiquadFilter(); bp.type = 'bandpass'; bp.frequency.value = 2600 + R() * 2600; bp.Q.value = 3;
|
||||||
|
const p = ctx.createStereoPanner(); p.pan.value = R() * 0.5 - 0.25;
|
||||||
|
const v = ctx.createGain(); env(v, t, 0.0008, g * (0.7 + R() * 0.6), 0.012); n.connect(bp); bp.connect(v); v.connect(p); p.connect(master);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- arrangement ----
|
||||||
|
const sub = scene('submit').start, brand = scene('brand').start, drop = scene('config').start;
|
||||||
|
const rollBar = scene('validate').end - BAR; // last bar before the Submit card
|
||||||
|
duck.gain.setValueAtTime(1, 0);
|
||||||
|
for (let b = 0; b < 20; b++) {
|
||||||
|
const t0 = b * BAR, name = BARS[b], [root, iv] = CH[name];
|
||||||
|
const tones = [0, iv[1], iv[2], 12, 12 + iv[1], 12 + iv[2], 24].map(x => root + 12 + x);
|
||||||
|
const main = t0 >= drop && t0 < sub, end = b === 19, calm = t0 >= sub && t0 < brand;
|
||||||
|
const groove = main || (t0 >= brand && !end);
|
||||||
|
// pad
|
||||||
|
if (!end) pad(t0, BAR, [root, root + iv[1], root + iv[2], root + 12], calm ? 0.06 : t0 < drop ? 0.045 : 0.035, calm ? 1100 : 1500);
|
||||||
|
for (let s = 0; s < 16; s++) {
|
||||||
|
const t = t0 + s * BEAT / 4;
|
||||||
|
const beat = s % 4 === 0, off = s % 4 === 2;
|
||||||
|
const cutDrums = t0 === rollBar && s >= 8; // drums drop out for the last half bar of the riser
|
||||||
|
// arp
|
||||||
|
if (!end) {
|
||||||
|
if (calm) { if (s % 2 === 0) arpNote(t, tones[ARP[s]] ?? root, 0.09, 0.3); }
|
||||||
|
else arpNote(t, tones[ARP[s]] ?? root, t0 < drop ? 0.08 : 0.11, 0.16);
|
||||||
|
}
|
||||||
|
if (groove && !cutDrums) {
|
||||||
|
if (beat) kick(t);
|
||||||
|
if (off) { hat(t, 0.14, 0.2); bass(t, root - 12); }
|
||||||
|
else if (!beat) hat(t, 0.045, -0.2);
|
||||||
|
if (t0 >= drop + BAR * 2 && (s === 4 || s === 12)) clap(t);
|
||||||
|
}
|
||||||
|
if (calm && off) hat(t, 0.05, 0.15);
|
||||||
|
if (b === 1 && s >= 8 && s % 2 === 0) hat(t, 0.02 + 0.06 * (s - 8) / 8, 0); // intro tick-in
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// snare roll + riser into the Submit card
|
||||||
|
for (let i = 0; i < 8; i++) snare(rollBar + i * BEAT / 4, 0.04 + 0.1 * i / 7);
|
||||||
|
for (let i = 0; i < 16; i++) snare(rollBar + BAR / 2 + i * BEAT / 8, 0.14 + 0.18 * i / 15);
|
||||||
|
riser(rollBar, BAR);
|
||||||
|
riser(brand - BAR / 2, BAR / 2, 0.05);
|
||||||
|
whoosh(drop - BAR / 2, BAR / 2, 0.25);
|
||||||
|
// hits on the cuts
|
||||||
|
for (const c of CUTS) {
|
||||||
|
const big = c === sub || c === brand;
|
||||||
|
if (!big && c !== drop) whoosh(c - 0.32, 0.32, 0.16, 800, 6000);
|
||||||
|
impact(c, big || c === drop);
|
||||||
|
}
|
||||||
|
stab(drop, 'Fm', 0.06);
|
||||||
|
stab(sub, 'Db', 0.1);
|
||||||
|
stab(brand, 'Fm', 0.1);
|
||||||
|
stab(19 * BAR, 'Fm', 0.11);
|
||||||
|
impact(19 * BAR, true);
|
||||||
|
kick(19 * BAR, 1);
|
||||||
|
// key clicks
|
||||||
|
for (const t of keyTimes()) key(t, t < drop ? 0.16 : 0.07);
|
||||||
|
|
||||||
|
const buf = await ctx.startRendering();
|
||||||
|
const n = Math.round(DURATION * SR);
|
||||||
|
return { sampleRate: SR, left: buf.getChannelData(0).slice(0, n), right: buf.getChannelData(1).slice(0, n) };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 32-bit float stereo WAV, base64. */
|
||||||
|
export async function renderWav() {
|
||||||
|
const { sampleRate, left, right } = await renderMusic();
|
||||||
|
const n = left.length, bytes = 44 + n * 8;
|
||||||
|
const ab = new ArrayBuffer(bytes), dv = new DataView(ab);
|
||||||
|
const str = (o, s) => { for (let i = 0; i < s.length; i++) dv.setUint8(o + i, s.charCodeAt(i)); };
|
||||||
|
str(0, 'RIFF'); dv.setUint32(4, bytes - 8, true); str(8, 'WAVE'); str(12, 'fmt ');
|
||||||
|
dv.setUint32(16, 16, true); dv.setUint16(20, 3, true); dv.setUint16(22, 2, true); dv.setUint32(24, sampleRate, true);
|
||||||
|
dv.setUint32(28, sampleRate * 8, true); dv.setUint16(32, 8, true); dv.setUint16(34, 32, true); str(36, 'data'); dv.setUint32(40, n * 8, true);
|
||||||
|
let peak = 0;
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
dv.setFloat32(44 + i * 8, left[i], true); dv.setFloat32(48 + i * 8, right[i], true);
|
||||||
|
peak = Math.max(peak, Math.abs(left[i]), Math.abs(right[i]));
|
||||||
|
}
|
||||||
|
const u8 = new Uint8Array(ab);
|
||||||
|
let bin = '';
|
||||||
|
for (let i = 0; i < u8.length; i += 0x8000) bin += String.fromCharCode.apply(null, u8.subarray(i, i + 0x8000));
|
||||||
|
return { base64: btoa(bin), peak, seconds: n / sampleRate };
|
||||||
|
}
|
||||||
BIN
media/teaser/poster.jpg
Normal file
BIN
media/teaser/poster.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
133
media/teaser/render.ts
Normal file
133
media/teaser/render.ts
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
#!/usr/bin/env bun
|
||||||
|
// Renders the storebound teaser: frames from index.html (Playwright, headless Chrome) piped into ffmpeg, plus the
|
||||||
|
// original music (music.js, OfflineAudioContext in the same browser), mastered to about -14 LUFS.
|
||||||
|
// bun media/teaser/render.ts both formats, music, posters -> media/teaser/out/
|
||||||
|
// bun media/teaser/render.ts --only v vertical only (v = 1080x1920, h = 1920x1080)
|
||||||
|
// bun media/teaser/render.ts --stills 1,9.5,30 PNG stills only (out/stills/), quick layout check
|
||||||
|
// bun media/teaser/render.ts --serve preview server: open /index.html?w=1080&h=1920&play=1
|
||||||
|
// Needs ffmpeg and Playwright (devDependency; Playwright's Chromium or an installed Google Chrome).
|
||||||
|
import { existsSync, mkdirSync, statSync } from 'node:fs';
|
||||||
|
import { join } from 'node:path';
|
||||||
|
import { launch } from '../../cli/shots/browser';
|
||||||
|
|
||||||
|
const DIR = import.meta.dir;
|
||||||
|
const ROOT = join(DIR, '../..');
|
||||||
|
const OUT = join(DIR, 'out');
|
||||||
|
const ASSETS = join(OUT, 'assets');
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const opt = (k: string): string | undefined => { const i = args.indexOf(`--${k}`); return i >= 0 ? args[i + 1] : undefined; };
|
||||||
|
const FORMATS = [{ id: 'v', w: 1080, h: 1920 }, { id: 'h', w: 1920, h: 1080 }].filter(f => !opt('only') || opt('only') === f.id);
|
||||||
|
const log = (m: string): void => console.log(`${new Date().toISOString().slice(11, 19)} [teaser] ${m}`);
|
||||||
|
|
||||||
|
function sh(cmd: string[], input?: Uint8Array): void {
|
||||||
|
const r = Bun.spawnSync(cmd, { stdin: input, stdout: 'pipe', stderr: 'pipe' });
|
||||||
|
if (r.exitCode !== 0) throw new Error(`${cmd.slice(0, 3).join(' ')} failed:\n${r.stderr.toString().slice(-2000)}`);
|
||||||
|
}
|
||||||
|
const ff = (...a: string[]): void => sh(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-y', ...a]);
|
||||||
|
|
||||||
|
/** Screenshots used by the store-art scene: the demo game's real renders, or crops of docs/img/showcase.jpg. */
|
||||||
|
function prepAssets(): void {
|
||||||
|
mkdirSync(ASSETS, { recursive: true });
|
||||||
|
const names = ['en-01', 'en-02', 'en-03', 'en-04', 'tr-01', 'ja-01', 'ar-01'];
|
||||||
|
const renders = join(ROOT, 'examples/demo-game/store/renders');
|
||||||
|
const src = (n: string): string => { const [l, k] = n.split('-'); return join(renders, l!, 'play', `${k}.png`); };
|
||||||
|
if (names.every(n => existsSync(src(n)))) {
|
||||||
|
for (const n of names) ff('-i', src(n), '-vf', 'scale=720:1280:flags=lanczos', '-q:v', '2', join(ASSETS, `${n}.jpg`));
|
||||||
|
log('assets: demo game renders (examples/demo-game/store/renders)');
|
||||||
|
} else {
|
||||||
|
// showcase.jpg: 7 panes (en 01-04, tr, ja, ar hero), 263 x 571 each, 283 px apart, from (20, 20)
|
||||||
|
const show = join(ROOT, 'docs/img/showcase.jpg');
|
||||||
|
names.forEach((n, i) => ff('-i', show, '-vf', `crop=263:468:${20 + i * 283}:20,scale=720:1280:flags=lanczos`, '-q:v', '2', join(ASSETS, `${n}.jpg`)));
|
||||||
|
log('assets: demo renders not found, using crops of docs/img/showcase.jpg (run the demo\'s `shots render` for sharper art)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function serve(): ReturnType<typeof Bun.serve> {
|
||||||
|
return Bun.serve({
|
||||||
|
port: Number(opt('port') ?? 0),
|
||||||
|
fetch(req) {
|
||||||
|
const p = decodeURIComponent(new URL(req.url).pathname).replace(/^\/+/, '') || 'index.html';
|
||||||
|
if (p.includes('..')) return new Response('no', { status: 400 });
|
||||||
|
const f = Bun.file(join(DIR, p));
|
||||||
|
return f.size ? new Response(f) : new Response('not found', { status: 404 });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main(): Promise<void> {
|
||||||
|
mkdirSync(OUT, { recursive: true });
|
||||||
|
prepAssets();
|
||||||
|
const server = serve();
|
||||||
|
const base = `http://127.0.0.1:${server.port}/index.html`;
|
||||||
|
if (args.includes('--serve')) { log(`preview: ${base}?w=1080&h=1920&play=1`); return; }
|
||||||
|
|
||||||
|
const browser = await launch(ROOT, { headless: true });
|
||||||
|
try {
|
||||||
|
const stills = opt('stills');
|
||||||
|
for (const f of FORMATS) {
|
||||||
|
const page = await browser.newPage({ viewport: { width: f.w, height: f.h }, deviceScaleFactor: 1 });
|
||||||
|
page.on('pageerror', (e: Error) => console.error('page error:', e.message));
|
||||||
|
await page.goto(`${base}?w=${f.w}&h=${f.h}`);
|
||||||
|
await page.evaluate('window.teaser.ready');
|
||||||
|
const { DURATION, FPS } = await page.evaluate('({ DURATION: teaser.DURATION, FPS: teaser.FPS })') as { DURATION: number; FPS: number };
|
||||||
|
const shot = async (t: number): Promise<Buffer> => {
|
||||||
|
await page.evaluate(`teaser.seek(${t})`);
|
||||||
|
return page.screenshot({ type: 'png' });
|
||||||
|
};
|
||||||
|
if (stills) {
|
||||||
|
mkdirSync(join(OUT, 'stills'), { recursive: true });
|
||||||
|
for (const t of stills.split(',').map(Number)) {
|
||||||
|
await Bun.write(join(OUT, 'stills', `${f.id}-${t.toFixed(2)}.png`), await shot(t));
|
||||||
|
}
|
||||||
|
log(`${f.id}: ${stills.split(',').length} stills in out/stills`);
|
||||||
|
await page.close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const frames = Math.round(DURATION * FPS);
|
||||||
|
const silent = join(OUT, `teaser-${f.w}x${f.h}-silent.mp4`);
|
||||||
|
const enc = Bun.spawn(['ffmpeg', '-hide_banner', '-loglevel', 'error', '-y', '-f', 'image2pipe', '-framerate', String(FPS), '-c:v', 'png', '-i', '-',
|
||||||
|
'-c:v', 'libx264', '-profile:v', 'high', '-preset', 'slow', '-crf', '17', '-pix_fmt', 'yuv420p', '-r', String(FPS),
|
||||||
|
'-g', String(FPS * 2), '-movflags', '+faststart', silent], { stdin: 'pipe', stdout: 'inherit', stderr: 'inherit' });
|
||||||
|
const t0 = Date.now();
|
||||||
|
for (let i = 0; i < frames; i++) {
|
||||||
|
enc.stdin.write(await shot(i / FPS));
|
||||||
|
if (i % 60 === 0 || i === frames - 1) {
|
||||||
|
const el = (Date.now() - t0) / 1000;
|
||||||
|
log(`${f.id}: frame ${i + 1}/${frames} · ${el.toFixed(0)}s · eta ${((frames - i - 1) * el / (i + 1)).toFixed(0)}s`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await enc.stdin.end();
|
||||||
|
if (await enc.exited !== 0) throw new Error('ffmpeg encode failed');
|
||||||
|
ff('-ss', String(DURATION - 0.5), '-i', silent, '-frames:v', '1', '-q:v', '3', join(OUT, `poster-${f.w}x${f.h}.jpg`));
|
||||||
|
log(`${f.id}: ${silent} (${(statSync(silent).size / 1e6).toFixed(1)} MB)`);
|
||||||
|
await page.close();
|
||||||
|
}
|
||||||
|
if (stills || args.includes('--no-audio')) return;
|
||||||
|
|
||||||
|
// music
|
||||||
|
const page = await browser.newPage();
|
||||||
|
await page.goto(base);
|
||||||
|
log('music: rendering (OfflineAudioContext)');
|
||||||
|
const wav = await page.evaluate(`import('./music.js').then(m => m.renderWav())`) as { base64: string; peak: number; seconds: number };
|
||||||
|
log(`music: ${wav.seconds.toFixed(2)} s, raw peak ${wav.peak.toFixed(3)}`);
|
||||||
|
const raw = join(OUT, 'music-raw.wav'), music = join(OUT, 'music.wav');
|
||||||
|
await Bun.write(raw, Buffer.from(wav.base64, 'base64'));
|
||||||
|
const dur = wav.seconds;
|
||||||
|
// two-pass loudnorm to -14 LUFS / -1 dBTP, then a 2 s fade out
|
||||||
|
const m = Bun.spawnSync(['ffmpeg', '-hide_banner', '-i', raw, '-af', 'loudnorm=I=-14:TP=-1.5:LRA=11:print_format=json', '-f', 'null', '-'], { stderr: 'pipe' });
|
||||||
|
const j = JSON.parse(m.stderr.toString().match(/\{[\s\S]*?\}/)![0]) as Record<string, string>;
|
||||||
|
ff('-i', raw, '-af', `loudnorm=I=-14:TP=-1.5:LRA=11:measured_I=${j.input_i}:measured_TP=${j.input_tp}:measured_LRA=${j.input_lra}:measured_thresh=${j.input_thresh}:offset=${j.target_offset}:linear=true,afade=t=out:st=${(dur - 2).toFixed(2)}:d=2,aresample=48000`,
|
||||||
|
'-c:a', 'pcm_s16le', '-ar', '48000', '-ac', '2', music);
|
||||||
|
for (const f of FORMATS) {
|
||||||
|
const silent = join(OUT, `teaser-${f.w}x${f.h}-silent.mp4`), out = join(OUT, `teaser-${f.w}x${f.h}.mp4`);
|
||||||
|
if (!existsSync(silent)) continue;
|
||||||
|
ff('-i', silent, '-i', music, '-map', '0:v', '-map', '1:a', '-c:v', 'copy', '-c:a', 'aac', '-b:a', '192k', '-ar', '48000', '-ac', '2', '-shortest', '-movflags', '+faststart', out);
|
||||||
|
log(`${out} (${(statSync(out).size / 1e6).toFixed(1)} MB)`);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
server.stop(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await main();
|
||||||
142
media/teaser/script.js
Normal file
142
media/teaser/script.js
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
// Teaser timeline: the single source of truth for the picture (teaser.js) and the music (music.js).
|
||||||
|
// Everything is a pure function of time, so a frame at t always looks the same and the hits land on the cuts.
|
||||||
|
// The terminal text is scripted, modelled on real storebound output for the demo game (examples/demo-game,
|
||||||
|
// placeholder ids, dry runs). Nothing here talks to a store.
|
||||||
|
|
||||||
|
export const BPM = 128;
|
||||||
|
export const BEAT = 60 / BPM; // 0.46875 s
|
||||||
|
export const BAR = BEAT * 4; // 1.875 s
|
||||||
|
export const FPS = 30;
|
||||||
|
export const BARS = 20;
|
||||||
|
export const DURATION = BARS * BAR; // 37.5 s
|
||||||
|
|
||||||
|
/** Scenes in bars; start/end in seconds are derived below. */
|
||||||
|
const SCENE_BARS = [
|
||||||
|
['prompt', 2],
|
||||||
|
['config', 2],
|
||||||
|
['prices', 2],
|
||||||
|
['languages', 2],
|
||||||
|
['questionnaires', 2],
|
||||||
|
['shots', 3],
|
||||||
|
['validate', 2],
|
||||||
|
['submit', 2],
|
||||||
|
['brand', 3],
|
||||||
|
];
|
||||||
|
let acc = 0;
|
||||||
|
export const SCENES = SCENE_BARS.map(([id, bars]) => {
|
||||||
|
const s = { id, start: acc * BAR, end: (acc + bars) * BAR, bars };
|
||||||
|
acc += bars;
|
||||||
|
return s;
|
||||||
|
});
|
||||||
|
export const scene = id => SCENES.find(s => s.id === id);
|
||||||
|
|
||||||
|
export const PROMPT = 'ship Prism Puddle to Google Play and the App Store';
|
||||||
|
export const PROMPT_AT = 0.35; // seconds
|
||||||
|
export const PROMPT_CPS = 21; // the user types
|
||||||
|
export const CMD_CPS = 62; // the agent types
|
||||||
|
|
||||||
|
export const LANGS = ['en-US', 'tr-TR', 'de-DE', 'fr-FR', 'es-ES', 'es-419', 'it-IT', 'pt-BR', 'ja-JP', 'ko-KR', 'zh-CN', 'ru-RU', 'ar', 'hi-IN'];
|
||||||
|
|
||||||
|
// Price rows for the flicker panel: illustrative local price points for a 2.99 / 0.99 USD pair (Play converts from
|
||||||
|
// USD per region; TR is a config override, as in templates/storebound.config.ts).
|
||||||
|
export const PRICES = [
|
||||||
|
['US', 'USD', '2.99', '0.99'],
|
||||||
|
['TR', 'TRY', '99.99', '34.99'],
|
||||||
|
['DE', 'EUR', '2.99', '0.99'],
|
||||||
|
['GB', 'GBP', '2.79', '0.89'],
|
||||||
|
['JP', 'JPY', '450', '150'],
|
||||||
|
['BR', 'BRL', '14.90', '4.90'],
|
||||||
|
['IN', 'INR', '249', '79'],
|
||||||
|
['KR', 'KRW', '4,100', '1,300'],
|
||||||
|
['MX', 'MXN', '59.00', '19.00'],
|
||||||
|
['ID', 'IDR', '45,000', '15,000'],
|
||||||
|
['SA', 'SAR', '10.99', '3.69'],
|
||||||
|
['FR', 'EUR', '2.99', '0.99'],
|
||||||
|
['CA', 'CAD', '3.99', '1.39'],
|
||||||
|
['AU', 'AUD', '4.49', '1.49'],
|
||||||
|
];
|
||||||
|
|
||||||
|
export const BLOCKERS = [
|
||||||
|
['apple', 'build 12 is PROCESSING'],
|
||||||
|
['apple', 'ja: missing keywords'],
|
||||||
|
['apple', 'remove_ads: MISSING_METADATA'],
|
||||||
|
['apple', 'no app price schedule'],
|
||||||
|
['play', 'tr-TR: no listing'],
|
||||||
|
['play', 'drops_500: not on Play'],
|
||||||
|
['play', 'no release on any track'],
|
||||||
|
];
|
||||||
|
export const BLOCKERS_AT = 0.45; // first blocker line, relative to the validate scene
|
||||||
|
export const BLOCKER_GAP = 0.05;
|
||||||
|
export const FIX_AT = 1.05; // first flip to ok
|
||||||
|
export const FIX_GAP = 0.26;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminal lines per scene. at = seconds after the scene start.
|
||||||
|
* kind: cmd (typed by the agent), out (printed), note (agent comment), ok / bad (coloured output).
|
||||||
|
*/
|
||||||
|
const T = {
|
||||||
|
prompt: [
|
||||||
|
{ at: 2.85, kind: 'note', text: 'agent using storebound · dry runs first' },
|
||||||
|
],
|
||||||
|
config: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound init' },
|
||||||
|
{ at: 0.45, kind: 'out', text: '[init] create storebound.config.ts' },
|
||||||
|
{ at: 0.55, kind: 'out', text: '[init] create store/listing.md' },
|
||||||
|
{ at: 0.65, kind: 'out', text: '[init] create store/appstore.md' },
|
||||||
|
{ at: 0.75, kind: 'out', text: '[init] create store/declarations.md' },
|
||||||
|
{ at: 0.85, kind: 'out', text: '[init] create store/app-privacy.md' },
|
||||||
|
{ at: 0.95, kind: 'out', text: '[init] create store/privacy-policy.html' },
|
||||||
|
{ at: 1.875, kind: 'cmd', text: 'bunx storebound check' },
|
||||||
|
{ at: 2.3, kind: 'out', text: '[check] config ok: storebound.config.ts' },
|
||||||
|
{ at: 2.42, kind: 'out', text: '[check] play listing: 14 languages' },
|
||||||
|
{ at: 2.54, kind: 'out', text: '[check] appstore listing: 14 locales' },
|
||||||
|
{ at: 2.66, kind: 'out', text: '[check] data safety: 764 CSV rows' },
|
||||||
|
{ at: 2.78, kind: 'out', text: '[check] shots copy: 14 languages x 4 scenes' },
|
||||||
|
],
|
||||||
|
prices: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound play products --dry' },
|
||||||
|
{ at: 0.62, kind: 'out', text: '[play] 1/2 remove_ads: create · 173 regions (dry)' },
|
||||||
|
{ at: 0.9, kind: 'out', text: '[play] 2/2 drops_500: create · 173 regions (dry)' },
|
||||||
|
{ at: 1.4, kind: 'cmd', text: 'bunx storebound apple iap --dry' },
|
||||||
|
{ at: 1.95, kind: 'out', text: '[apple] 1/2 remove_ads: missing (dry)' },
|
||||||
|
{ at: 2.07, kind: 'out', text: '[apple] 2/2 drops_500: missing (dry)' },
|
||||||
|
],
|
||||||
|
languages: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound play listing --dry' },
|
||||||
|
{ at: 0.6, kind: 'out', text: `[play] 14 listings: ${LANGS.slice(0, 4).join(', ')} ...` },
|
||||||
|
...LANGS.map((l, i) => ({ at: 0.8 + i * 0.13, kind: 'out', text: `[play] ${String(i + 1).padStart(2)}/14 ${l}` })),
|
||||||
|
],
|
||||||
|
questionnaires: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound play data-safety --dry' },
|
||||||
|
{ at: 0.62, kind: 'out', text: '[play] data safety: 6 data types declared' },
|
||||||
|
{ at: 0.95, kind: 'cmd', text: 'bunx storebound apple appinfo --dry' },
|
||||||
|
{ at: 1.55, kind: 'out', text: '[apple] categories: GAMES / GAMES_CASUAL (dry)' },
|
||||||
|
{ at: 1.67, kind: 'out', text: '[apple] age rating declaration: all NONE (dry)' },
|
||||||
|
{ at: 1.85, kind: 'note', text: '[apple] appinfo done (App Privacy is UI-only: store-declarations skill)' },
|
||||||
|
],
|
||||||
|
shots: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound shots render' },
|
||||||
|
...['play', 'tab7', 'tab10', 'ios69', 'ios65', 'ipad13', 'feature'].flatMap((d, k) =>
|
||||||
|
['en', 'tr', 'ja', 'ar'].map((l, j) => ({ at: 0.5 + (k * 4 + j) * 0.14, kind: 'out',
|
||||||
|
text: `[shots] store/renders/${l}/${d}/${d === 'feature' ? '1024x500' : '01'}.png` }))),
|
||||||
|
],
|
||||||
|
validate: [
|
||||||
|
{ at: 0.0, kind: 'cmd', text: 'bunx storebound validate' },
|
||||||
|
// the blocker lines are drawn by teaser.js from BLOCKERS (they change state)
|
||||||
|
],
|
||||||
|
};
|
||||||
|
export const TERMINAL = T;
|
||||||
|
|
||||||
|
/** Seconds at which each typed character lands (for key clicks in the music). */
|
||||||
|
export function keyTimes() {
|
||||||
|
const out = [];
|
||||||
|
for (let i = 0; i < PROMPT.length; i++) out.push(PROMPT_AT + i / PROMPT_CPS);
|
||||||
|
for (const s of SCENES) for (const l of T[s.id] ?? []) {
|
||||||
|
if (l.kind !== 'cmd') continue;
|
||||||
|
for (let i = 0; i < l.text.length; i++) out.push(s.start + l.at + i / CMD_CPS);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Seconds of the scene cuts that get a hit (every scene after the first). */
|
||||||
|
export const CUTS = SCENES.slice(1).map(s => s.start);
|
||||||
378
media/teaser/teaser.js
Normal file
378
media/teaser/teaser.js
Normal file
|
|
@ -0,0 +1,378 @@
|
||||||
|
// Teaser picture: every element is set from the time t alone (window.teaser.seek(t)), so frames render
|
||||||
|
// deterministically, in any order. URL: ?w=1080&h=1920 (or 1920x1080) · &t=12.5 to hold a frame · &play=1 to preview.
|
||||||
|
import { BAR, BEAT, BLOCKERS, BLOCKERS_AT, BLOCKER_GAP, CMD_CPS, CUTS, DURATION, FIX_AT, FIX_GAP, FPS, LANGS, PRICES,
|
||||||
|
PROMPT, PROMPT_AT, PROMPT_CPS, SCENES, TERMINAL, scene } from './script.js';
|
||||||
|
|
||||||
|
const q = new URLSearchParams(location.search);
|
||||||
|
const W = Number(q.get('w') ?? 1080), H = Number(q.get('h') ?? 1920);
|
||||||
|
const V = H > W;
|
||||||
|
const $ = s => document.querySelector(s);
|
||||||
|
const stage = $('#stage');
|
||||||
|
stage.style.width = `${W}px`; stage.style.height = `${H}px`;
|
||||||
|
document.body.classList.add(V ? 'v' : 'h');
|
||||||
|
|
||||||
|
// ---------- easing ----------
|
||||||
|
const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
|
||||||
|
const prog = (t, a, d) => clamp((t - a) / d);
|
||||||
|
const eoc = p => 1 - Math.pow(1 - p, 3);
|
||||||
|
const eic = p => p * p * p;
|
||||||
|
const eob = p => { const c1 = 1.70158, c3 = c1 + 1; return 1 + c3 * Math.pow(p - 1, 3) + c1 * Math.pow(p - 1, 2); };
|
||||||
|
const lerp = (a, b, p) => a + (b - a) * p;
|
||||||
|
const esc = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
const sceneAt = t => SCENES.find(s => t >= s.start && t < s.end) ?? SCENES[SCENES.length - 1];
|
||||||
|
|
||||||
|
// ---------- background ----------
|
||||||
|
const g1 = $('#bg .g1'), g2 = $('#bg .g2'), g3 = $('#bg .g3'), grid = $('#bg .grid'), flash = $('#flash');
|
||||||
|
function background(t) {
|
||||||
|
let pulse = 0;
|
||||||
|
for (const c of CUTS) if (t >= c) pulse = Math.max(pulse, 1 - prog(t, c, 0.6));
|
||||||
|
const beat = 1 - prog((t % BEAT), 0, BEAT * 0.6);
|
||||||
|
g1.style.transform = `translate(${W * 0.15 + Math.sin(t * 0.31) * 140 - 450}px, ${H * 0.28 + Math.cos(t * 0.23) * 120 - 450}px) scale(${1 + pulse * 0.18})`;
|
||||||
|
g2.style.transform = `translate(${W * 0.85 + Math.cos(t * 0.27) * 160 - 380}px, ${H * 0.72 + Math.sin(t * 0.35) * 140 - 380}px)`;
|
||||||
|
g3.style.transform = `translate(${W * 0.7 + Math.sin(t * 0.19) * 200 - 320}px, ${H * 0.1 + Math.cos(t * 0.29) * 100 - 320}px)`;
|
||||||
|
g1.style.opacity = String(0.8 + 0.2 * beat * (t > SCENES[1].start ? 1 : 0.3));
|
||||||
|
grid.style.transform = `translate(${(t * 18) % 64}px, ${(t * 26) % 64}px)`;
|
||||||
|
let f = 0;
|
||||||
|
for (const c of CUTS) if (t >= c && t < c + 0.14) f = Math.max(f, (c === scene('brand').start || c === scene('submit').start ? 0.45 : 0.2) * (1 - (t - c) / 0.14));
|
||||||
|
flash.style.opacity = String(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- captions ----------
|
||||||
|
// lines: array of [text, at] ; words wrapped in *...* are highlighted. at = seconds after the caption start.
|
||||||
|
const CAPS = [
|
||||||
|
{ id: 'prompt', lines: [['One prompt.', 0.15], ['Two *stores.*', 1.35]] },
|
||||||
|
{ id: 'config', lines: [['One *config.*', 0.05]], sub: ['storebound.config.ts + store/*.md', 0.55] },
|
||||||
|
{ id: 'prices', lines: [['IAP *prices.*', 0.05], ['Every region.', 0.55]] },
|
||||||
|
{ id: 'languages', lines: [['Listings in', 0.05], ['*14* languages.', 0.45]] },
|
||||||
|
{ id: 'questionnaires', lines: [['Every', 0.05], ['*questionnaire.*', 0.3]], sub: ['Data safety · age rating · App Privacy', 0.9] },
|
||||||
|
{ id: 'shots', lines: [['Store art,', 0.05], ['*rendered.*', 0.4]], sub: ['real renders · Prism Puddle demo', 1.0] },
|
||||||
|
{ id: 'validate', lines: [['Blockers', 0.05], ['#count', 0.3]], sub: ['read-only check · in fix order', 0.8] },
|
||||||
|
];
|
||||||
|
const capEl = $('#caption');
|
||||||
|
let capId = null, capWords = [], capSub = null, capCount = null;
|
||||||
|
function buildCaption(c) {
|
||||||
|
const base = V ? 112 : 108;
|
||||||
|
capEl.style.fontSize = `${base}px`;
|
||||||
|
capEl.innerHTML = c.lines.map(([text]) => text === '#count'
|
||||||
|
? '<span class="line"><span class="w big hl" data-count>7</span></span>'
|
||||||
|
: `<span class="line">${text.split(' ').map(w => w.startsWith('*') ? `<span class="w hl">${esc(w.replace(/\*/g, ''))}</span>` : `<span class="w">${esc(w)}</span>`).join(' ')}</span>`).join('')
|
||||||
|
+ (c.sub ? `<span class="sub">${esc(c.sub[0])}</span>` : '');
|
||||||
|
// fit: the widest line must fit the caption box
|
||||||
|
const avail = capEl.clientWidth;
|
||||||
|
const widest = Math.max(...[...capEl.querySelectorAll('.line')].map(l => l.scrollWidth));
|
||||||
|
if (widest > avail) capEl.style.fontSize = `${Math.floor(base * avail / widest)}px`;
|
||||||
|
capWords = [];
|
||||||
|
[...capEl.querySelectorAll('.line')].forEach((l, i) => {
|
||||||
|
[...l.querySelectorAll('.w')].forEach((w, j) => capWords.push({ el: w, at: c.lines[i][1] + j * 0.07 }));
|
||||||
|
});
|
||||||
|
capSub = c.sub ? { el: capEl.querySelector('.sub'), at: c.sub[1] } : null;
|
||||||
|
capCount = capEl.querySelector('[data-count]');
|
||||||
|
}
|
||||||
|
function captions(t) {
|
||||||
|
const s = sceneAt(t);
|
||||||
|
const c = CAPS.find(x => x.id === s.id);
|
||||||
|
if (!c) { capEl.style.opacity = '0'; return; }
|
||||||
|
if (capId !== c.id) { capId = c.id; buildCaption(c); }
|
||||||
|
const r = t - s.start;
|
||||||
|
const out = prog(t, s.end - 0.16, 0.16);
|
||||||
|
capEl.style.opacity = String(1 - out);
|
||||||
|
capEl.style.transform = `translateY(${-50 * eic(out)}px)`;
|
||||||
|
for (const w of capWords) {
|
||||||
|
const p = prog(r, w.at, 0.3);
|
||||||
|
w.el.style.opacity = String(clamp(p * 4));
|
||||||
|
w.el.style.transform = `translateY(${(1 - eob(p)) * 0.45}em) scale(${1 + 0.3 * (1 - eoc(p))})`;
|
||||||
|
}
|
||||||
|
if (capSub) {
|
||||||
|
const p = prog(r, capSub.at, 0.3);
|
||||||
|
capSub.el.style.opacity = String(p);
|
||||||
|
capSub.el.style.transform = `translateY(${(1 - eoc(p)) * 20}px)`;
|
||||||
|
}
|
||||||
|
if (capCount) {
|
||||||
|
const n = BLOCKERS.length - fixedCount(r);
|
||||||
|
capCount.textContent = n === 0 ? '0' : String(n);
|
||||||
|
capCount.classList.toggle('g', n === 0);
|
||||||
|
const last = n < BLOCKERS.length ? FIX_AT + (BLOCKERS.length - n - 1) * FIX_GAP : -9;
|
||||||
|
const pop = 1 - prog(r, last, 0.18);
|
||||||
|
const base = prog(r, 0.3, 0.3);
|
||||||
|
capCount.style.transform = `translateY(${(1 - eob(base)) * 0.45}em) scale(${(1 + 0.3 * (1 - eoc(base))) * (1 + (n === 0 ? 0.35 : 0.18) * pop)})`;
|
||||||
|
capCount.style.opacity = String(clamp(base * 4));
|
||||||
|
capCount.style.color = n === 0 ? 'var(--green)' : '#f87171';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const fixedCount = r => r < FIX_AT ? 0 : Math.min(BLOCKERS.length, Math.floor((r - FIX_AT) / FIX_GAP) + 1);
|
||||||
|
|
||||||
|
// ---------- terminal ----------
|
||||||
|
const term = $('#term'), pin = $('#term .pin'), linesEl = $('#term .lines');
|
||||||
|
const TERM_SCENES = ['prompt', 'config', 'prices', 'languages', 'questionnaires', 'shots', 'validate'];
|
||||||
|
const PANEL_FOR = { prices: '#prices', languages: '#langs', questionnaires: '#quest' };
|
||||||
|
const cursor = '<span class="cur"></span>';
|
||||||
|
const fmtOut = text => {
|
||||||
|
const m = text.match(/^\[(\w+)\](.*)$/s);
|
||||||
|
if (!m) return esc(text);
|
||||||
|
let rest = esc(m[2]).replace(/\(dry\)/g, '<span class="dim">(dry)</span>');
|
||||||
|
return `<span class="t-${m[1]}">[${m[1]}]</span>${rest}`;
|
||||||
|
};
|
||||||
|
let lastLines = '', lastPin = '', panelTopCache = null;
|
||||||
|
function terminal(t) {
|
||||||
|
const s = sceneAt(t);
|
||||||
|
const on = TERM_SCENES.includes(s.id);
|
||||||
|
if (!on) { term.style.opacity = '0'; return; }
|
||||||
|
const r = t - s.start;
|
||||||
|
// enter + punch on every cut
|
||||||
|
const enter = s.id === 'prompt' ? eoc(prog(t, 0, 0.35)) : 1;
|
||||||
|
const punch = s.id === 'prompt' ? 0 : 1 - eoc(prog(r, 0, 0.28));
|
||||||
|
const dim = s.id === 'shots' ? 0.72 * eoc(prog(r, 0.35, 0.35)) : 0;
|
||||||
|
term.style.opacity = String(enter * (1 - dim));
|
||||||
|
term.style.transform = `translateY(${(1 - enter) * 60}px) scale(${(0.94 + 0.06 * enter) * (1 + 0.035 * punch)})`;
|
||||||
|
|
||||||
|
// pinned user prompt
|
||||||
|
const n = clamp(Math.floor((t - PROMPT_AT) * PROMPT_CPS), 0, PROMPT.length);
|
||||||
|
const typing = n < PROMPT.length;
|
||||||
|
const blink = Math.floor(t * 2.6) % 2 === 0;
|
||||||
|
const pinHtml = `<span class="gt">></span> ${esc(PROMPT.slice(0, n))}${s.id === 'prompt' && (typing || blink) ? cursor : ''}`;
|
||||||
|
if (pinHtml !== lastPin) { pin.innerHTML = pinHtml; lastPin = pinHtml; }
|
||||||
|
|
||||||
|
// scene lines
|
||||||
|
const out = [];
|
||||||
|
let busy = false;
|
||||||
|
for (const l of TERMINAL[s.id] ?? []) {
|
||||||
|
if (r < l.at) break;
|
||||||
|
if (l.kind === 'cmd') {
|
||||||
|
const k = Math.min(l.text.length, Math.floor((r - l.at) * CMD_CPS) + 1);
|
||||||
|
busy = k < l.text.length;
|
||||||
|
out.push(`<div class="l cmd"><span class="ps">$</span> ${esc(l.text.slice(0, k))}${busy ? cursor : ''}</div>`);
|
||||||
|
} else if (l.kind === 'note') out.push(`<div class="l note">${fmtOut(l.text)}</div>`);
|
||||||
|
else out.push(`<div class="l">${fmtOut(l.text)}</div>`);
|
||||||
|
}
|
||||||
|
if (s.id === 'validate') {
|
||||||
|
const fixed = fixedCount(r);
|
||||||
|
BLOCKERS.forEach(([store, msg], i) => {
|
||||||
|
if (r < BLOCKERS_AT + i * BLOCKER_GAP) return;
|
||||||
|
const ok = i < fixed;
|
||||||
|
out.push(`<div class="l"><span class="dim">${String(i + 1).padStart(2)}.</span> ${ok ? '<span class="okk">ok</span> ' : '<span class="bad">BLOCKER</span>'} <span class="t-${store === 'play' ? 'play' : 'apple'}">[${store}]</span> <span class="${ok ? 'fixed' : ''}">${esc(msg)}</span></div>`);
|
||||||
|
});
|
||||||
|
const winAt = FIX_AT + BLOCKERS.length * FIX_GAP + 0.05;
|
||||||
|
if (r >= winAt) out.push('<div class="l"><span class="t-validate">[validate]</span> <span class="win">no blockers</span></div>');
|
||||||
|
if (r >= winAt + 0.2) out.push('<div class="l dim">(UI-only steps are not visible to the API: App Privacy, Play App content)</div>');
|
||||||
|
}
|
||||||
|
const last = out.length ? out[out.length - 1] : '';
|
||||||
|
const idle = !busy && s.id !== 'prompt' && (blink || r < 0.05);
|
||||||
|
const html = out.join('') + (idle && !last.includes('cur') ? `<div class="l">${cursor}</div>` : '');
|
||||||
|
// visible height: up to the panel when one is shown
|
||||||
|
const panel = PANEL_FOR[s.id];
|
||||||
|
const body = linesEl.parentElement;
|
||||||
|
const top = term.offsetTop + body.offsetTop + linesEl.offsetTop;
|
||||||
|
const bottom = panel && r > 0.4 ? panelTop(panel) - 14 : term.offsetTop + term.offsetHeight - 22;
|
||||||
|
const lh = parseFloat(getComputedStyle(linesEl).lineHeight) || 40;
|
||||||
|
linesEl.style.height = `${Math.max(lh, Math.floor((bottom - top) / lh) * lh)}px`;
|
||||||
|
if (html !== lastLines) { linesEl.innerHTML = html; lastLines = html; }
|
||||||
|
linesEl.scrollTop = linesEl.scrollHeight;
|
||||||
|
}
|
||||||
|
function panelTop(sel) {
|
||||||
|
panelTopCache ??= {};
|
||||||
|
if (panelTopCache[sel] === undefined) {
|
||||||
|
const el = $(sel);
|
||||||
|
panelTopCache[sel] = parseFloat(getComputedStyle(el).top);
|
||||||
|
}
|
||||||
|
return panelTopCache[sel];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- panels ----------
|
||||||
|
const pricesEl = $('#prices'), langsEl = $('#langs'), questEl = $('#quest');
|
||||||
|
langsEl.querySelector('.chips').innerHTML = LANGS.map(l => `<span class="chip">${l}</span>`).join('');
|
||||||
|
const chips = [...langsEl.querySelectorAll('.chip')];
|
||||||
|
const QUEST = [
|
||||||
|
['Play Data safety', 'the whole form, from the config', 'api'],
|
||||||
|
['App Store age rating', 'categories, content rights too', 'api'],
|
||||||
|
['Export compliance', 'your answer, set once in the config', 'api'],
|
||||||
|
['Play content rating (IARC)', 'the skill walks your agent through it', 'ui'],
|
||||||
|
['App Privacy labels + Publish', 'the skill walks your agent through it', 'ui'],
|
||||||
|
['The answers themselves', 'your statements · the agent asks', 'you'],
|
||||||
|
];
|
||||||
|
const ICON = {
|
||||||
|
api: '<svg viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5" fill="none" stroke="#86efac" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||||
|
ui: '<svg viewBox="0 0 24 24"><path d="M5 12h12M12.5 6.5 18 12l-5.5 5.5" fill="none" stroke="#fcd34d" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||||
|
you: '<svg viewBox="0 0 24 24"><circle cx="12" cy="8.5" r="3.6" fill="none" stroke="#f9a8d4" stroke-width="2.6"/><path d="M5 19.5c1.2-3.6 4-5 7-5s5.8 1.4 7 5" fill="none" stroke="#f9a8d4" stroke-width="2.6" stroke-linecap="round"/></svg>',
|
||||||
|
};
|
||||||
|
const BG = { api: 'var(--api-bg)', ui: 'var(--ui-bg)', you: 'var(--you-bg)' };
|
||||||
|
questEl.querySelector('.rows').innerHTML = QUEST.map(([nm, ds, k]) =>
|
||||||
|
`<div class="row"><span class="ico" style="background:${BG[k]}">${ICON[k]}</span><div><div class="nm">${esc(nm)}</div><div class="ds">${esc(ds)}</div></div><span class="pill p-${k}">${k.toUpperCase()}</span></div>`).join('');
|
||||||
|
const qrows = [...questEl.querySelectorAll('.row')];
|
||||||
|
const tbody = pricesEl.querySelector('tbody'), psum = pricesEl.querySelector('.sum');
|
||||||
|
let lastPrices = '';
|
||||||
|
|
||||||
|
function panelIn(el, r, at) {
|
||||||
|
const p = prog(r, at, 0.32);
|
||||||
|
el.style.opacity = String(clamp(p * 2));
|
||||||
|
el.style.transform = `translateY(${(1 - eob(p)) * 90}px) scale(${0.96 + 0.04 * eoc(p)})`;
|
||||||
|
}
|
||||||
|
function panels(t) {
|
||||||
|
const s = sceneAt(t), r = t - s.start;
|
||||||
|
for (const el of [pricesEl, langsEl, questEl]) el.style.opacity = '0';
|
||||||
|
if (s.id === 'prices') {
|
||||||
|
panelIn(pricesEl, r, 0.45);
|
||||||
|
const flick = r < 3.05;
|
||||||
|
const k = flick ? Math.max(0, Math.floor((r - 0.7) / 0.085)) : 0;
|
||||||
|
const rows = Array.from({ length: 5 }, (_, i) => PRICES[(k + i) % PRICES.length]);
|
||||||
|
const html = rows.map(([reg, cur, a, b], i) =>
|
||||||
|
`<tr class="${(flick && i === 0) || (!flick && reg === 'TR') ? 'hot' : ''}"><td>${reg}${reg === 'TR' ? '<span class="ov">OVERRIDE</span>' : ''}</td><td>${cur}</td><td>${a}</td><td>${b}</td></tr>`).join('');
|
||||||
|
if (html !== lastPrices) { tbody.innerHTML = html; lastPrices = html; }
|
||||||
|
psum.textContent = flick ? `${String(Math.min(173, Math.max(1, Math.floor((r - 0.7) * 72)))).padStart(3)} / 173 regions` : 'Play: 173 regions · App Store: equalized from the USA';
|
||||||
|
} else if (s.id === 'languages') {
|
||||||
|
panelIn(langsEl, r, 0.45);
|
||||||
|
let n = 0;
|
||||||
|
chips.forEach((c, i) => {
|
||||||
|
const at = 0.8 + i * 0.13;
|
||||||
|
const on = r >= at;
|
||||||
|
if (on) n++;
|
||||||
|
c.classList.toggle('on', on);
|
||||||
|
const p = prog(r, at, 0.2);
|
||||||
|
c.style.transform = `scale(${on ? 1 + 0.25 * (1 - eoc(p)) : 1})`;
|
||||||
|
});
|
||||||
|
langsEl.querySelector('.count').textContent = `${n}/14`;
|
||||||
|
} else if (s.id === 'questionnaires') {
|
||||||
|
panelIn(questEl, r, 0.3);
|
||||||
|
qrows.forEach((row, i) => {
|
||||||
|
const p = prog(r, 0.55 + i * 0.36, 0.28);
|
||||||
|
row.style.opacity = String(p);
|
||||||
|
row.style.transform = `translateX(${(1 - eob(p)) * 60}px)`;
|
||||||
|
const ico = row.querySelector('.ico');
|
||||||
|
ico.style.transform = `scale(${p >= 1 ? 1 + 0.3 * (1 - eoc(prog(r, 0.55 + i * 0.36 + 0.28, 0.2))) : eob(p)})`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- store art ----------
|
||||||
|
const shotsEl = $('#shots'), sizesEl = $('#sizes');
|
||||||
|
const FAN = ['en-01', 'en-02', 'en-03', 'en-04'];
|
||||||
|
const BIG = [['en-01', 'English'], ['tr-01', 'Türkçe'], ['ja-01', '日本語'], ['ar-01', 'العربية']];
|
||||||
|
const SIZES = ['Play phone', '7" tablet', '10" tablet', 'iPhone 6.9"', 'iPhone 6.5"', 'iPad 13"', 'feature graphic'];
|
||||||
|
const L = V
|
||||||
|
? { cx: 540, cy: 1040, w: 300, off: [-330, -110, 110, 330], rot: [-9, -3, 3, 9], dy: [36, 0, 0, 36], bw: 390, bcy: 1000, ly: 1318 }
|
||||||
|
: { cx: 1360, cy: 540, w: 290, off: [-330, -110, 110, 330], rot: [-9, -3, 3, 9], dy: [30, 0, 0, 30], bw: 330, bcy: 515, ly: 790 };
|
||||||
|
const RATIO = 1920 / 1080;
|
||||||
|
shotsEl.innerHTML = FAN.map(f => `<div class="card fan"><img src="out/assets/${f}.jpg" alt=""></div>`).join('')
|
||||||
|
+ `<div class="card big">${BIG.map(([f]) => `<img src="out/assets/${f}.jpg" alt="" style="position:absolute;inset:0">`).join('')}</div>`
|
||||||
|
+ '<div class="lang"></div>';
|
||||||
|
sizesEl.innerHTML = SIZES.map(s => `<span class="sz">${esc(s)}</span>`).join('');
|
||||||
|
const fanEls = [...shotsEl.querySelectorAll('.card.fan')], bigEl = shotsEl.querySelector('.card.big'), bigImgs = [...bigEl.querySelectorAll('img')];
|
||||||
|
const langEl = shotsEl.querySelector('.lang'), sizeEls = [...sizesEl.querySelectorAll('.sz')];
|
||||||
|
for (const c of fanEls) { c.style.width = `${L.w}px`; c.style.height = `${L.w * RATIO}px`; }
|
||||||
|
bigEl.style.width = `${L.bw}px`; bigEl.style.height = `${L.bw * RATIO}px`;
|
||||||
|
|
||||||
|
function place(el, cx, cy, w, h, rot, sc, op) {
|
||||||
|
el.style.transform = `translate(${cx - w / 2}px, ${cy - h / 2}px) rotate(${rot}deg) scale(${sc})`;
|
||||||
|
el.style.opacity = String(op);
|
||||||
|
}
|
||||||
|
function shots(t) {
|
||||||
|
const s = sceneAt(t), r = t - s.start;
|
||||||
|
const on = s.id === 'shots';
|
||||||
|
shotsEl.style.display = on ? '' : 'none';
|
||||||
|
sizesEl.style.display = on ? '' : 'none';
|
||||||
|
if (!on) return;
|
||||||
|
const h = L.w * RATIO;
|
||||||
|
const spread = eoc(prog(r, 1.95, 0.35));
|
||||||
|
fanEls.forEach((el, i) => {
|
||||||
|
const p = prog(r, 0.3 + i * 0.2, 0.5);
|
||||||
|
const e = eob(p);
|
||||||
|
const dir = i < 2 ? -1 : 1;
|
||||||
|
const x0 = L.cx + dir * (V ? 700 : 900), y0 = L.cy + (V ? 1100 : 800);
|
||||||
|
const fx = L.cx + L.off[i] + dir * 70 * spread, fy = L.cy + L.dy[i] + Math.sin(t * 2 + i) * 6;
|
||||||
|
place(el, lerp(x0, fx, e), lerp(y0, fy, e), L.w, h, lerp(dir * 40, L.rot[i] + dir * 4 * spread, e), 1 - 0.12 * spread, clamp(p * 3) * (1 - 0.45 * spread));
|
||||||
|
});
|
||||||
|
// big card cycling the hero screenshot through four languages
|
||||||
|
const bp = prog(r, 1.95, 0.42);
|
||||||
|
const bh = L.bw * RATIO;
|
||||||
|
const idx = r < 2.5 ? 0 : r < 2.95 ? 1 : r < 3.4 ? 2 : 3;
|
||||||
|
const sw = [2.5, 2.95, 3.4].map(a => 1 - Math.min(1, Math.abs(r - a) / 0.09)).reduce((a, b) => Math.max(a, b), 0);
|
||||||
|
place(bigEl, L.cx, L.bcy + (1 - eob(bp)) * 500 + Math.sin(t * 1.6) * 5, L.bw, bh, (1 - eoc(bp)) * 12, (0.7 + 0.3 * eob(bp)), clamp(bp * 3));
|
||||||
|
bigEl.style.transform += ` scaleX(${1 - 0.18 * sw})`;
|
||||||
|
bigImgs.forEach((im, i) => { im.style.opacity = i === idx ? '1' : '0'; });
|
||||||
|
langEl.textContent = BIG[idx][1];
|
||||||
|
const lp = prog(r, 2.2, 0.25);
|
||||||
|
langEl.style.opacity = String(lp);
|
||||||
|
langEl.style.left = `${L.cx}px`; langEl.style.top = `${L.ly}px`;
|
||||||
|
langEl.style.transform = `translateX(-50%) scale(${(1 + 0.2 * sw) * (0.6 + 0.4 * eob(lp))})`;
|
||||||
|
// sizes
|
||||||
|
sizeEls.forEach((el, i) => {
|
||||||
|
const at = 3.75 + i * 0.16;
|
||||||
|
const p = prog(r, at, 0.22);
|
||||||
|
el.style.opacity = String(clamp(p * 3));
|
||||||
|
el.style.transform = `translateY(${(1 - eob(p)) * 30}px) scale(${1 + 0.2 * (1 - eoc(p))})`;
|
||||||
|
el.classList.toggle('on', r >= at);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- end cards ----------
|
||||||
|
const submitEl = $('#submit'), btn = $('#submit .btn'), ring = $('#submit .ring'), kick = $('#submit .kick'),
|
||||||
|
yours = $('#submit .yours'), fine = $('#submit .fine'), cur = $('#cursor');
|
||||||
|
const brandEl = $('#brand');
|
||||||
|
const brandParts = [...brandEl.children];
|
||||||
|
function pop(el, r, at, dist = 50, d = 0.35) {
|
||||||
|
const p = prog(r, at, d);
|
||||||
|
el.style.opacity = String(clamp(p * 2.5));
|
||||||
|
el.style.transform = `translateY(${(1 - eob(p)) * dist}px) scale(${0.85 + 0.15 * eob(p)})`;
|
||||||
|
}
|
||||||
|
function endCards(t) {
|
||||||
|
const s = sceneAt(t), r = t - s.start;
|
||||||
|
submitEl.style.opacity = s.id === 'submit' ? '1' : '0';
|
||||||
|
brandEl.style.opacity = s.id === 'brand' ? '1' : '0';
|
||||||
|
cur.style.opacity = '0';
|
||||||
|
if (s.id === 'submit') {
|
||||||
|
pop(kick, r, 0.0, 30);
|
||||||
|
const bp = prog(r, 0.08, 0.42);
|
||||||
|
btn.style.opacity = String(clamp(bp * 3));
|
||||||
|
const hover = eoc(prog(r, 1.25, 0.2));
|
||||||
|
btn.style.transform = `scale(${(0.4 + 0.6 * eob(bp)) * (1 + 0.04 * hover)})`;
|
||||||
|
btn.style.filter = `brightness(${1 + 0.18 * hover})`;
|
||||||
|
const rp = ((r - 0.5) % BEAT) / BEAT;
|
||||||
|
ring.style.opacity = r > 0.5 ? String(0.7 * (1 - rp)) : '0';
|
||||||
|
ring.style.transform = `scale(${1 + 0.12 * eoc(rp)})`;
|
||||||
|
pop(yours, r, 0.95, 70, 0.4);
|
||||||
|
pop(fine, r, 1.55, 30);
|
||||||
|
// the cursor comes close and waits: the click stays yours
|
||||||
|
const b = btn.getBoundingClientRect();
|
||||||
|
const tx = b.left + b.width * 0.78, ty = b.top + b.height * 0.72;
|
||||||
|
const cp = eoc(prog(r, 0.55, 0.8));
|
||||||
|
const wob = Math.sin(r * 5) * 4 * prog(r, 1.35, 0.3);
|
||||||
|
cur.style.opacity = String(clamp((r - 0.55) * 4));
|
||||||
|
cur.style.transform = `translate(${lerp(tx + 380, tx, cp) + wob}px, ${lerp(ty + 420, ty, cp) + wob * 0.6}px)`;
|
||||||
|
} else if (s.id === 'brand') {
|
||||||
|
const [mark, word, tag, url, meta, inst] = brandParts;
|
||||||
|
const mp = prog(r, 0.0, 0.45);
|
||||||
|
mark.style.opacity = String(clamp(mp * 3));
|
||||||
|
mark.style.transform = `scale(${eob(mp)}) rotate(${(1 - eoc(mp)) * -25}deg)`;
|
||||||
|
pop(word, r, 0.15, 60);
|
||||||
|
pop(tag, r, 0.5, 40);
|
||||||
|
pop(url, r, 0.85, 40);
|
||||||
|
pop(meta, r, 1.05, 30);
|
||||||
|
pop(inst, r, 1.3, 30);
|
||||||
|
const beat = 1 - prog(((r + 1e-6) % BEAT), 0, BEAT * 0.5);
|
||||||
|
url.style.textShadow = `0 0 ${20 + 30 * beat * (r > 0.85 ? 1 : 0)}px rgba(129,140,248,${0.35 + 0.35 * beat})`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- seek ----------
|
||||||
|
function seek(t) {
|
||||||
|
t = clamp(t, 0, DURATION - 1e-6);
|
||||||
|
background(t);
|
||||||
|
captions(t);
|
||||||
|
terminal(t);
|
||||||
|
panels(t);
|
||||||
|
shots(t);
|
||||||
|
endCards(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ready = (async () => {
|
||||||
|
await document.fonts.ready;
|
||||||
|
await Promise.all([...document.images].map(im => im.decode().catch(() => { throw new Error(`image failed: ${im.src}`); })));
|
||||||
|
seek(0);
|
||||||
|
})();
|
||||||
|
window.teaser = { ready, seek, DURATION, FPS, BAR, W, H };
|
||||||
|
|
||||||
|
if (q.has('t')) ready.then(() => seek(Number(q.get('t'))));
|
||||||
|
if (q.has('play')) ready.then(() => {
|
||||||
|
const t0 = performance.now();
|
||||||
|
const loop = () => { seek(((performance.now() - t0) / 1000) % DURATION); requestAnimationFrame(loop); };
|
||||||
|
loop();
|
||||||
|
});
|
||||||
|
|
@ -12,5 +12,5 @@
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["cli", "tests", "tools", "templates/storebound.config.ts", "examples/demo-game/storebound.config.ts", "examples/demo-game/serve.ts"]
|
"include": ["cli", "tests", "tools", "templates/storebound.config.ts", "examples/demo-game/storebound.config.ts", "examples/demo-game/serve.ts", "media/teaser/render.ts"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue