Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

README: the owl lesson sheet plus its timelapse and full captioned video; owl social cut with sound

Alex Greenshpun3ee198cdd2d6
diff --git a/.gitignore b/.gitignore
index 596eb99..092846e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,6 @@ skills/anidoodle/engine/src/canvas-core/lessonClawd*.ts
skills/anidoodle/engine/src/hosts/page-lessonClawd*.ts
# agent worktrees
.claude/
+# PRIVATE: local-only studio pieces
+skills/anidoodle/engine/src/canvas-core/clawd*.ts
+skills/anidoodle/engine/src/hosts/page-clawd*.ts
diff --git a/README.es-ES.md b/README.es-ES.md
index 63e9622..a8b278f 100644
--- a/README.es-ES.md
+++ b/README.es-ES.md
@@ -114,8 +114,10 @@ Ilustraciones interactivas para webs reales: una mascota que sigue el cursor y r
## Aprende a dibujar
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="Cómo dibujar un búho en nueve pasos: de dos círculos a la estructura, el contorno, los ojos, las sombras y las plumas, hasta el resto del búho">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="Cómo dibujar un búho en nueve pasos: de dos círculos a la estructura, el contorno, los ojos, las sombras y las plumas, hasta el resto del búho">
+ <img src="assets/readme/lesson.gif" width="40%" alt="El búho dibujándose paso a paso">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">Ver la lección completa con subtítulos (mp4, 95 s)</a></p>
Pregunta cómo dibujar algo, o trae un dibujo, y anidoodle lo reconstruye como lección: una lámina paso a paso y un timelapse con subtítulos. Cada paso explica qué observar, cómo hacerlo y cuál es el error más común.
diff --git a/README.fr-FR.md b/README.fr-FR.md
index 9da305b..4236a09 100644
--- a/README.fr-FR.md
+++ b/README.fr-FR.md
@@ -114,8 +114,10 @@ Des illustrations interactives pour de vrais sites : une mascotte qui suit le cu
## Apprendre à dessiner
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="Dessiner un hibou en neuf étapes : de deux cercles à la structure, au contour, aux yeux, aux ombres et aux plumes, jusqu'au reste du hibou">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="Dessiner un hibou en neuf étapes : de deux cercles à la structure, au contour, aux yeux, aux ombres et aux plumes, jusqu'au reste du hibou">
+ <img src="assets/readme/lesson.gif" width="40%" alt="Le hibou se dessine étape par étape">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">Voir la leçon complète sous-titrée (mp4, 95 s)</a></p>
Demandez comment dessiner quelque chose, ou apportez un de vos dessins, et anidoodle le reconstruit en leçon : une planche étape par étape et un accéléré légendé, avec, à chaque étape, ce qu'il faut observer, comment procéder et l'erreur courante.
diff --git a/README.ja-JP.md b/README.ja-JP.md
index 7c18456..09dbbe4 100644
--- a/README.ja-JP.md
+++ b/README.ja-JP.md
@@ -114,8 +114,10 @@
## 描き方を学ぶ
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="フクロウの描き方を9ステップで。2つの円から、構造、輪郭、目、陰影、羽根を経て、残りのフクロウまで">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="フクロウの描き方を9ステップで。2つの円から、構造、輪郭、目、陰影、羽根を経て、残りのフクロウまで">
+ <img src="assets/readme/lesson.gif" width="40%" alt="フクロウが一段階ずつ描かれていくタイムラプス">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">キャプション付きのレッスン全編を見る (mp4, 95秒)</a></p>
描き方を尋ねるか、自分の絵を持ち込めば、anidoodleがレッスンに組み直す。手順シートと字幕付きタイムラプスで、各段階に観察する点、描き方、よくある間違いを添える。
diff --git a/README.ko-KR.md b/README.ko-KR.md
index 9b44dc6..9088b59 100644
--- a/README.ko-KR.md
+++ b/README.ko-KR.md
@@ -114,8 +114,10 @@
## 그림 그리는 법 배우기
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="부엉이 그리는 법 9단계: 동그라미 두 개에서 시작해 구조, 윤곽, 눈, 그림자, 깃털을 거쳐 나머지 부엉이까지">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="부엉이 그리는 법 9단계: 동그라미 두 개에서 시작해 구조, 윤곽, 눈, 그림자, 깃털을 거쳐 나머지 부엉이까지">
+ <img src="assets/readme/lesson.gif" width="40%" alt="부엉이가 단계별로 그려지는 타임랩스">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">자막이 있는 전체 레슨 보기 (mp4, 95초)</a></p>
무언가 그리는 법을 묻거나 직접 그린 그림을 가져오면, anidoodle이 수업으로 다시 구성해요. 단계별 시트와 자막이 달린 타임랩스에 각 단계에서 볼 것, 그리는 법, 흔한 실수를 담아요.
diff --git a/README.md b/README.md
index ad9d808..6e7c58f 100644
--- a/README.md
+++ b/README.md
@@ -114,8 +114,10 @@ Interactive illustrations for real sites: a mascot that follows the cursor and r
## Learn to draw
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="How to draw an owl in nine steps: from two circles through construction, outline, eyes, shadows and feathers, to the rest of the owl">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="How to draw an owl in nine steps: from two circles through construction, outline, eyes, shadows and feathers, to the rest of the owl">
+ <img src="assets/readme/lesson.gif" width="40%" alt="The owl drawing itself, step by step, with captions">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">Watch the full lesson with captions (mp4, 95 s)</a></p>
Ask how to draw something, or bring a drawing, and anidoodle rebuilds it as a lesson: a step sheet and a captioned timelapse, each step with what to look for, how to do it, and the common mistake.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 94d4704..2022dc7 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -114,8 +114,10 @@
## 学着画画
<p align="center">
- <img src="assets/readme/lesson.jpg" width="100%" alt="九步画一只猫头鹰:从两个圆开始,经过结构、轮廓、眼睛、阴影和羽毛,直到画完剩下的猫头鹰">
+ <img src="assets/readme/lesson.jpg" width="56%" alt="九步画一只猫头鹰:从两个圆开始,经过结构、轮廓、眼睛、阴影和羽毛,直到画完剩下的猫头鹰">
+ <img src="assets/readme/lesson.gif" width="40%" alt="猫头鹰一步步画出来的延时动画">
</p>
+<p align="center"><a href="assets/readme/lesson.mp4">观看带字幕的完整课程 (mp4, 95 秒)</a></p>
问它怎么画一样东西,或者带来自己的画,anidoodle 就会把它重新拆成一堂课:分步图和带字幕的延时视频,每一步都说明该观察什么、怎样动笔,以及常见的错误。
diff --git a/assets/readme/lesson.gif b/assets/readme/lesson.gif
new file mode 100644
index 0000000..1c66562
Binary files /dev/null and b/assets/readme/lesson.gif differ
diff --git a/assets/readme/lesson.jpg b/assets/readme/lesson.jpg
index ced3d23..d6a4a95 100644
Binary files a/assets/readme/lesson.jpg and b/assets/readme/lesson.jpg differ
diff --git a/assets/readme/lesson.mp4 b/assets/readme/lesson.mp4
new file mode 100644
index 0000000..0210b69
Binary files /dev/null and b/assets/readme/lesson.mp4 differ
diff --git a/skills/anidoodle/engine/src/canvas-core/banner.ts b/skills/anidoodle/engine/src/canvas-core/banner.ts
index 9166361..415de2a 100644
--- a/skills/anidoodle/engine/src/canvas-core/banner.ts
+++ b/skills/anidoodle/engine/src/canvas-core/banner.ts
@@ -152,7 +152,7 @@ const fineliner = (g: Gfx, a: P, b: P) => rod(g, a, b, [
{ t0: 0.82, t1: 0.95, r0: 7, r1: 2.6, c: "#8d8d90", sh: "#48484b" }, { t0: 0.95, t1: 1, r0: 1, r1: 0.7, c: "#bdbdbd", sh: "#6c6c6c" }]);
const brush = (g: Gfx, a: P, b: P, handle: string, hsh: string, tip: string) => rod(g, a, b, [
{ t0: 0, t1: 0.62, r0: 3, r1: 6, c: handle, sh: hsh }, { t0: 0.62, t1: 0.8, r0: 6.4, r1: 5.8, c: "#d6d0c4", sh: "#817b72" }, { t0: 0.8, t1: 1, r0: 5.8, r1: 0.4, c: tip, sh: mix(tip, "#000000", 0.5), round: true }]);
-const dipPen = (g: Gfx, tip: P, ang: number, s: State) => {
+export const dipPen = (g: Gfx, tip: P, ang: number, s: Pick<State, "glint" | "glintT">) => {
const back: P = [tip[0] - Math.cos(ang) * 340, tip[1] - Math.sin(ang) * 340];
const pt = rod(g, back, tip, [{ t0: 0, t1: 0.66, r0: 3.2, r1: 6, c: "#4a2f26", sh: "#1f1411" }, { t0: 0.66, t1: 0.8, r0: 6.4, r1: 5, c: "#c2a063", sh: "#7a6234" }]);
const nib = [pt(0.8, -4.8), pt(0.87, -5), pt(0.95, -2.5), pt(1, 0), pt(0.95, 2.5), pt(0.87, 5), pt(0.8, 4.8)];
diff --git a/skills/anidoodle/engine/src/canvas-core/lessonOwl.ts b/skills/anidoodle/engine/src/canvas-core/lessonOwl.ts
index 182609e..18ba332 100644
--- a/skills/anidoodle/engine/src/canvas-core/lessonOwl.ts
+++ b/skills/anidoodle/engine/src/canvas-core/lessonOwl.ts
@@ -229,7 +229,10 @@ export const owlScore = (): Score => {
const radial = (cx: number, cy: number, a0: number, a1: number, rim: P[], seed: number) => { const out: Ink[] = [], r = rng(seed), reg = polyR(rim); for (let k = 0; k < 34; k++) { const a = a0 + ((a1 - a0) * (k + r() * 0.6)) / 34, c = Math.cos(a), s = Math.sin(a); let r1 = 42; while (r1 < 140 && reg.has(cx + c * (r1 + 4), cy + s * (r1 + 4))) r1 += 3; if (r1 < 52) continue; const r0 = 40 + r() * 6; out.push(S([[cx + c * r0, cy + s * r0], [cx + c * (r0 + r1) / 2 + s * 2, cy + s * (r0 + r1) / 2 - c * 2], [cx + c * (r1 - 3), cy + s * (r1 - 3)]], 2.1, 0.6)); } return out; };
b.addAll("face.discL", "face", "line", "line", radial(eyeL.cx, eyeL.cy + 4, Math.PI * 0.35, Math.PI * 1.25, discL, 84));
b.addAll("face.discR", "face", "line", "line", radial(eyeR.cx, eyeR.cy + 4, -Math.PI * 0.25, Math.PI * 0.65, discR, 85));
- b.erase("circles.lift", "circles", "guides", eraserPath([0, 30, 1000, 1170], { seed: 86, bite: 70 }), { width: 80, ghost: 0.03 });
+ // lift the blue where it is: back and forth over the owl, then once along each branch line (never scrubbing bare paper)
+ b.erase("circles.lift", "circles", "guides", eraserPath([226, 36, 774, 1146], { seed: 86, bite: 50 }), { width: 90, ghost: 0.03 });
+ b.erase("branch.liftTop", "branch", "guides", [[10, bTop(10)], [505, bTop(505)], [1000, bTop(1000)]], { width: 34, ghost: 0.03 });
+ b.erase("branch.liftBot", "branch", "guides", [[1000, bBot(1000)], [505, bBot(505)], [10, bBot(10)]], { width: 34, ghost: 0.03 });
// 6. value masses
b.step("s6", "values", {
diff --git a/skills/anidoodle/engine/src/canvas-core/lessonOwlLayout.ts b/skills/anidoodle/engine/src/canvas-core/lessonOwlLayout.ts
index e0fc471..f901122 100644
--- a/skills/anidoodle/engine/src/canvas-core/lessonOwlLayout.ts
+++ b/skills/anidoodle/engine/src/canvas-core/lessonOwlLayout.ts
@@ -9,21 +9,38 @@
// - the last panel, the payoff, shows the whole owl at full strength with no veil.
// The film: a 1080 px wide art area with a deep caption band under it, captions ~3x the old size.
import { Gfx, PENCIL, type Ctx, type Env } from "./core";
-import { letter } from "./drafting";
+import { letter, width } from "./drafting";
import type { Film } from "./film";
import { all, before, only, paperGrain, progressAt, renderArt, schedule, type Score, type Timing, type View } from "./drawingScore";
import { lessonTiming, wrap } from "./lesson";
export type OwlLook = { ink: string; body: string; accent: string; band: string; rule: string };
-const LOOK: OwlLook = { ink: "#1d191a", body: "#2e292a", accent: "#2f5fae", band: "#ebe4d4", rule: "#8a817c" };
-const pen = (ctx: Ctx, env: Env) => new Gfx(ctx, env, 0, { ...PENCIL, wobble: 0.35, rough: 0.45 });
+export const LOOK: OwlLook = { ink: "#1d191a", body: "#2e292a", accent: "#2f5fae", band: "#ebe4d4", rule: "#8a817c" };
+export const pen = (ctx: Ctx, env: Env) => new Gfx(ctx, env, 0, { ...PENCIL, wobble: 0.35, rough: 0.45 });
-type Line = { t: string; cap: number; col: string; w: number; gap: number; x?: number };
+export type Line = { t: string; cap: number; col: string; w: number; gap: number; x?: number };
// write lines on, one after another; `p` is 0..1 over the whole block (a hand writes, nothing fades)
-const block = (g: Gfx, lines: Line[], x: number, y: number, p: number, seed: number) => {
+export const block = (g: Gfx, lines: Line[], x: number, y: number, p: number, seed: number) => {
const cost = lines.map((l) => l.t.length), tot = cost.reduce((a, b) => a + b, 0) || 1; let acc = 0, yy = y;
lines.forEach((l, i) => { const a = acc / tot, b = (acc + cost[i]) / tot, q = p >= 1 ? 1 : Math.max(0, Math.min(1, (p - a) / (b - a || 1))); acc += cost[i]; if (q > 0) letter(g, l.t, x + (l.x ?? 0), yy, { cap: l.cap, color: l.col, seed: seed + i * 7, w: l.w, progress: q, slant: 0.1, opacity: 1 }); yy += l.cap + l.gap; });
};
+// FIT, never clip. Every text block is wrapped against the drafting hand's own measured advance
+// widths, then the whole block is checked against the box it must live in; only if it still does
+// not fit (too many lines, or one word wider than the box) does the lettering shrink, 4 % at a
+// time, down to 55 %. The test that forced this: "FEATHERS FOLLOW THE FORM" at 52 px caps ran off
+// a 1080 px frame at "FOR" because titles were written as one unwrapped line.
+export type Spec = { text: string; cap: number; col: string; w: number; gap: number; maxW: number; x?: number };
+export const fitLines = (specs: Spec[], maxH: number): { lines: Line[]; scale: number; height: number } => {
+ let best = { lines: [] as Line[], scale: 0.55, height: Infinity };
+ for (let s = 1; s >= 0.549; s -= 0.04) {
+ const lines: Line[] = []; let ok = true;
+ for (const sp of specs) { const cap = sp.cap * s, room = sp.maxW - 8; for (const t of wrap(sp.text, cap, room)) { if (width(t, cap) > room) ok = false; lines.push({ t, cap, col: sp.col, w: sp.w * Math.max(0.8, s), gap: sp.gap * s, x: sp.x }); } }
+ const height = lines.reduce((a, l, i) => a + l.cap + (i < lines.length - 1 ? l.gap : 0), 0);
+ best = { lines, scale: s, height };
+ if (ok && height <= maxH) return best;
+ }
+ return best;
+};
const rule = (g: Gfx, x0: number, x1: number, y: number, seed: number, col: string) => g.pen([[x0, y], [(x0 + x1) / 2, y - 1.2], [x1, y + 0.6]], { w: 1.6, color: col, seed, opacity: 0.6, retrace: false, boil: 0, wobble: 0.3 });
// ---------------------------------------------------------------- the timelapse
@@ -31,7 +48,7 @@ export type OwlFilmOpts = { timing?: Partial<Timing>; outro?: string; subtitle?:
export const owlFilm = (build: () => Score, o: OwlFilmOpts = {}) => {
let S0: Score | null = null; const score = () => (S0 ??= build());
const S = score(), W = 1080, art = Math.round((W * S.H) / S.W), bandH = 360, H = art + bandH;
- const T = lessonTiming({ intro: 90, captionLead: 24, pause: 12, hold: 120, rate: 30, minStep: 120, maxStep: 330, ...o.timing });
+ const T = lessonTiming({ intro: 90, captionLead: 24, pause: 12, hold: 120, rate: 30, minStep: 75, maxStep: 330, ...o.timing });
const P0 = schedule(S, T), total = P0.total, last = P0.steps[P0.steps.length - 1];
const view = (env: Env): View => ({ x: 0, y: 0, w: Math.round(W * env.scale), h: Math.round(art * env.scale) });
const band = (ctx: Ctx, env: Env, frame: number, final: boolean) => {
@@ -44,11 +61,12 @@ export const owlFilm = (build: () => Score, o: OwlFilmOpts = {}) => {
return;
}
if (k < 0) { // the title card
- block(g, [{ t: S.title.toUpperCase(), cap: 62, col: LOOK.ink, w: 6.8, gap: 30 }, ...wrap(o.subtitle ?? S.medium, 30, maxW).map((t) => ({ t, cap: 30, col: LOOK.accent, w: 3.3, gap: 16 }))], x, art + 70, Math.min(1, frame / Math.max(1, T.intro - 20)), 700);
+ block(g, [{ t: S.title.toUpperCase(), cap: 62, col: LOOK.ink, w: 6.8, gap: 30 }, ...wrap(o.subtitle ?? S.medium, 30, maxW).map((t) => ({ t, cap: 30, col: LOOK.accent, w: 3.3, gap: 16 }))], x, art + 70, Math.min(1, frame / Math.max(1, T.intro - 1)), 700);
return;
}
- const st = S.steps[k], ps = P0.steps[k], p = Math.min(1, (frame - ps.start) / Math.max(24, (ps.markEnd - ps.start) * 0.4));
- block(g, [{ t: `STEP ${k + 1} OF ${S.steps.length}`, cap: 26, col: LOOK.accent, w: 3.2, gap: 22 }, { t: st.title.toUpperCase(), cap: 52, col: LOOK.ink, w: 6, gap: 26 }, ...wrap(st.caption, 31, maxW).map((t) => ({ t, cap: 31, col: LOOK.body, w: 3.5, gap: 17 }))], x, art + 50, p, 100 + k * 50);
+ const st = S.steps[k], ps = P0.steps[k], p = Math.min(1, (frame - ps.start) / Math.max(24, (ps.markEnd - ps.start) * 0.7)); // written on across most of the step, finished in time to be read
+ const fitted = fitLines([{ text: `STEP ${k + 1} OF ${S.steps.length}`, cap: 26, col: LOOK.accent, w: 3.2, gap: 22, maxW }, { text: st.title, cap: 52, col: LOOK.ink, w: 6, gap: 22, maxW }, { text: st.caption, cap: 31, col: LOOK.body, w: 3.5, gap: 16, maxW }], bandH - 50 - 24);
+ block(g, fitted.lines, x, art + 50, p, 100 + k * 50);
};
const draw = (ctx: Ctx, frame: number, env: Env, final: boolean) => {
ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = S.paper; ctx.fillRect(0, 0, W * env.scale, H * env.scale); ctx.restore();
diff --git a/skills/anidoodle/engine/src/canvas-core/lessonOwlScore.ts b/skills/anidoodle/engine/src/canvas-core/lessonOwlScore.ts
new file mode 100644
index 0000000..b36485e
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/lessonOwlScore.ts
@@ -0,0 +1,117 @@
+// SOUND FOR THE OWL LESSON (social cut): a composed score plus pencil foley, mixed and mastered
+// in code. No samples. Pure in (plan, sampleRate).
+//
+// THE SCORE. Style minimalist (interlocking ostinato + a hook), mood curious, G major, 4/4 at
+// 100 bpm, so one beat is exactly 18 frames at 30 fps and every step of the drawing starts on a
+// beat. All parts are on the grid (no rubato, no ritard): the picture is cut to this clock, so the
+// clock may not breathe. Form, written by hand:
+// hook card 1 bar marimba ostinato alone (the question before the drawing starts)
+// drawing 8-bar cycle, restated: G | Em | C | D (question, ends on A, off the tonic) |
+// G | Em | Am D | G (answer, lands on the tonic). Odd cycles the plucked "pizzicato"
+// (Karplus-Strong guitar, damped) carries the hook; even cycles the marimba does.
+// The bar before the reveal is a D7 run up to the leading tone.
+// steps one celesta ping on each step's first beat, climbing the G major scale (G5 .. A6):
+// you hear the lesson progress
+// reveal "da-DAH": [D5 F#5 A5] half a beat early, then a rolled G major chord on marimba and
+// pluck with a bell on top, on the beat the finished owl is shown
+// end card one bar of rising G arpeggio, then a soft G chord to ring out
+// FOLEY. Every mark in the schedule is a pencil stroke: band-passed noise (3.4 kHz graphite
+// scratch, a grain modulation for the paper's tooth) gated by that mark's own start and end, a
+// 6 ms attack and a 30 ms lift, panned by where the mark sits across the page. Construction lines
+// are softer, hatching is scratchier, the kneaded eraser is a low 700 Hz rub. Mixed 15 dB under
+// the music (loudness to loudness), so it is felt more than heard.
+// MASTER: one static gain to -16 LUFS integrated; if the true peak is over -1 dBTP the gain comes
+// down (gentle rule: loudness gives way, never a compressor).
+import { rng } from "./core";
+import { line, renderPiece, loudness, truePeak, type Note, type Part, type Piece, type Role } from "./music";
+import { Biquad, db, gauss, onePoleCoef, pan } from "./music/dsp";
+
+export type FoleyEvent = { t0: number; t1: number; kind: "guide" | "line" | "fill" | "correction" | "erase"; x: number };
+export type OwlSoundPlan = { bpm: number; seconds: number; stepBeats: number[]; revealBeat: number; endBeat: number; foley: FoleyEvent[] };
+
+const bar = (t: number, src: string, role: Role, v: number, roll?: number) => line(t, src, { role, v, bpb: 4, roll });
+const eighths = (names: string) => names.split(" ").map((n) => `${n}:.5`).join(" ");
+type Bar = { ost: string; mel: string; bass: string };
+const G: Bar = { ost: "G3 D4 G4 B4 D4 G4 B4 D4", mel: "r:.5 D5:.5 G5:.5 A5:.5 B5:1 G5:1", bass: "G2:2 D3:2" };
+const CYCLE: Bar[] = [
+ G,
+ { ost: "E3 B3 E4 G4 B3 E4 G4 B3", mel: "E5:.5 G5:.5 B5:1 A5:.5 G5:.5 E5:1", bass: "E2:2 B2:2" },
+ { ost: "C3 G3 C4 E4 G3 C4 E4 G3", mel: "C5:.5 E5:.5 G5:.5 E5:.5 A5:1 G5:1", bass: "C3:2 G2:2" },
+ { ost: "D3 A3 D4 F#4 A3 D4 F#4 A3", mel: "F#5:.5 E5:.5 D5:1 A4:1 r:1", bass: "D3:2 A2:2" },
+ { ...G, mel: "r:.5 D5:.5 G5:.5 A5:.5 B5:1 D6:1" },
+ { ost: "E3 B3 E4 G4 B3 E4 G4 B3", mel: "C6:.5 B5:.5 G5:1 E5:.5 G5:.5 B5:1", bass: "E2:2 B2:2" },
+ { ost: "A2 E3 A3 C4 D3 A3 D4 F#4", mel: "A5:.5 C6:.5 B5:.5 A5:.5 F#5:1 A5:1", bass: "A2:2 D3:2" },
+ { ...G, mel: "G5:2 r:2" },
+];
+const D7: Bar = { ost: "D3 A3 C4 F#4 A3 C4 F#4 A4", mel: "F#5:.5 G5:.5 A5:.5 B5:.5 C6:.5 B5:.5 A5:.5 F#5:.5", bass: "D3:2 A2:2" };
+const PINGS = ["G5", "A5", "B5", "C6", "D6", "E6", "F#6", "G6", "A6"];
+
+export const owlPiece = (sp: OwlSoundPlan): Piece => {
+ const R = sp.revealBeat, cut = R - 0.5, ost: Note[] = [], bass: Note[] = [], pl: Note[] = [], mar: Note[] = [], ping: Note[] = [], bell: Note[] = [];
+ const keep = (ns: Note[]) => ns.filter((n) => n.t < cut - 1e-6);
+ // hook card: the ostinato alone
+ ost.push(...bar(0, eighths(G.ost), "accomp", 0.5)); bass.push(...bar(0, "G2:4", "bass", 0.55));
+ // the drawing: the cycle restated, alternating the hook's instrument; D7 into the reveal
+ const lastBar = Math.floor((cut - 1e-6) / 4) * 4;
+ for (let b = 4, k = 0; b < cut; b += 4, k++) {
+ const B = b === lastBar ? D7 : CYCLE[k % 8], cyc = Math.floor(k / 8);
+ ost.push(...keep(bar(b, eighths(B.ost), "accomp", 0.55)));
+ bass.push(...keep(bar(b, B.bass, "bass", 0.62)));
+ (cyc % 2 === 0 ? pl : mar).push(...keep(bar(b, B.mel, "melody", 0.8)));
+ }
+ sp.stepBeats.forEach((b, i) => ping.push(...bar(b, `${PINGS[Math.min(i, PINGS.length - 1)]}:1`, "color", 0.62)));
+ // da-DAH
+ pl.push(...bar(cut, "[D5 F#5 A5]:.5", "melody", 0.75));
+ // peaks are a composing problem: the chord is rolled upward (a strum, not a slab), the bass lands an
+ // eighth late and the bell a sixteenth late, so no two loud attacks share a sample
+ mar.push(...bar(R, "[G3 D4 B4]:4", "melody", 0.64, 0.03)); pl.push(...bar(R, "[G4 D5 G5]:2 r:2", "melody", 0.78, 0.036)); // no doubled notes between the two
+ bass.push(...bar(R, "r:.5 G2:3.5", "bass", 0.72)); bell.push(...bar(R, "r:.25 G6:3.75", "color", 0.66));
+ // end card: a rising arpeggio, then the chord rings out
+ const E = sp.endBeat;
+ ost.push(...bar(E, eighths("G3 B3 D4 G4 B4 D5 G5 B5"), "accomp", 0.5));
+ mar.push(...bar(E + 4, "[G3 D4 G4 B4]:3", "melody", 0.55)); pl.push(...bar(E + 4, "G5:3", "melody", 0.5)); bass.push(...bar(E + 4, "G2:3", "bass", 0.5));
+ const grid = { grid: true };
+ const parts: Part[] = [
+ { id: "ostinato", inst: "marimba", role: "accomp", notes: ost, gainDb: -6, opts: grid },
+ { id: "bass", inst: "marimba", role: "bass", notes: bass, gainDb: -3, opts: grid },
+ { id: "pizz", inst: "guitar", role: "melody", notes: pl, gainDb: 1, opts: grid, pan: -0.15 },
+ { id: "hook", inst: "marimba", role: "melody", notes: mar, gainDb: -1, opts: grid, pan: 0.15 },
+ { id: "steps", inst: "celesta", role: "color", notes: ping, gainDb: -5, opts: grid, pan: 0.25 },
+ { id: "tada", inst: "bell", role: "color", notes: bell, gainDb: -7, opts: grid },
+ ];
+ const bars = Math.ceil((E + 7) / 4);
+ return {
+ title: "How to draw an owl (social cut)", seed: 1109, tail: 1.5, harmony: [],
+ plan: { style: "minimalist", tempo: sp.bpm, meter: "4/4", rubato: 0, ritard: 1, sections: [{ id: "all", bars, mood: "curious", key: "G", mode: "major", melody: ["ostinato", "hook"], dyn: [0.62, 0.7], ending: "button" }] },
+ parts,
+ };
+};
+
+// ---------------------------------------------------------------- foley
+const foley = (sp: OwlSoundPlan, sr: number): [Float32Array, Float32Array] => {
+ const n = Math.round(sp.seconds * sr), env = new Float32Array(n), envE = new Float32Array(n), px = new Float32Array(n).fill(0.5);
+ const att = Math.round(0.006 * sr), rel = 0.03 * sr, AMP = { guide: 0.5, line: 0.85, fill: 1, correction: 0.85, erase: 0 } as const;
+ for (const ev of sp.foley) {
+ const i0 = Math.round(ev.t0 * sr), i1 = Math.max(i0 + att, Math.round(ev.t1 * sr)), a = ev.kind === "erase" ? 0.8 : AMP[ev.kind], tgt = ev.kind === "erase" ? envE : env;
+ for (let i = Math.max(0, i0); i < Math.min(n, i1 + Math.round(rel * 5)); i++) { const g = i < i0 + att ? (i - i0) / att : i <= i1 ? 1 : Math.exp(-(i - i1) / rel); const v = a * g; if (v > tgt[i]) { tgt[i] = v; px[i] = ev.x; } }
+ }
+ const r = rng(4242), L = new Float32Array(n), Rr = new Float32Array(n);
+ const bp = Biquad.make(sr, "bp", 3400, 0.7), hp = Biquad.make(sr, "hp", 1200, 0.7), rub = Biquad.make(sr, "bp", 700, 0.6), gc = onePoleCoef(sr, 45);
+ let grain = 0;
+ for (let i = 0; i < n; i++) {
+ const w = gauss(r), w2 = gauss(r); grain += gc * (Math.abs(w2) - grain); // the tooth: a slow random flutter under the scratch
+ const s = hp.tick(bp.tick(w)) * env[i] * (0.35 + 1.1 * grain) + rub.tick(w2) * envE[i] * 0.6;
+ const [gl, gr] = pan((px[i] - 0.5) * 0.8); L[i] = s * gl; Rr[i] = s * gr;
+ }
+ return [L, Rr];
+};
+
+export const owlSocialAudio = (sp: OwlSoundPlan) => (sr: number): [Float32Array, Float32Array] => {
+ const m = renderPiece(owlPiece(sp), sr, { seconds: sp.seconds, tempo: sp.bpm, master: "none" }), [fL, fR] = foley(sp, sr), n = m.L.length;
+ const lm = loudness([m.L, m.R], sr).integrated, lf = loudness([fL, fR], sr).integrated, fg = db(lm - 15 - lf);
+ const L = new Float32Array(n), R = new Float32Array(n);
+ for (let i = 0; i < n; i++) { L[i] = m.L[i] + fL[i] * fg; R[i] = m.R[i] + fR[i] * fg; }
+ let g = db(-16 - loudness([L, R], sr).integrated); for (let i = 0; i < n; i++) { L[i] *= g; R[i] *= g; }
+ const tp = truePeak([L, R]).dbtp; if (tp > -1) { g = db(-1.05 - tp); for (let i = 0; i < n; i++) { L[i] *= g; R[i] *= g; } }
+ return [L, R];
+};
diff --git a/skills/anidoodle/engine/src/canvas-core/lessonOwlSocial.ts b/skills/anidoodle/engine/src/canvas-core/lessonOwlSocial.ts
new file mode 100644
index 0000000..5b3a00c
--- /dev/null
+++ b/skills/anidoodle/engine/src/canvas-core/lessonOwlSocial.ts
@@ -0,0 +1,83 @@
+// THE OWL LESSON, SOCIAL CUT: vertical 1080 x 1920 (9:16), scored, ~49 s. Same drawing score as
+// the README lesson (lessonOwl.ts), re-timed and re-laid-out for a phone:
+// 0.0 s HOOK card slot, 4 beats (2.4 s): a plain placeholder; a build can pass its own hook card
+// 2.4 s the drawing: 9 steps in ~40 s. Each step starts on a beat (100 bpm = 18 frames), is
+// 2.4 to 4.8 s long, and long hatching passes are sped up (rate 70 against the README's 30)
+// so no step drags; captions are written on in the first 60 % of the step, then read
+// reveal on the beat after the last mark: the "da-DAH" and "That's the rest of the owl."
+// end END card slot, 7 beats (4.2 s): a plain placeholder; a build can pass its own end card
+// LAYOUT, for a phone and the apps' overlays: a small title at the top, the drawing large in the
+// middle (1130 px tall), the caption band under it with the step number big, and the bottom
+// ~320 px left as quiet paper, where Reels/TikTok/Shorts draw their own captions and buttons.
+// Every text block goes through fitLines (wrap to measured width, shrink only as a last resort).
+// Frames are drawn cold (no replay cache): exact by construction, see lessonOwlLayout.ts.
+import { type Ctx, type Env } from "./core";
+import { letter } from "./drafting";
+import type { Film } from "./film";
+import { paperGrain, progressAt, renderArt, schedule, type Timing, type View } from "./drawingScore";
+import { owlScore } from "./lessonOwl";
+import { LOOK, block, fitLines, pen } from "./lessonOwlLayout";
+import { owlSocialAudio, type FoleyEvent } from "./lessonOwlScore";
+
+const W = 1080, H = 1920, FPS = 30, BPM = 100, BEAT = 18, AFTER = 4 * BEAT;
+const S = owlScore();
+const T: Timing = { intro: 0, captionLead: 9, pause: 6, hold: 0, rate: 70, minStep: 72, maxStep: 144, grid: BEAT };
+const P = schedule(S, T), LAST = P.steps[P.steps.length - 1].markEnd, REVEAL = Math.ceil(LAST / BEAT) * BEAT, DRAW = REVEAL + AFTER;
+const CROP = [96, 50, 904, 1134] as const, ART_TOP = 170, ART_H = 1130, BAND = 1318, BAND_BOTTOM = 1600;
+
+const artView = (env: Env): View => {
+ const sc = Math.min(W / (CROP[2] - CROP[0]), ART_H / (CROP[3] - CROP[1])), ox = (W - (CROP[2] - CROP[0]) * sc) / 2 - CROP[0] * sc, oy = ART_TOP - CROP[1] * sc, k = env.scale;
+ return { x: Math.round(ox * k), y: Math.round(oy * k), w: Math.round(S.W * sc * k), h: Math.round(S.H * sc * k) };
+};
+const paper = (ctx: Ctx, env: Env) => { ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.fillStyle = S.paper; ctx.fillRect(0, 0, W * env.scale, H * env.scale); ctx.restore(); };
+
+// a slot another worker fills: plain cream with a label saying so
+const placeholder = (label: string, note: string) => (ctx: Ctx, _f: number, env: Env) => {
+ paper(ctx, env); const g = pen(ctx, env);
+ letter(g, label, W / 2, 860, { cap: 64, color: LOOK.rule, seed: 5, w: 6, align: "center", slant: 0.1, opacity: 1 });
+ letter(g, note, W / 2, 970, { cap: 28, color: LOOK.rule, seed: 6, w: 3, align: "center", slant: 0.1, opacity: 1 });
+ paperGrain(ctx, env, 0.05);
+};
+
+const drawing = (ctx: Ctx, f: number, env: Env) => {
+ paper(ctx, env);
+ renderArt(ctx, env, S, progressAt(P, f), artView(env));
+ const g = pen(ctx, env);
+ block(g, [{ t: S.title.toUpperCase(), cap: 46, col: LOOK.ink, w: 5.2, gap: 0 }], 56, 84, 1, 3);
+ g.pen([[44, BAND - 22], [W / 2, BAND - 23.5], [W - 44, BAND - 21]], { w: 1.8, color: LOOK.rule, seed: 7, opacity: 0.6, retrace: false, boil: 0, wobble: 0.3 });
+ if (f >= REVEAL) { // the reveal
+ const fit = fitLines([{ text: "That's the rest of the owl.", cap: 84, col: LOOK.ink, w: 9, gap: 26, maxW: W - 112 }], BAND_BOTTOM - BAND - 20);
+ block(g, fit.lines, 56, BAND + 10, Math.min(1, (f - REVEAL) / 40), 990);
+ } else {
+ let k = 0; for (let i = 0; i < P.steps.length; i++) if (f >= P.steps[i].start) k = i;
+ const st = S.steps[k], ps = P.steps[k], p = Math.min(1, (f - ps.start) / Math.max(24, (ps.markEnd - ps.start) * 0.6));
+ block(g, [{ t: `${k + 1}`, cap: 150, col: LOOK.accent, w: 14, gap: 0 }], 50, BAND, Math.min(1, (f - ps.start) / 8), 500 + k);
+ const title = fitLines([{ text: st.title, cap: 64, col: LOOK.ink, w: 7, gap: 18, maxW: W - 200 - 50 }], 150);
+ block(g, title.lines, 200, BAND + (title.lines.length === 1 ? 44 : 4), p, 520 + k * 7);
+ const cap = fitLines([{ text: st.caption, cap: 38, col: LOOK.body, w: 4.2, gap: 14, maxW: W - 112 }], BAND_BOTTOM - (BAND + 172));
+ block(g, cap.lines, 56, BAND + 172, p, 560 + k * 7);
+ }
+ paperGrain(ctx, env, 0.05);
+};
+
+// The cut is a factory so a build can drop its own hook and end cards into the slots
+// (and give them more beats); the public film keeps the plain placeholders.
+type Slot = (ctx: Ctx, f: number, env: Env) => void;
+export const OWL_SOCIAL = { W, H, FPS, BPM, BEAT };
+export const owlSocial = (o: { hookBeats?: number; endBeats?: number; hook?: Slot; end?: Slot; title?: string } = {}): Film => {
+ const HOOK = (o.hookBeats ?? 4) * BEAT, END = (o.endBeats ?? 7) * BEAT, TOTAL = HOOK + DRAW + END;
+ // declared rests: the card slots, the pencil's rest between steps, the held finished owl
+ const holds: [number, number][] = [[0, HOOK], ...P.steps.map((s) => [HOOK + Math.ceil(s.markEnd), HOOK + s.end] as [number, number]).filter(([a, b]) => b > a), [HOOK + Math.ceil(LAST), HOOK + REVEAL], [HOOK + REVEAL + 40, HOOK + DRAW], [HOOK + DRAW, TOTAL]].filter(([a, b]) => b > a) as [number, number][];
+ const foley: FoleyEvent[] = S.marks.map((m, i) => ({ t0: (HOOK + P.s[i]) / FPS, t1: (HOOK + P.e[i]) / FPS, kind: m.kind, x: Math.max(0, Math.min(1, ((m.box[0] + m.box[2]) / 2) / S.W)) }));
+ return {
+ meta: { title: o.title ?? "How to draw an owl (social 9x16)", W, H, fps: FPS, bpm: BPM, durationFrames: TOTAL, raster: "cpu", kind: "drawing", holds },
+ assets: { images: {} },
+ shots: [
+ { id: "hook", start: 0, end: HOOK, draw: o.hook ?? placeholder("HOOK CARD", "YOUR CARD HERE") },
+ { id: "drawing", start: HOOK, end: HOOK + DRAW, draw: drawing },
+ { id: "end", start: HOOK + DRAW, end: TOTAL, draw: o.end ?? placeholder("END CARD", "YOUR CARD HERE") },
+ ],
+ audio: owlSocialAudio({ bpm: BPM, seconds: TOTAL / FPS, stepBeats: P.steps.map((s) => (HOOK + s.start) / BEAT), revealBeat: (HOOK + REVEAL) / BEAT, endBeat: (HOOK + DRAW) / BEAT, foley }),
+ };
+};
+export const lessonOwlSocial: Film = owlSocial();
diff --git a/skills/anidoodle/engine/src/hosts/page-lessonOwlSocial.ts b/skills/anidoodle/engine/src/hosts/page-lessonOwlSocial.ts
new file mode 100644
index 0000000..3fcd9aa
--- /dev/null
+++ b/skills/anidoodle/engine/src/hosts/page-lessonOwlSocial.ts
@@ -0,0 +1,4 @@
+import { lessonOwlSocial } from "../canvas-core/lessonOwlSocial";
+import { mountFilm } from "./page";
+
+mountFilm(lessonOwlSocial);