Skip to content

An AI skill that turns books into animated, narrated, interactive web experiences

feat(site): Proteus, upright: the same film on the 900×1600 stage

yzrdba195ce8e84
diff --git a/site/proteus/ch02/audio/bgm/haydn-lark-finale.mp3 b/site/proteus/ch02/audio/bgm/haydn-lark-finale.mp3
new file mode 100644
index 0000000..2ed1aff
Binary files /dev/null and b/site/proteus/ch02/audio/bgm/haydn-lark-finale.mp3 differ
diff --git a/site/proteus/ch02/audio/en/boar.mp3 b/site/proteus/ch02/audio/en/boar.mp3
new file mode 100644
index 0000000..d2d60c3
Binary files /dev/null and b/site/proteus/ch02/audio/en/boar.mp3 differ
diff --git a/site/proteus/ch02/audio/en/dragon.mp3 b/site/proteus/ch02/audio/en/dragon.mp3
new file mode 100644
index 0000000..ff99428
Binary files /dev/null and b/site/proteus/ch02/audio/en/dragon.mp3 differ
diff --git a/site/proteus/ch02/audio/en/leopard.mp3 b/site/proteus/ch02/audio/en/leopard.mp3
new file mode 100644
index 0000000..16edb4b
Binary files /dev/null and b/site/proteus/ch02/audio/en/leopard.mp3 differ
diff --git a/site/proteus/ch02/audio/en/lion.mp3 b/site/proteus/ch02/audio/en/lion.mp3
new file mode 100644
index 0000000..18aa269
Binary files /dev/null and b/site/proteus/ch02/audio/en/lion.mp3 differ
diff --git a/site/proteus/ch02/audio/en/open.mp3 b/site/proteus/ch02/audio/en/open.mp3
new file mode 100644
index 0000000..d8b8d95
Binary files /dev/null and b/site/proteus/ch02/audio/en/open.mp3 differ
diff --git a/site/proteus/ch02/audio/en/timings.js b/site/proteus/ch02/audio/en/timings.js
new file mode 100644
index 0000000..2f9b358
--- /dev/null
+++ b/site/proteus/ch02/audio/en/timings.js
@@ -0,0 +1,128 @@
+window.TIMINGS = {
+ "open": {
+ "dur": 4.369,
+ "marks": {
+ "old": 0.4,
+ "proteus": 1.72,
+ "hands": 3.26
+ },
+ "cues": [
+ [
+ 0.0,
+ "Homer's old man of the sea, Proteus, changes shape in your hands."
+ ]
+ ]
+ },
+ "lion": {
+ "dur": 4.517,
+ "marks": {
+ "lion": 0.56,
+ "lesson": 2.44
+ },
+ "cues": [
+ [
+ 0.0,
+ "First a lion with a great mane:"
+ ],
+ [
+ 2.44,
+ "a lesson that draws itself."
+ ]
+ ]
+ },
+ "dragon": {
+ "dur": 3.643,
+ "marks": {
+ "dragon": 0.32,
+ "book": 1.66
+ },
+ "cues": [
+ [
+ 0.0,
+ "Then a dragon:"
+ ],
+ [
+ 1.66,
+ "a picture book of paper puppets."
+ ]
+ ]
+ },
+ "leopard": {
+ "dur": 2.335,
+ "marks": {
+ "leopard": 0.0,
+ "film": 1.1
+ },
+ "cues": [
+ [
+ 0.0,
+ "A leopard:"
+ ],
+ [
+ 1.1,
+ "a narrated film."
+ ]
+ ]
+ },
+ "boar": {
+ "dur": 2.988,
+ "marks": {
+ "boar": 0.0,
+ "short": 1.38
+ },
+ "cues": [
+ [
+ 0.0,
+ "A wild boar:"
+ ],
+ [
+ 1.38,
+ "a short for the phone."
+ ]
+ ]
+ },
+ "water": {
+ "dur": 2.767,
+ "marks": {
+ "water": 0.0,
+ "map": 1.22
+ },
+ "cues": [
+ [
+ 0.0,
+ "Running water:"
+ ],
+ [
+ 1.22,
+ "a map to explore."
+ ]
+ ]
+ },
+ "tree": {
+ "dur": 6.26,
+ "marks": {
+ "tree": 0.14,
+ "one": 2.82,
+ "many": 3.98,
+ "name": 5.24
+ },
+ "cues": [
+ [
+ 0.0,
+ "And a tree, where every shape stands."
+ ],
+ [
+ 2.82,
+ "One source."
+ ],
+ [
+ 3.98,
+ "Many shapes."
+ ],
+ [
+ 5.24,
+ "Papermorph."
+ ]
+ ]
+ }
+};
diff --git a/site/proteus/ch02/audio/en/tree.mp3 b/site/proteus/ch02/audio/en/tree.mp3
new file mode 100644
index 0000000..1130d85
Binary files /dev/null and b/site/proteus/ch02/audio/en/tree.mp3 differ
diff --git a/site/proteus/ch02/audio/en/water.mp3 b/site/proteus/ch02/audio/en/water.mp3
new file mode 100644
index 0000000..e8993c1
Binary files /dev/null and b/site/proteus/ch02/audio/en/water.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/growl.mp3 b/site/proteus/ch02/audio/sfx/growl.mp3
new file mode 100644
index 0000000..c31a850
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/growl.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/grunt.mp3 b/site/proteus/ch02/audio/sfx/grunt.mp3
new file mode 100644
index 0000000..5fdf1e2
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/grunt.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/hiss.mp3 b/site/proteus/ch02/audio/sfx/hiss.mp3
new file mode 100644
index 0000000..39b9580
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/hiss.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/roar.mp3 b/site/proteus/ch02/audio/sfx/roar.mp3
new file mode 100644
index 0000000..d83e1e4
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/roar.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/splash.mp3 b/site/proteus/ch02/audio/sfx/splash.mp3
new file mode 100644
index 0000000..cec8ed8
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/splash.mp3 differ
diff --git a/site/proteus/ch02/audio/sfx/whoosh.mp3 b/site/proteus/ch02/audio/sfx/whoosh.mp3
new file mode 100644
index 0000000..6c63e5e
Binary files /dev/null and b/site/proteus/ch02/audio/sfx/whoosh.mp3 differ
diff --git a/site/proteus/ch02/index.html b/site/proteus/ch02/index.html
new file mode 100644
index 0000000..3c0ecd9
--- /dev/null
+++ b/site/proteus/ch02/index.html
@@ -0,0 +1,155 @@
+<!doctype html>
+<html lang="en" data-stage="portrait">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Proteus, upright</title>
+<link rel="stylesheet" href="../lib/engine.css">
+<link rel="expect" href="#bar" blocking="render">
+</head>
+<body>
+<!-- A documentary chapter: one beat per paragraph of the script. After engine.py has made site/<book>/lib/, copy lib/
+ found pictures; add lib/lines.js (trace.py) and img/frames.js (frames.py) when the film uses traced drawings or clips. -->
+<script src="../lib/engine.js"></script>
+<script src="../lib/film.js"></script>
+<script src="audio/en/timings.js"></script>
+<script>
+'use strict';
+// lead: false — every opening is timed by hand, so the engine never pulls a beat's first reveal earlier
+const CHAPTER = { number: 2, title: 'Proteus, upright', minutes: 1, language: 'en', lead: false };
+
+// the upright cut of ch01: the same voice, sounds and timing; each card and its word above Proteus, inside the safe
+// area (x 50–810, y 130–1290)
+const CX = 450, CY = 480, KY = 800; // each shape's card, and its word under it
+
+// a card for one shape with its word, at the shape's second mark
+function shapeCard(p, name, col, word, t0, cx = CX) {
+ const g = sheet(p, cx, CY, col, t0 - .1);
+ CARDS[name](g, t0);
+ key(p, word, cx, KY, t0 + .1, { size: 72, fill: col });
+ tw(S.pro.disc, { x: cx, c_fill: col }, Math.max(0, t0 - 1.3), .9, soft); // the colour field follows the card
+ return g;
+}
+// the leopard's spots, on its body in stage coordinates; they fly off to be the film strip's holes
+const SPOTS = [[-190, -112], [-140, -128], [-95, -104], [-50, -128], [-5, -108], [40, -130], [85, -110], [130, -128], [-120, -95], [-25, -90], [65, -92], [150, -100]];
+const HOLES = SPOTS.map((_, i) => [CX - 220 + (i % 6) * 88, CY + (i < 6 ? -146 : 146)]);
+// a hand of the one who holds on (Menelaus), cut from paper, reaching from the side dir (-1 left, 1 right)
+function hand(p, x, y, dir) {
+ const g = G(p, { x: x - dir * 260, y, o: 0 });
+ const h = G(g, { s: dir < 0 ? 1 : -1 }); // drawn for the left hand; mirrored for the right
+ path(h, 'M-240 -30H-70C-40 -44 -6 -34 6 -8C16 16 12 44 -10 52C-30 58 -60 50 -80 40H-240Z', { fill: '#c98f62' });
+ path(h, 'M-74 -32C-66 -66 -30 -72 -12 -54C-20 -44 -36 -40 -50 -30Z', { fill: '#d9a275' });
+ path(h, 'M-16 -14C-6 -10 0 0 2 8M-20 10C-10 14 -4 22 -4 30M-30 32C-22 36 -18 42 -18 46', { stroke: '#a8714a', 'stroke-width': 3, fill: 'none', 'stroke-linecap': 'round' });
+ return g;
+}
+
+/* ---------- beats ----------
+ [id, title, run, extra]: id names audio/en/<id>.mp3 and its TIMINGS entry; m('mark') is the time a word is heard.
+ `pre` gives the picture seconds before the narration starts. The last frame is the first (the page), so it loops. */
+// every beat's length on screen, hold included (a little over what it needs; ?lengths shows it), so the film has one
+// clock: the start of each beat (the waves run on it) and its whole length, the loop
+const LEN = { open: 5.8, lion: 5.4, dragon: 4.3, leopard: 3.8, boar: 4.1, water: 4.2, tree: 9.3 };
+const AT0 = {}; let FILM_LEN = 0;
+for (const id in LEN) { AT0[id] = FILM_LEN; FILM_LEN += LEN[id]; }
+window.FILM_LEN = FILM_LEN;
+
+// a beat's picture: the last beat's card fades on this beat's clock (in the export too), gone before Proteus lands
+function nextPanel() {
+ if (S.panel) hide(S.panel, 0, .35);
+ return panel(.5);
+}
+
+// Proteus changes in beat `id`: the morph, a splash as he melts, and the animal's call once he has the shape
+// (the call waits for the pause after the animal is named, so it never covers a word)
+function change(id, D, from, to, t0, dur, call, vol = 1, callAt = t0 + dur) {
+ S.at0 = AT0[id];
+ morph(D, from, to, t0, dur, callAt);
+ sfx(id, t0, 'splash', .45);
+ if (call) sfx(id, callAt, call, vol);
+}
+
+const BEATS = [
+ ['open', 'Proteus', (m, D) => {
+ proteus();
+ const p = nextPanel();
+ change('open', D, 'page', 'water', .3, 1.4, null, 1, m('hands'));
+ key(p, 'Proteus', CX, CY + 20, m('proteus'), { size: 120, fill: DEEP });
+ const tg = tag(p, 'Odyssey, book IV', CX, CY + 80, m('proteus', .4), { size: 30, anchor: 'middle' });
+ tg.setAttribute('font-style', 'italic');
+ [-1, 1].forEach(dir => { const W = SHAPES.water, h = hand(p, W.x + dir * 130, W.y - 150, dir); tw(h, { x: W.x + dir * 130, o: 1 }, m('hands', -.3), .5, out);
+ tw(h, { x: W.x + dir * 330, o: 0 }, D - .1, .5, io); // he slips out of them
+ });
+ }, { pre: .4 }],
+ ['lion', 'A lesson', (m, D) => {
+ const p = nextPanel();
+ change('lion', D, 'water', 'lion', Math.max(0, m('lion', -.45)), .9, 'roar', .8, m('lesson', -.72));
+ shapeCard(p, 'lesson', RED, 'a lesson', m('lesson'));
+ }],
+ ['dragon', 'A picture book', (m, D) => {
+ const p = nextPanel();
+ change('dragon', D, 'lion', 'dragon', Math.max(0, m('dragon', -.3)), .9, 'hiss', .7, m('book', -.56));
+ shapeCard(p, 'book', BLUE, 'a picture book', m('book'));
+ }],
+ ['leopard', 'A film', (m, D) => {
+ const p = nextPanel();
+ change('leopard', D, 'dragon', 'leopard', m('leopard', -.6), .8, 'growl', 1.4, m('film', -.62));
+ const L0 = SHAPES.leopard, strip = G(p, { x: L0.x, y: L0.y });
+ shapeCard(p, 'film', PURPLE, 'a film', m('film'));
+ p.appendChild(strip); // the spots go over the card as its holes
+ clockRun(t => { // on the body, then level while they fly
+ const { x, y, r } = st(S.pro.g), k = smooth01(span01(t, m('film'), m('film', .7)));
+ put(strip, { x: x + (L0.x - x) * k, y: y + (L0.y - y) * k, r: r * (1 - k) });
+ }, D, { tail: true });
+ SPOTS.forEach(([x, y], i) => {
+ const e = G(strip, { x, y, o: 0 });
+ const r = mk('rect', { x: -11, y: -8, width: 22, height: 16, rx: 5, fill: '#3b2357' }, e);
+ show(e, m('leopard', .15), .3);
+ tw(e, { x: HOLES[i][0] - L0.x, y: HOLES[i][1] - L0.y }, m('film', i * .03), .7, soft);
+ tw(r, { c_fill: '#f3ede0' }, m('film', .5), .3);
+ });
+ }, { pre: .6 }],
+ ['boar', 'A short', (m, D) => {
+ const p = nextPanel();
+ change('boar', D, 'leopard', 'boar', m('boar', -.5), .8, 'grunt', .9, m('short', -.44));
+ shapeCard(p, 'short', OCHRE, 'a short', m('short'));
+ }, { pre: .5 }],
+ ['water', 'A map', (m, D) => {
+ const p = nextPanel();
+ change('water', D, 'boar', 'stream', m('water', -.5), .9, 'whoosh', .6, m('map', -.54));
+ shapeCard(p, 'map', TEAL, 'a map', m('map'));
+ }, { pre: .5 }],
+ ['tree', 'One source', (m, D) => {
+ const p = nextPanel();
+ const t1 = m('tree', -.5), t2 = m('name', 2.2); // into the tree, then back to the page
+ sfx('tree', t1, 'splash', .7); sfx('tree', t2, 'splash', .6);
+ S.at0 = AT0.tree; sea(D);
+ clockRun(t => t < t2 ? drawPro('stream', 'tree', smooth01(span01(t, t1, t1 + 1.1)), t, t - t1 - 1.1)
+ : drawPro('tree', 'page', smooth01(span01(t, t2, t2 + 1.2)), t), D, { tail: true });
+ S.pro.at = 'page';
+ const T0 = SHAPES.tree;
+ const shelf = [['lesson', RED, -250, -322], ['book', BLUE, -220, -492], ['film', PURPLE, 0, -684], ['short', OCHRE, 228, -547], ['map', TEAL, 252, -380]];
+ shelf.forEach(([name, col, x, y], i) => {
+ const g = sheet(p, T0.x + x, T0.y + y, col, m('tree', .9 + i * .22), { s: .3 });
+ CARDS[name](g, m('tree', 1 + i * .22));
+ tw(g, { x: SHAPES.page.x, y: SHAPES.page.y - 210, s: .1 }, t2 - .3 + i * .05, .6, io); // the shapes go back into the one source
+ hide(g, t2 - .1 + i * .05, .3);
+ });
+ [['One source.', 250, m('one')], ['Many shapes.', 350, m('many')]].forEach(([w, y, t]) => hide(key(p, w, CX, y, t, { size: 88 }), t2, .5));
+ hide(key(p, 'Papermorph', CX, 450, m('name'), { size: 76, fill: DEEP }), t2, .5);
+ tw(S.pro.disc, { y: 330, c_fill: WATER }, m('one', -.6), .9, soft);
+ tw(S.pro.disc, { y: CY }, t2, 1.2, soft); // where the film starts, so it loops
+ prog(() => {}, 0, t2 + 1.25); // hold the page a moment: the film's last frame is its first
+ }],
+].map(([id, title, run, extra]) => ({ id, title, run, ...extra, minDur: LEN[id] }));
+
+/* ---------- music ----------
+ One music(file, [beat ids], gain, fade) per part of the film; window.MUSIC_UP_IN_PRE lifts it in a music-only opening. */
+window.MUSIC_UP_IN_PRE = ['open'];
+music('audio/bgm/haydn-lark-finale.mp3', BEATS.map(b => b.id), .6, 0);
+
+// the fonts must be in before words are measured
+Promise.all(['600 40px Oswald', '500 40px Oswald', 'italic 400 40px "EB Garamond"', '400 40px "EB Garamond"']
+ .map(f => document.fonts.load(f))).then(boot);
+</script>
+</body>
+</html>
diff --git a/site/proteus/lib/film.js b/site/proteus/lib/film.js
index f791ac9..e7f7f5e 100644
--- a/site/proteus/lib/film.js
+++ b/site/proteus/lib/film.js
@@ -273,6 +273,10 @@ const SHAPES = {
[40, -432], [45, -300], [50, -288], [330, -332], [332, -310], [55, -256], [60, -40], [98, 0]] },
};
for (const k in SHAPES) SHAPES[k].pts = resample(SHAPES[k].pts);
+// the upright stage: Proteus stands in the middle of the lower half (his cards and words go above him), and every
+// change is a hop in place rather than a leap across
+const GROUND = PORTRAIT ? 1250 : 770;
+if (PORTRAIT) for (const k in SHAPES) Object.assign(SHAPES[k], { x: 450, y: GROUND + SHAPES[k].y - 760 });
// what each animal does once it has its shape (u: seconds since it settled): a move of the whole body, and a bend of
// its outline; each comes with its sound in the chapter
const bump = (u, a, b) => Math.sin(Math.PI * span01(u, a, b));
@@ -311,9 +315,10 @@ const DECOR = {
function proteus() {
const back = G(scene, {});
const disc = mk('circle', { r: 300, fill: WATER }, back);
- put(disc, { x: 1130, y: 410, o: .16 });
- path(back, 'M-20 770L120 764L300 772L520 762L760 770L980 763L1220 771L1440 764L1620 770V920H-20Z', { fill: '#e8d9b8' });
- const waves = [['#9cc6d8', 852, 0], ['#6fb3c8', 876, 60]].map(([fill, y, dx]) => {
+ put(disc, PORTRAIT ? { x: 450, y: 480, o: .16 } : { x: 1130, y: 410, o: .16 });
+ path(back, PORTRAIT ? 'M-20 1250L140 1244L330 1252L520 1243L700 1251L920 1245V1620H-20Z'
+ : 'M-20 770L120 764L300 772L520 762L760 770L980 763L1220 771L1440 764L1620 770V920H-20Z', { fill: '#e8d9b8' });
+ const waves = [['#9cc6d8', SH - 48, 0], ['#6fb3c8', SH - 24, 60]].map(([fill, y, dx]) => {
const w = G(scene, {});
path(w, 'M-200 0' + Array.from({ length: 22 }, (_, i) => `q50 -26 100 0`).join('') + 'V60H-200Z', { fill, transform: `translate(${dx} ${y})` });
return w;
@@ -364,7 +369,7 @@ function drawPro(a, b, q, t, u = -1) {
}).join('') + 'Z';
const col = q < .5 ? tint(A.col, WATER, q * 2) : tint(WATER, B.col, q * 2 - 1);
pr.body.setAttribute('d', d); pr.shadow.setAttribute('d', d); setOnce(pr.body, 'fill', col);
- const gx = A.x + (B.x - A.x) * q, gy = A.y + (B.y - A.y) * q - (Math.abs(B.x - A.x) > 100 ? 160 * k : 0); // a leap across
+ const gx = A.x + (B.x - A.x) * q, gy = A.y + (B.y - A.y) * q - (Math.abs(B.x - A.x) > 100 || PORTRAIT && a !== b ? 160 * k : 0); // a leap
const act = q === 1 && B.act ? B.act(u) : {};
put(pr.g, { x: gx + (act.x || 0), y: gy + (act.y || 0), s: A.s + (B.s - A.s) * q, r: act.r || 0 });
for (const n in pr.decor) {