paper-motion 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -2
- package/bin/pamo.mjs +535 -0
- package/examples/breath/brief.md +11 -0
- package/examples/breath/poster.jpg +0 -0
- package/examples/breath/scene.html +59 -0
- package/examples/chrome-endcard/brief.md +7 -0
- package/examples/chrome-endcard/fonts/GeistMono-Variable.woff2 +0 -0
- package/examples/chrome-endcard/fonts/GeistSerif-Regular.woff2 +0 -0
- package/examples/chrome-endcard/poster.jpg +0 -0
- package/examples/chrome-endcard/scene.html +68 -0
- package/examples/chrome-endcard/wordmark.js +16 -0
- package/examples/install-loop/brief.md +7 -0
- package/examples/install-loop/fonts/GeistMono-Variable.woff2 +0 -0
- package/examples/install-loop/fonts/GeistSerif-Regular.woff2 +0 -0
- package/examples/install-loop/poster.jpg +0 -0
- package/examples/install-loop/scene.html +46 -0
- package/examples/signal/brief.md +10 -0
- package/examples/signal/poster.jpg +0 -0
- package/examples/signal/scene.html +50 -0
- package/lib/board.mjs +95 -0
- package/lib/browser.mjs +88 -0
- package/lib/catalog.mjs +77 -0
- package/lib/keys.mjs +93 -0
- package/lib/modules.mjs +23 -0
- package/lib/react-hooks.mjs +9 -0
- package/lib/render.mjs +193 -0
- package/lib/server.mjs +88 -0
- package/lib/sfx.mjs +285 -0
- package/lib/shaderset.mjs +65 -0
- package/lib/wordmark.mjs +64 -0
- package/package.json +46 -4
- package/runtime/brand.js +71 -0
- package/runtime/index.js +606 -0
- package/runtime/jsx-shim.js +3 -0
- package/runtime/moves.js +174 -0
- package/runtime/player.js +69 -0
- package/runtime/react-shim.js +15 -0
- package/templates/blank/brief.md +39 -0
- package/templates/blank/scene.html +44 -0
- package/templates/brand-sheet/index.html +241 -0
- package/templates/move-demo/brief.md +4 -0
- package/templates/move-demo/scene.html +157 -0
- package/templates/piece/brief.md +39 -0
- package/templates/piece/scene.html +62 -0
- package/templates/shader-set/shot.js +47 -0
- package/templates/still/brief.md +3 -0
- package/templates/still/scene.html +56 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>move demo</title>
|
|
6
|
+
<!--
|
|
7
|
+
A 7 s demo of one motion style in the brand's look: frames alternate (the name, then a line in the brand's
|
|
8
|
+
words) at the chosen pace, so the clip shows rhythm, not one move. Reads /brand/tokens.json and
|
|
9
|
+
/brand/IDENTITY.md: render it from the project root. Edit freely: it is a sketch for a board.
|
|
10
|
+
-->
|
|
11
|
+
<style>
|
|
12
|
+
#stage { overflow: hidden; }
|
|
13
|
+
#world { position: absolute; inset: 0; }
|
|
14
|
+
.frame { position: absolute; top: 0; width: 1600px; height: 900px; display: flex; flex-direction: column; justify-content: center; padding: 0 140px; box-sizing: border-box; }
|
|
15
|
+
.name { white-space: nowrap; }
|
|
16
|
+
.cur { display: inline-block; width: 0.5em; height: 0.95em; vertical-align: -0.12em; margin-left: 4px; }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<main id="stage"><div id="world"></div></main>
|
|
21
|
+
<script type="module">
|
|
22
|
+
import { scene, ease, clamp } from 'paper-motion';
|
|
23
|
+
import * as M from 'paper-motion/moves';
|
|
24
|
+
|
|
25
|
+
// The four choices this demo shows. `pamo new <name> --move … --pace … --text … --camera …` sets them.
|
|
26
|
+
const MOVE = 'crossfade'; // transition between frames: cut crossfade wipe push maskReveal scanReveal zoomThrough
|
|
27
|
+
const PACE = 'medium'; // calm | medium | fast
|
|
28
|
+
const TEXT = 'plain'; // how the line appears: typing | rise | blur | track | plain
|
|
29
|
+
const CAMERA = 'still'; // still | drift | travel (travel moves the camera between frames and replaces MOVE)
|
|
30
|
+
const SOUND = 'none'; // sound palette: none | soft | crisp | airy (subtle swells) | ambient (airy over a low bed)
|
|
31
|
+
const DURATION = 7;
|
|
32
|
+
|
|
33
|
+
const tokens = await fetch('/brand/tokens.json').then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
34
|
+
const identity = await fetch('/brand/IDENTITY.md').then((r) => (r.ok ? r.text() : '')).catch(() => '');
|
|
35
|
+
const C = tokens?.colors ?? {};
|
|
36
|
+
const col = (role, fb) => C[role]?.hex ?? fb;
|
|
37
|
+
const fam = (k, fb) => (tokens?.fonts?.[k]?.family ? `'${tokens.fonts[k].family}', ${fb}` : fb);
|
|
38
|
+
await Promise.all(Object.values(tokens?.fonts ?? {}).filter((f) => f?.css).map((f) => new Promise((res) => document.head.append(Object.assign(document.createElement('link'), { rel: 'stylesheet', href: f.css, onload: res, onerror: res })))));
|
|
39
|
+
for (const f of Object.values(tokens?.fonts ?? {})) if (f?.file) document.head.append(Object.assign(document.createElement('style'), { textContent: `@font-face { font-family: '${f.family}'; src: url('/brand/${f.file}'); font-weight: 100 900; }` }));
|
|
40
|
+
|
|
41
|
+
// The brand's own words: its one line, else the voice sample, else the first sentence of its offer.
|
|
42
|
+
const section = (h) => (identity.split(new RegExp(`^## ${h}\\s*$`, 'm'))[1] ?? '').split(/^## /m)[0].trim();
|
|
43
|
+
const firstLine = (s) => s.split('\n').map((l) => l.replace(/^[-*]\s*/, '').trim()).find(Boolean) ?? '';
|
|
44
|
+
const quoted = section('Voice').match(/[“"]([^”"]{4,90})[”"]/)?.[1];
|
|
45
|
+
const name = tokens?.wordmark?.text ?? tokens?.brand ?? 'brand';
|
|
46
|
+
// a short line reads in one beat: the voice sample, else the first clause of the one line, at most ~48 characters
|
|
47
|
+
const clip = (t) => { if (!t) return ''; const c = t.split(/[,.;:—]/)[0].trim(); const u = c.length <= 48 ? c : c.slice(0, c.lastIndexOf(' ', 48)); return u; };
|
|
48
|
+
// the brand speaking (its voice sample) comes first: it is in the brand's own language
|
|
49
|
+
const line = (quoted && quoted.length <= 64 ? quoted : '') || clip(firstLine(section('In one line'))) || clip(quoted) || clip(firstLine(section('Offer') || section('Purpose'))) || name;
|
|
50
|
+
|
|
51
|
+
// Two frames that contrast enough for every move to read: ground, and figure (or a surface far from ground).
|
|
52
|
+
const lum = (hex) => { const n = parseInt((hex ?? '#888').slice(1), 16); return ((n >> 16 & 255) * 0.299 + (n >> 8 & 255) * 0.587 + (n & 255) * 0.114) / 255; };
|
|
53
|
+
const ground = col('ground', '#f2f2f2'), figure = col('figure', '#1a1a1a'), surface = C.surface?.hex;
|
|
54
|
+
// the second frame contrasts enough for moves to read, without flashing: a nearby tone of the brand first
|
|
55
|
+
// (surface, the ramp's steps, muted), the figure color only as a last resort
|
|
56
|
+
const near = [surface, tokens?.ramp?.[1], tokens?.ramp?.[2], C.muted?.hex].filter(Boolean).find((c) => Math.abs(lum(c) - lum(ground)) >= 0.07);
|
|
57
|
+
const bBg = near ?? figure;
|
|
58
|
+
const bInk = Math.abs(lum(figure) - lum(bBg)) > Math.abs(lum(ground) - lum(bBg)) ? figure : ground;
|
|
59
|
+
|
|
60
|
+
const T = tokens?.type ?? {};
|
|
61
|
+
const s = scene({ width: 1600, height: 900, fps: 30, duration: DURATION, background: ground });
|
|
62
|
+
const world = document.getElementById('world');
|
|
63
|
+
const mk = (i, kind) => {
|
|
64
|
+
const el = document.createElement('div'); el.className = 'frame';
|
|
65
|
+
el.style.left = CAMERA === 'travel' ? `${i * 1600}px` : '0';
|
|
66
|
+
el.style.background = kind === 'name' ? ground : bBg; el.style.color = kind === 'name' ? figure : bInk;
|
|
67
|
+
if (kind === 'name') {
|
|
68
|
+
el.innerHTML = '<div class="name"></div>';
|
|
69
|
+
Object.assign(el.firstChild.style, { font: `${tokens?.wordmark?.weight ?? T.display?.weight ?? 600} 220px ${fam(tokens?.wordmark?.font ?? 'display', 'system-ui, sans-serif')}`, letterSpacing: tokens?.wordmark?.tracking ?? T.display?.tracking ?? '-0.02em', lineHeight: 0.95 });
|
|
70
|
+
el.firstChild.textContent = name;
|
|
71
|
+
} else {
|
|
72
|
+
el.innerHTML = '<div><span class="ln"></span><span class="cur"></span></div>';
|
|
73
|
+
Object.assign(el.firstChild.style, { font: `${T.title?.weight ?? 500} 80px/1.08 ${fam('display', 'system-ui, sans-serif')}`, letterSpacing: T.title?.tracking ?? '-0.01em', maxWidth: '1300px' });
|
|
74
|
+
el.querySelector('.ln').textContent = line;
|
|
75
|
+
if (TEXT === 'track') el.firstChild.style.whiteSpace = 'nowrap'; // letters settle without reflowing lines
|
|
76
|
+
if (TEXT === 'typing') { el.firstChild.style.fontFamily = fam(tokens?.fonts?.mono ? 'mono' : 'text', 'ui-monospace, monospace'); el.firstChild.style.fontWeight = 400; } // typing reads in the brand's mono (or text face), never the display face
|
|
77
|
+
el.querySelector('.cur').style.background = bInk; el.querySelector('.cur').style.opacity = 0;
|
|
78
|
+
}
|
|
79
|
+
world.append(el);
|
|
80
|
+
return el;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Beats: name, line, name, line… each holds for the pace, then the move carries it to the next.
|
|
84
|
+
const P = M.PACE[PACE], trans = P.enter * 1.6, textDur = P.enter * 1.6;
|
|
85
|
+
const beats = [];
|
|
86
|
+
for (let t = 0.3, i = 0; t < DURATION; i++) {
|
|
87
|
+
const kind = i % 2 ? 'line' : 'name';
|
|
88
|
+
const hold = kind === 'line' ? textDur + P.hold * 0.55 : P.hold * 0.45; // a demo compresses holds so even calm shows its rhythm
|
|
89
|
+
beats.push({ kind, start: t, end: t + hold, el: mk(i, kind) });
|
|
90
|
+
t += hold + trans;
|
|
91
|
+
}
|
|
92
|
+
beats.forEach((b, i) => { b.el.style.opacity = i === 0 ? 1 : 0; });
|
|
93
|
+
const cps = { calm: 14, medium: 22, fast: 32 }[PACE]; // typing speed per pace (characters a second)
|
|
94
|
+
|
|
95
|
+
s.update((t) => {
|
|
96
|
+
// Every frame is derived from t alone: reset, then apply only the transition in progress (or last finished).
|
|
97
|
+
for (const b of beats) Object.assign(b.el.style, { opacity: CAMERA === 'travel' ? 1 : 0, transform: '', maskImage: '', webkitMaskImage: '', clipPath: '' });
|
|
98
|
+
let k = -1;
|
|
99
|
+
beats.forEach((b, i) => { if (beats[i + 1] && t >= b.end) k = i; });
|
|
100
|
+
const p = k < 0 ? 0 : clamp((t - beats[k].end) / trans);
|
|
101
|
+
const drift = CAMERA === 'drift' ? ` scale(${1 + 0.05 * t / DURATION})` : '';
|
|
102
|
+
if (CAMERA === 'travel') world.style.transform = `translateX(${-(Math.max(0, k) + (k < 0 ? 0 : ease.inOutCubic(p))) * 1600}px)`;
|
|
103
|
+
else {
|
|
104
|
+
world.style.transform = drift.trim();
|
|
105
|
+
if (k < 0) beats[0].el.style.opacity = 1;
|
|
106
|
+
else {
|
|
107
|
+
const a = beats[k].el, b = beats[k + 1].el;
|
|
108
|
+
({ cut: () => M.cut(a, b, p >= 0.5 ? 1 : 0), crossfade: () => M.crossfade(a, b, p), wipe: () => M.wipe(a, b, p),
|
|
109
|
+
push: () => M.push(a, b, p), maskReveal: () => M.maskReveal(a, b, p), scanReveal: () => M.scanReveal(a, b, p),
|
|
110
|
+
zoomThrough: () => M.zoomThrough(a, b, p, { origin: beats[k].kind === 'name' ? '30% 50%' : '50% 50%' }) })[MOVE]?.();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// the line appears as its frame lands
|
|
114
|
+
for (const b of beats.filter((x) => x.kind === 'line')) {
|
|
115
|
+
const el = b.el.querySelector('.ln'), start = b.start - (CAMERA === 'travel' ? 0 : trans * 0.3);
|
|
116
|
+
if (TEXT === 'typing') M.typeOn(el, line, t, { times: M.typingTimes(line, { start, cps, seed: beats.indexOf(b) + 1 }), cursor: t < b.end + trans ? b.el.querySelector('.cur') : null });
|
|
117
|
+
else if (TEXT === 'rise') M.wordRise(el, t, { start, each: P.stagger, duration: textDur });
|
|
118
|
+
else if (TEXT === 'blur') M.blurIn(el, t, { start, duration: textDur });
|
|
119
|
+
else if (TEXT === 'track') M.trackIn(el, t, { start, duration: textDur * 1.2 });
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// ── sound palette: one cue family per gesture (transition, landing, text), all low and soft ──
|
|
124
|
+
const PAL = {
|
|
125
|
+
soft: { lowpass: 1800, move: (t) => s.sfx(t, 'whoosh', { dur: Math.min(1.4, Math.max(0.4, trans * 1.4)), from: 220, to: 700, peak: 0.6, gain: 0.2, body: 0.4 }), land: (t) => s.sfx(t, 'thud', { freq: 55, gain: 0.22, decay: 0.45 }), text: (t) => s.sfx(t, 'paper', { dur: 0.5, gain: 0.035 }) },
|
|
126
|
+
crisp: { lowpass: 4200, move: (t) => { s.sfx(t, 'flick', { gain: 0.12 }); s.sfx(t + 0.02, 'tick', { freq: 320, gain: 0.07, decay: 0.03 }); }, land: (t) => s.sfx(t, 'knock', { freq: 160, gain: 0.16, decay: 0.08 }), text: (t) => s.sfx(t, 'tick', { freq: 260, gain: 0.05, decay: 0.04 }) },
|
|
127
|
+
airy: { lowpass: 2000, move: (t) => s.sfx(t - 0.2, 'swell', { dur: Math.max(1.4, trans * 2.2), freq: 73.4, gain: 0.045 }), land: () => {}, text: (t) => s.sfx(t, 'paper', { dur: 0.6, gain: 0.025 }) },
|
|
128
|
+
ambient: { lowpass: 2000, bed: () => s.sfx(0, 'drone', { dur: DURATION, freq: 55, gain: 0.04, attack: 1.5, release: 1.5 }), move: (t) => s.sfx(t - 0.2, 'swell', { dur: Math.max(1.4, trans * 2.2), freq: 73.4, gain: 0.05 }), land: () => {}, text: (t) => s.sfx(t, 'paper', { dur: 0.6, gain: 0.03 }) },
|
|
129
|
+
}[SOUND];
|
|
130
|
+
if (PAL) {
|
|
131
|
+
PAL.bed?.();
|
|
132
|
+
const bank = await fetch('/brand/sound/keys/keys.json').then((r) => (r.ok ? 'brand/sound/keys' : null)).catch(() => null);
|
|
133
|
+
beats.forEach((b, i) => {
|
|
134
|
+
if (beats[i + 1]) { PAL.move(b.end); PAL.land(b.end + trans); }
|
|
135
|
+
if (b.kind === 'line') {
|
|
136
|
+
const start = b.start - (CAMERA === 'travel' ? 0 : trans * 0.3);
|
|
137
|
+
if (TEXT === 'typing') M.keySounds(s, line, M.typingTimes(line, { start, cps, seed: i + 1 }), { bank, seed: i + 1 });
|
|
138
|
+
else PAL.text(start);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
s.sound({ lowpass: PAL.lowpass, gain: 1 });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// track sets the line on one row: shrink it to fit the frame at its widest (start) spacing
|
|
145
|
+
if (TEXT === 'track') for (const b of beats.filter((x) => x.kind === 'line')) {
|
|
146
|
+
const box = b.el.firstChild, ln = b.el.querySelector('.ln');
|
|
147
|
+
await document.fonts.ready;
|
|
148
|
+
ln.style.letterSpacing = '0.4em';
|
|
149
|
+
const fit = (1600 - 280) / box.scrollWidth;
|
|
150
|
+
if (fit < 1) box.style.fontSize = `${parseFloat(getComputedStyle(box).fontSize) * fit}px`;
|
|
151
|
+
ln.style.letterSpacing = '';
|
|
152
|
+
}
|
|
153
|
+
await Promise.all([...document.querySelectorAll('.name, .frame > div')].map((el) => { const c = getComputedStyle(el); return document.fonts.load(`${c.fontWeight} ${c.fontSize} ${c.fontFamily}`); }));
|
|
154
|
+
await s.start();
|
|
155
|
+
</script>
|
|
156
|
+
</body>
|
|
157
|
+
</html>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Brief — <title>
|
|
2
|
+
Status: draft | approved by <user> on <date>
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
Where it lives · who watches · what should happen after watching.
|
|
6
|
+
|
|
7
|
+
## Feeling
|
|
8
|
+
Three words. One sentence of intent.
|
|
9
|
+
|
|
10
|
+
## References
|
|
11
|
+
- <link> — what we take from it: …
|
|
12
|
+
- <image> — what we take from it: …
|
|
13
|
+
|
|
14
|
+
## Anti-references (never)
|
|
15
|
+
- …
|
|
16
|
+
|
|
17
|
+
## Content
|
|
18
|
+
Exact text / none · must be read? · hero moment.
|
|
19
|
+
|
|
20
|
+
## Recipe and format
|
|
21
|
+
Recipe · aspect (16:9 / 9:16 / 1:1) · duration · fps · loop · safe areas.
|
|
22
|
+
|
|
23
|
+
## Structure and pace
|
|
24
|
+
Continuous / cuts / chapters · pace (cut every N s) · sync (music/VO/none) · opening · ending.
|
|
25
|
+
|
|
26
|
+
## Look
|
|
27
|
+
From the brand (say "brand") · what this piece changes · composition · which shader-set entries.
|
|
28
|
+
|
|
29
|
+
## Motion
|
|
30
|
+
From the brand's motion.json · what this piece changes · motion blur.
|
|
31
|
+
|
|
32
|
+
## Sound
|
|
33
|
+
From the brand's sound.json · music (the user's file) or sound design only · loudness.
|
|
34
|
+
|
|
35
|
+
## Done when
|
|
36
|
+
The user's own words.
|
|
37
|
+
|
|
38
|
+
## Open questions
|
|
39
|
+
- …
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>untitled piece</title>
|
|
6
|
+
<!-- A piece wired to the brand folder: look, moves, sound and material come from /brand (serve from the project root). -->
|
|
7
|
+
<style>
|
|
8
|
+
#stage { overflow: hidden; }
|
|
9
|
+
.abs { position: absolute; box-sizing: border-box; }
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<main id="stage">
|
|
14
|
+
<div id="bg" class="abs" style="inset:0"></div>
|
|
15
|
+
<div id="group" class="abs" style="display:flex;flex-direction:column"><div id="title"></div><div id="line"></div></div>
|
|
16
|
+
</main>
|
|
17
|
+
<script type="module">
|
|
18
|
+
import { scene, progress, ease } from 'paper-motion';
|
|
19
|
+
import { wordRise, blurIn, trackIn, typeOn, typingTimes, keySounds } from 'paper-motion/moves';
|
|
20
|
+
import { loadBrand } from 'paper-motion/brand';
|
|
21
|
+
|
|
22
|
+
const B = await loadBrand();
|
|
23
|
+
const W = 1920, H = 1080, SHORT = Math.min(W, H), M = Math.round(SHORT * 0.08); // `pamo new --format` sets W and H
|
|
24
|
+
const s = scene({ width: W, height: H, fps: 30, duration: 8, background: B.color('ground') });
|
|
25
|
+
|
|
26
|
+
// Material: the brand's first shader-set entry, or a slow field from its ramp.
|
|
27
|
+
const first = B.set.entries.find((e) => e.shader && !e.image);
|
|
28
|
+
if (first) B.shader(s, '#bg', first.id);
|
|
29
|
+
else if (B.ramp.length >= 2) s.shader('#bg', 'MeshGradient', { colors: B.ramp.slice(0, 4), distortion: 0.6, swirl: 0.2, speed: 0.2 });
|
|
30
|
+
|
|
31
|
+
const title = B.style(document.querySelector('#title'), 'display', { short: SHORT });
|
|
32
|
+
const line = B.style(document.querySelector('#line'), 'title', { short: SHORT });
|
|
33
|
+
// title and line stack from the bottom margin; the title shrinks to fit the frame's width in any format
|
|
34
|
+
Object.assign(document.querySelector('#group').style, { left: `${M}px`, right: `${M}px`, bottom: `${M}px`, gap: `${Math.round(SHORT * 0.03)}px` });
|
|
35
|
+
Object.assign(title.style, { whiteSpace: 'nowrap' });
|
|
36
|
+
title.textContent = B.name;
|
|
37
|
+
line.textContent = (B.identity['In one line'] ?? '').split('\n')[0] || B.name;
|
|
38
|
+
await document.fonts.ready;
|
|
39
|
+
const fit = (W - M * 2) / title.scrollWidth;
|
|
40
|
+
if (fit < 1) title.style.fontSize = `${parseFloat(title.style.fontSize) * fit}px`;
|
|
41
|
+
if (H > W) line.style.fontSize = `${parseFloat(line.style.fontSize) * 0.8}px`;
|
|
42
|
+
|
|
43
|
+
// Text behaves the way the brand's motion style says (motion.json: typing | rise | blur | track).
|
|
44
|
+
const P = B.pace, T1 = 0.6, T2 = T1 + P.enter * 2, TEXT = B.motion?.text ?? 'rise';
|
|
45
|
+
// typed text is set in the brand's text face (a terminal types in its mono), a little smaller than a title
|
|
46
|
+
if (TEXT === 'typing') Object.assign(line.style, { fontFamily: B.font('text'), fontSize: `${parseFloat(line.style.fontSize) * 0.55}px`, letterSpacing: '0em', lineHeight: 1.3 });
|
|
47
|
+
const lineText = line.textContent, times = typingTimes(lineText, { start: T2, cps: { calm: 14, medium: 22, fast: 32 }[B.motion?.pace ?? 'medium'], seed: 1 });
|
|
48
|
+
s.update((t) => {
|
|
49
|
+
wordRise(title, t, { start: T1, each: P.stagger, duration: P.enter * 1.6 });
|
|
50
|
+
if (TEXT === 'typing') typeOn(line, lineText, t, { times });
|
|
51
|
+
else if (TEXT === 'blur') blurIn(line, t, { start: T2, duration: P.enter * 1.6 });
|
|
52
|
+
else if (TEXT === 'track') trackIn(line, t, { start: T2, duration: P.enter * 2 });
|
|
53
|
+
else wordRise(line, t, { start: T2, each: P.stagger, duration: P.enter * 1.6 });
|
|
54
|
+
});
|
|
55
|
+
B.cue(s, 'land', T1);
|
|
56
|
+
if (TEXT === 'typing') keySounds(s, lineText, times, B.keys); else B.cue(s, 'text', T2);
|
|
57
|
+
B.sound(s);
|
|
58
|
+
|
|
59
|
+
await s.start();
|
|
60
|
+
</script>
|
|
61
|
+
</body>
|
|
62
|
+
</html>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Mounts entries of a brand's shader set (brand/shader-set/set.json). Copied here by `pamo shader-set build`.
|
|
2
|
+
// One entry → a loop in the set's format; several → a review board (4 columns, numbered).
|
|
3
|
+
import { scene } from 'paper-motion';
|
|
4
|
+
|
|
5
|
+
const BRAND = '/brand';
|
|
6
|
+
|
|
7
|
+
/** Periodic over the loop: a param travels from → to and back, `cycles` times per loop. */
|
|
8
|
+
const wave = (t, D, from, to, cycles = 1) => from + (to - from) * (0.5 - 0.5 * Math.cos((2 * Math.PI * cycles * t) / D));
|
|
9
|
+
|
|
10
|
+
export async function mount(entries, format, { board = false, numbers = [] } = {}) {
|
|
11
|
+
const tokens = await fetch(`${BRAND}/tokens.json`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
12
|
+
const W = format.width ?? 1920, H = format.height ?? 1080, D = format.duration ?? 6;
|
|
13
|
+
const s = scene({ width: board ? 1920 : W, height: board ? Math.round(1920 / 4 / (W / H)) * Math.ceil(entries.length / 4) : H, fps: format.fps ?? 30, duration: D, background: tokens?.colors?.ground?.hex ?? '#000' });
|
|
14
|
+
const stage = document.querySelector('#stage');
|
|
15
|
+
const cols = board ? 4 : 1, cw = board ? 1920 / 4 : W, ch = board ? Math.round(cw / (W / H)) : H;
|
|
16
|
+
const wm = tokens?.wordmark?.files ?? {};
|
|
17
|
+
const image = (img) => {
|
|
18
|
+
if (!img) return undefined;
|
|
19
|
+
if (img === 'wordmark') return `${BRAND}/${wm.onDark ?? wm.onLight}`; // light ink on transparent (LiquidMetal, GemSmoke)
|
|
20
|
+
if (img === 'wordmark-dark') return `${BRAND}/${wm.onLight ?? wm.onDark}`; // dark ink on transparent (Heatmap)
|
|
21
|
+
return img.startsWith('/') || img.startsWith('http') ? img : `${BRAND}/${img}`;
|
|
22
|
+
};
|
|
23
|
+
for (const [i, e] of entries.entries()) {
|
|
24
|
+
const el = document.createElement('div');
|
|
25
|
+
Object.assign(el.style, { position: 'absolute', left: `${(i % cols) * cw}px`, top: `${Math.floor(i / cols) * ch}px`, width: `${cw}px`, height: `${ch}px`, overflow: 'hidden', background: e.background ?? 'transparent' });
|
|
26
|
+
stage.append(el);
|
|
27
|
+
if (e.source === 'user' && e.file) {
|
|
28
|
+
// the user's own loop: played in sync with the scene, covering the frame
|
|
29
|
+
const v = Object.assign(document.createElement('video'), { src: `${BRAND}/${e.file}`, muted: true, loop: true, playsInline: true });
|
|
30
|
+
v.setAttribute('data-pm-sync', ''); v.setAttribute('loop', '');
|
|
31
|
+
Object.assign(v.style, { width: '100%', height: '100%', objectFit: 'cover' });
|
|
32
|
+
el.append(v);
|
|
33
|
+
} else {
|
|
34
|
+
const props = { ...e.props };
|
|
35
|
+
if (e.image) props.image = image(e.image);
|
|
36
|
+
const layer = s.shader(el, e.shader, props, board || !e.loop ? {} : { loop: e.loop });
|
|
37
|
+
if (e.motion) s.update((t) => layer.set({ [e.motion.param]: wave(t, D, e.motion.from, e.motion.to, e.motion.cycles) }));
|
|
38
|
+
}
|
|
39
|
+
if (board) {
|
|
40
|
+
const lab = document.createElement('div');
|
|
41
|
+
Object.assign(lab.style, { position: 'absolute', left: `${(i % cols) * cw + 10}px`, top: `${Math.floor(i / cols) * ch + 10}px`, font: '500 15px ui-monospace, Menlo, monospace', color: '#fff', background: 'rgba(0,0,0,.62)', padding: '4px 8px', borderRadius: '5px', zIndex: 2 });
|
|
42
|
+
lab.textContent = `${numbers[i] ?? i + 1} · ${e.id}`;
|
|
43
|
+
stage.append(lab);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
await s.start();
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>untitled still</title>
|
|
6
|
+
<!-- A still: an option for a board, a style frame, a sheet section. Fonts come from brand/tokens.json when it exists. -->
|
|
7
|
+
<style>
|
|
8
|
+
#stage { overflow: hidden; }
|
|
9
|
+
.abs { position: absolute; box-sizing: border-box; }
|
|
10
|
+
</style>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<main id="stage">
|
|
14
|
+
<svg id="panel" class="abs" style="left:880px;top:140px" width="600" height="620"><path /></svg>
|
|
15
|
+
<div id="title" class="abs" style="left:120px;top:260px;white-space:pre"></div>
|
|
16
|
+
<div id="line" class="abs" style="left:124px;top:520px;max-width:640px"></div>
|
|
17
|
+
</main>
|
|
18
|
+
<script type="module">
|
|
19
|
+
import { scene, organicPath } from 'paper-motion';
|
|
20
|
+
|
|
21
|
+
// Read the brand if there is one; neutral stand-ins otherwise (system sans, greys).
|
|
22
|
+
const tokens = await fetch('/brand/tokens.json').then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
23
|
+
const C = tokens?.colors ?? {};
|
|
24
|
+
const col = (role, fallback) => C[role]?.hex ?? fallback;
|
|
25
|
+
const font = (key, fallback) => (tokens?.fonts?.[key]?.family ? `'${tokens.fonts[key].family}'` : fallback);
|
|
26
|
+
// Stylesheets must finish loading before fonts.load() can find their faces.
|
|
27
|
+
await Promise.all(Object.values(tokens?.fonts ?? {}).filter((f) => f?.css).map((f) => new Promise((res) => {
|
|
28
|
+
const l = Object.assign(document.createElement('link'), { rel: 'stylesheet', href: f.css, onload: res, onerror: res });
|
|
29
|
+
document.head.append(l);
|
|
30
|
+
})));
|
|
31
|
+
// Fonts the brand ships as files load as @font-face from the brand folder.
|
|
32
|
+
for (const f of Object.values(tokens?.fonts ?? {})) if (f?.file) document.head.append(Object.assign(document.createElement('style'), { textContent: `@font-face { font-family: '${f.family}'; src: url('/brand/${f.file}'); font-weight: 100 900; }` }));
|
|
33
|
+
|
|
34
|
+
const s = scene({ width: 1600, height: 900, fps: 30, duration: 3, background: col('ground', '#f2f2f2') });
|
|
35
|
+
|
|
36
|
+
const title = document.querySelector('#title'), line = document.querySelector('#line');
|
|
37
|
+
Object.assign(title.style, { font: `${tokens?.type?.display?.weight ?? 600} 200px ${font('display', 'system-ui, sans-serif')}`, letterSpacing: tokens?.type?.display?.tracking ?? '-0.02em', color: col('figure', '#1a1a1a'), lineHeight: '0.95' });
|
|
38
|
+
Object.assign(line.style, { font: `400 34px/1.35 ${font('text', 'system-ui, sans-serif')}`, color: col('figure', '#1a1a1a') });
|
|
39
|
+
title.textContent = tokens?.wordmark?.text ?? 'brand';
|
|
40
|
+
line.textContent = 'one line in the brand’s own words.';
|
|
41
|
+
|
|
42
|
+
// Shapes follow the brand's shape language: organic → organicPath, soft → rounded, hard → square.
|
|
43
|
+
const shape = tokens?.shape?.language ?? 'soft';
|
|
44
|
+
const path = document.querySelector('#panel path');
|
|
45
|
+
const d = shape === 'organic' ? organicPath(600, 620, { radius: tokens?.shape?.radius ?? 24, seed: 3 })
|
|
46
|
+
: `M0,0 H600 V620 H0 Z`;
|
|
47
|
+
path.setAttribute('d', d);
|
|
48
|
+
path.setAttribute('fill', col('surface', '#d9d9d9'));
|
|
49
|
+
if (shape === 'soft') document.querySelector('#panel').style.borderRadius = `${tokens?.shape?.radius ?? 24}px`;
|
|
50
|
+
|
|
51
|
+
// Wait for every face before the first frame, or the still renders in a fallback font.
|
|
52
|
+
await Promise.all([title, line].map((el) => { const c = getComputedStyle(el); return document.fonts.load(`${c.fontWeight} ${c.fontSize} ${c.fontFamily}`); }));
|
|
53
|
+
await s.start();
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|