Skip to content

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

fix(skill): picture-book template fixes from the series

yzr988bd35d8bba
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/chapter.html b/.claude/skills/papermorph/assets/templates/picture-book/chapter.html
index 811c068..12851f0 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/chapter.html
+++ b/.claude/skills/papermorph/assets/templates/picture-book/chapter.html
@@ -24,7 +24,7 @@
<script>
'use strict';
const CHAPTER = { number: 1, title: 'PICTURE BOOK TITLE', minutes: 2, language: 'en' }; // next: '../ch02/' once it exists
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {} // captions on at the first visit; the reader's own choice is kept
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {} // captions on at the first visit; the reader's own choice is kept
/* ---------- beats: one per scene ----------
[id, title, run, { lead: false, pre }]: id names audio/en/<id>.mp3 (the joined scene clip) and its TIMINGS entry;
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/lib/cast.js b/.claude/skills/papermorph/assets/templates/picture-book/lib/cast.js
index 91a375c..61b144c 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/lib/cast.js
+++ b/.claude/skills/papermorph/assets/templates/picture-book/lib/cast.js
@@ -13,8 +13,8 @@
(build in g, bakeAll(g), return { g, pose(o, f) }) — see spKid for the pattern. */
'use strict';
const SP_INK = '#1d1a1a';
-// How far a shut eye's lid comes down: 1 covers it; a book may set window.SP_SHUT = .9 to leave the lid line showing.
-const SP_SHUT = window.SP_SHUT ?? 1;
+// How far a shut eye's lid comes down: .9 leaves the lid line showing (a full lid, 1, leaves two blank skin ovals).
+const SP_SHUT = window.SP_SHUT ?? .9;
// Mouths, centred on the mouth point: Rhubarb shapes A–H and X (mouths.py writes them), plus expressions. They open downward, like the show's.
const SP_MOUTHS = {
X: `<path d="M-13,0 Q0,4 13,0" fill="none" stroke="${SP_INK}" stroke-width="3" stroke-linecap="round"/>`,
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js b/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js
index 74a0d48..ccd2369 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js
+++ b/.claude/skills/papermorph/assets/templates/picture-book/lib/paper.js
@@ -113,8 +113,8 @@ const mouthAt = (clip, t) => { let m = 'X'; if (t < 0) return m; for (const [at,
/* ---------- puppets ----------
A puppet is paper pieces on brass pins, built at its hip (0, 0) facing right, feet near y 166. pose(o, f) sets the
- whole state for frame f; any key left out keeps its rest value. turn (1 … -1) squashes the flat figure to turn it
- round: through the thin middle (|turn| < .55) the front head shows, past it the figure is the mirrored profile. */
+ whole state for frame f; any key left out keeps its rest value. A profile puppet that turns round squashes its
+ side figure, shows its whole front figure through the thin middle of the turn and comes out mirrored (puppets.md). */
const pinAt = (x, y) => `<circle cx="${x}" cy="${y}" r="3.4" fill="#caa24c" stroke="#7d5f22" stroke-width="1.2"/>`;
const tf = (el, s) => { if (el._t !== s) el.setAttribute('transform', el._t = s); };
const vis = (el, on) => { const v = on ? 'inherit' : 'hidden'; if (el._v !== v) el.setAttribute('visibility', el._v = v); };
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/lib/shared.js b/.claude/skills/papermorph/assets/templates/picture-book/lib/shared.js
index b92b208..e90e053 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/lib/shared.js
+++ b/.claude/skills/papermorph/assets/templates/picture-book/lib/shared.js
@@ -42,7 +42,7 @@ function sfxTick() {
a.play().catch(() => {}); sfxOn.push(a); a.onended = () => sfxOn.splice(sfxOn.indexOf(a), 1);
if (e.at <= from || e.at > P.t) a.addEventListener('loadedmetadata', () => { a.currentTime = P.t - e.at; }, { once: true }); // a long bed joined mid-way
}
- for (const a of sfxOn) { a.playbackRate = P.rate || 1; if (on === a.paused) on ? a.play().catch(() => {}) : a.pause(); } // a pause holds them, play resumes
+ for (const a of sfxOn) { a.playbackRate = P.rate || 1; if (on === a.paused && !a.ended) on ? a.play().catch(() => {}) : a.pause(); } // a pause holds them, play resumes
sfxLast = { i: P.i, t: on ? P.t : from, pend: !on && (!same || !!sfxLast.pend) };
requestAnimationFrame(sfxTick);
}
diff --git a/.claude/skills/papermorph/assets/templates/picture-book/painted.json b/.claude/skills/papermorph/assets/templates/picture-book/painted.json
index 62eb5dd..2721c56 100644
--- a/.claude/skills/papermorph/assets/templates/picture-book/painted.json
+++ b/.claude/skills/papermorph/assets/templates/picture-book/painted.json
@@ -1,11 +1,10 @@
{
"frame": [1600, 900],
"pad": [60, 34],
- "fonts": { "sign": "/System/Library/Fonts/STHeiti Medium.ttc" },
"sets": {
"room": [
{ "name": "wall", "file": "bg-room.png",
- "words": [{ "x": 800, "y": 200, "size": 60, "text": "WELCOME", "colour": "#f6d68a", "font": "sign" }] },
+ "words": [{ "x": 800, "y": 200, "size": 60, "text": "WELCOME", "colour": "#f6d68a" }] },
{ "name": "table", "file": "table.png", "cut": { "x": 1000, "bottom": 860, "width": 520 } }
]
},
diff --git a/site/joke-collection/ch01/index.html b/site/joke-collection/ch01/index.html
index 4a8938b..fbebb16 100644
--- a/site/joke-collection/ch01/index.html
+++ b/site/joke-collection/ch01/index.html
@@ -24,7 +24,7 @@
<script>
'use strict';
const CHAPTER = { number: 1, title: 'Breakfast in the Bathroom', minutes: 2, language: 'en', next: '../ch02/' };
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch02/index.html b/site/joke-collection/ch02/index.html
index 519f4b7..1194e4a 100644
--- a/site/joke-collection/ch02/index.html
+++ b/site/joke-collection/ch02/index.html
@@ -27,7 +27,7 @@
'use strict';
const CHAPTER = { number: 2, title: 'Do You Need a Bag?', minutes: 2, language: 'en', next: '../ch03/' };
// captions on the first time: half the film is Japanese
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch03/index.html b/site/joke-collection/ch03/index.html
index b445420..b4996d6 100644
--- a/site/joke-collection/ch03/index.html
+++ b/site/joke-collection/ch03/index.html
@@ -27,7 +27,7 @@
'use strict';
const CHAPTER = { number: 3, title: 'How to Move a Cow', minutes: 2, language: 'en', next: '../ch04/' };
// captions on the first time: half the film is Chinese and Hindi
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch04/index.html b/site/joke-collection/ch04/index.html
index 0750b29..2de9588 100644
--- a/site/joke-collection/ch04/index.html
+++ b/site/joke-collection/ch04/index.html
@@ -24,7 +24,7 @@
<script>
'use strict';
const CHAPTER = { number: 4, title: 'The Dog Ate My Homework', minutes: 2, language: 'en', next: '../ch05/' };
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch05/index.html b/site/joke-collection/ch05/index.html
index 740de92..d8b37e8 100644
--- a/site/joke-collection/ch05/index.html
+++ b/site/joke-collection/ch05/index.html
@@ -26,7 +26,7 @@
<script>
'use strict';
const CHAPTER = { number: 5, title: 'The Penguin and the Zoo', minutes: 2, language: 'en', next: '../ch06/' };
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch06/index.html b/site/joke-collection/ch06/index.html
index cf5968c..193faf1 100644
--- a/site/joke-collection/ch06/index.html
+++ b/site/joke-collection/ch06/index.html
@@ -26,7 +26,7 @@
<script>
'use strict';
const CHAPTER = { number: 6, title: 'Four Dogs', minutes: 2, language: 'en', next: '../ch07/' };
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/joke-collection/ch07/index.html b/site/joke-collection/ch07/index.html
index 64c8084..f31a734 100644
--- a/site/joke-collection/ch07/index.html
+++ b/site/joke-collection/ch07/index.html
@@ -29,7 +29,7 @@
'use strict';
const CHAPTER = { number: 7, title: 'Baka Means Cow', minutes: 2, language: 'en' };
// captions on the first time: a third of the film is Spanish and Japanese
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- beats: one per scene ---------- */
const BEATS = [
diff --git a/site/little-red-riding-hood/ch01/index.html b/site/little-red-riding-hood/ch01/index.html
index 2f8e4c0..321f341 100644
--- a/site/little-red-riding-hood/ch01/index.html
+++ b/site/little-red-riding-hood/ch01/index.html
@@ -20,7 +20,7 @@
'use strict';
const CHAPTER = { number: 1, title: 'Little Red Riding Hood', minutes: 4, language: 'en' };
// A picture book: captions are on unless the reader turned them off.
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
// The time (beat clock) of a word: part `b` of a joined scene, `w` seconds into its clip.
const word = (scene, pre, b, w) => pre + TIMINGS[scene].parts[b] + w;
diff --git a/site/three-little-pigs/ch01/index.html b/site/three-little-pigs/ch01/index.html
index 24173fd..cc89a04 100644
--- a/site/three-little-pigs/ch01/index.html
+++ b/site/three-little-pigs/ch01/index.html
@@ -20,7 +20,7 @@
'use strict';
const CHAPTER = { number: 1, title: 'The Three Little Pigs', minutes: 4, language: 'en' };
// A picture book: captions are on unless the reader turned them off.
-try { if (localStorage.getItem('captions') === null) setCaptions(true); } catch {}
+try { if (localStorage.getItem('captions') === null) setCaptions(true, false); } catch {}
/* ---------- helpers ---------- */
const clamp01 = x => Math.min(1, Math.max(0, x)), smooth = x => { x = clamp01(x); return x * x * (3 - 2 * x); };