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.

the installed plugin leaves out the showcase films, and stands on its own: a guard refuses repository-only films and unresolved imports; 0.6.4

Alex Greenshpunf649db6eb823
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 3be719c..8a9b2c6 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -13,7 +13,7 @@
"name": "anidoodle",
"source": "./",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
- "version": "0.6.3",
+ "version": "0.6.4",
"author": {
"name": "Alex Greenshpun",
"url": "https://linkedin.com/in/alexgreensh"
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json
index 77ef15a..a13ad44 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -2,7 +2,7 @@
"name": "anidoodle",
"displayName": "anidoodle",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
- "version": "0.6.3",
+ "version": "0.6.4",
"icon": "./assets/icon.png",
"author": {
"name": "Alex Greenshpun",
diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json
index bd2cbb0..712800f 100644
--- a/.codex-plugin/plugin.json
+++ b/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "anidoodle",
- "version": "0.6.3",
+ "version": "0.6.4",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
"skills": "./skills/",
"interface": {
diff --git a/.grok-plugin/marketplace.json b/.grok-plugin/marketplace.json
index a20799d..d00348a 100644
--- a/.grok-plugin/marketplace.json
+++ b/.grok-plugin/marketplace.json
@@ -10,7 +10,7 @@
"name": "anidoodle",
"source": "./plugins/anidoodle",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
- "version": "0.6.3",
+ "version": "0.6.4",
"author": {
"name": "Alex Greenshpun",
"url": "https://linkedin.com/in/alexgreensh"
diff --git a/plugins/anidoodle/.claude-plugin/plugin.json b/plugins/anidoodle/.claude-plugin/plugin.json
index 77ef15a..a13ad44 100644
--- a/plugins/anidoodle/.claude-plugin/plugin.json
+++ b/plugins/anidoodle/.claude-plugin/plugin.json
@@ -2,7 +2,7 @@
"name": "anidoodle",
"displayName": "anidoodle",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
- "version": "0.6.3",
+ "version": "0.6.4",
"icon": "./assets/icon.png",
"author": {
"name": "Alex Greenshpun",
diff --git a/plugins/anidoodle/.codex-plugin/plugin.json b/plugins/anidoodle/.codex-plugin/plugin.json
index bd2cbb0..712800f 100644
--- a/plugins/anidoodle/.codex-plugin/plugin.json
+++ b/plugins/anidoodle/.codex-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "anidoodle",
- "version": "0.6.3",
+ "version": "0.6.4",
"description": "Code-drawn stills, drawing timelapses, films, explainers and interactive web animations in 31 styles, with scores composed in code.",
"skills": "./skills/",
"interface": {
diff --git a/plugins/anidoodle/skills/anidoodle/engine/package.json b/plugins/anidoodle/skills/anidoodle/engine/package.json
index 08d287f..a7ad999 100644
--- a/plugins/anidoodle/skills/anidoodle/engine/package.json
+++ b/plugins/anidoodle/skills/anidoodle/engine/package.json
@@ -1,6 +1,6 @@
{
"name": "anidoodle-engine",
- "version": "0.6.3",
+ "version": "0.6.4",
"private": true,
"type": "module",
"description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts
deleted file mode 100644
index 0db1098..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahBody.ts
+++ /dev/null
@@ -1,177 +0,0 @@
-// THE CHEETAH, SIDE VIEW. One character module: a pose goes in, the animal is drawn. Shots pose it,
-// they never redraw it. It is the same animal as the face in cheetahDusk and is made the same way:
-// tapered tufts over a mass, solid spots, the tear line as the one big black shape.
-// Reference opened (Wikimedia Commons), for structure only:
-// - "Sarah Sprints" (CC BY 2.0): the build side-on, deep chest, tucked waist, spots following the form
-// - "Acinonyxrunningrespiration.png" (CC BY-SA 3.0): the two flight phases, where the spine folds and opens
-// - "Speed 2 - Running Cheetah" bronze (CC BY-SA 4.0): the extended phase, how the hind legs trail
-// - de Blainville's skeleton plate (public domain): scapula, the long metatarsus, the hock high off the foot
-// The anatomy it commits to: a small domed head held level; a long neck in line with the back; the
-// scapula riding over the ribs; chest twice as deep as the waist; hind legs longer than fore, with a
-// knee, a hock and a long metatarsus; a tail two thirds of the body, ringed at the end, white-tipped;
-// claws that show; dark pads on a trailing hind foot.
-// Everything is authored FACING RIGHT, y down, in the animal's own units (about 920 nose-paw to tail tip).
-import { rng, type Ctx, type P } from "./core";
-import { mix } from "./gallery";
-
-const NIGHT = "#0d1a22", OCHRE = "#e3a23a", GOLD = "#efb84e", CREAM = "#f2e4c5", PALE = "#fff5de", DARK = "#0a1216";
-const ROWS = ["#a9601f", "#cf8a2c", OCHRE, GOLD, "#f2c263", "#f4cd7e", CREAM]; // back to belly
-const clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v));
-const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
-
-export type Pose = {
- spine: P[]; // 10 stations: rump, hip, loin, waist, rear ribs, chest, shoulder, neck base, neck, head join
- tail: P[]; // 6, from its root to its tip
- foreN: P[]; foreF: P[]; // scapula, shoulder, elbow, wrist, toes (near side, far side)
- hindN: P[]; hindF: P[]; // hip, knee, hock, ball, toes
- head: number; // the head's own angle, radians: 0 is level, positive is nose down
-};
-
-// the build: how thick the animal is at each station. A pose moves points; it never changes these.
-const SPINE_UP = [14, 38, 40, 44, 54, 66, 66, 50, 38, 34], SPINE_DN = [22, 52, 44, 42, 68, 90, 76, 48, 36, 32];
-const TAIL_W = [15, 13, 12, 12, 13, 11], FORE_W = [20, 30, 19, 12, 8], HIND_W = [44, 30, 13, 12, 8];
-
-
-// a tuft: a tapered leaf from radius r0 to r1 along angle a, darker at its root (the mark cheetahDusk is made of)
-const tuft = (c: Ctx, o: P, a: number, r0: number, r1: number, w: number, col: string, vein = 0.22, root = 0.6) => {
- if (r1 - r0 < 1.5 || w < 0.6) return;
- const ca = Math.cos(a), sa = Math.sin(a), b: P = [o[0] + ca * r0, o[1] + sa * r0], t: P = [o[0] + ca * r1, o[1] + sa * r1], m = r0 + (r1 - r0) * 0.42, mx = o[0] + ca * m, my = o[1] + sa * m;
- const g = c.createLinearGradient(b[0], b[1], t[0], t[1]); g.addColorStop(0, mix(col, DARK, root)); g.addColorStop(0.45, col); g.addColorStop(1, mix(col, "#ffffff", 0.16));
- c.fillStyle = g; c.beginPath(); c.moveTo(b[0], b[1]); c.quadraticCurveTo(mx - sa * w, my + ca * w, t[0], t[1]); c.quadraticCurveTo(mx + sa * w, my - ca * w, b[0], b[1]); c.fill();
- if (vein > 0) { c.strokeStyle = mix(col, DARK, 0.7); c.globalAlpha = vein; c.lineWidth = 1; c.beginPath(); c.moveTo(b[0], b[1]); c.lineTo(o[0] + ca * (r1 - 3), o[1] + sa * (r1 - 3)); c.stroke(); c.globalAlpha = 1; }
-};
-
-// a ribbon: a smooth curve through the points with its own thickness on each side. Side a is on the
-// left hand of travel (the top, for a chain running to the right); side b is the other.
-type Rib = { c: P[]; a: P[]; b: P[]; ang: number[]; len: number };
-const cr = (p0: number, p1: number, p2: number, p3: number, t: number) => 0.5 * (2 * p1 + (p2 - p0) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t + (3 * p1 - p0 - 3 * p2 + p3) * t * t * t);
-const ribbon = (pts: P[], wa: number[], wb: number[] = wa, per = 12): Rib => {
- const g = (i: number) => pts[clamp(i, 0, pts.length - 1)], cs: P[] = [], ua: number[] = [], ub: number[] = [];
- for (let i = 0; i < pts.length - 1; i++) for (let k = 0; k < per + (i === pts.length - 2 ? 1 : 0); k++) {
- const t = k / per, e = t * t * (3 - 2 * t);
- cs.push([cr(g(i - 1)[0], g(i)[0], g(i + 1)[0], g(i + 2)[0], t), cr(g(i - 1)[1], g(i)[1], g(i + 1)[1], g(i + 2)[1], t)]); ua.push(lerp(wa[i], wa[i + 1], e)); ub.push(lerp(wb[i], wb[i + 1], e));
- }
- const a: P[] = [], b: P[] = [], ang: number[] = []; let len = 0;
- cs.forEach((p, i) => { const q0 = cs[Math.max(0, i - 1)], q1 = cs[Math.min(cs.length - 1, i + 1)], th = Math.atan2(q1[1] - q0[1], q1[0] - q0[0]), nx = Math.sin(th), ny = -Math.cos(th); ang.push(th); a.push([p[0] + nx * ua[i], p[1] + ny * ua[i]]); b.push([p[0] - nx * ub[i], p[1] - ny * ub[i]]); if (i) len += Math.hypot(p[0] - cs[i - 1][0], p[1] - cs[i - 1][1]); });
- return { c: cs, a, b, ang, len };
-};
-// a place on the ribbon: s along it (0-1), v across it (-1 is side a, +1 is side b)
-const on = (r: Rib, s: number, v: number) => {
- const x = clamp(s) * (r.c.length - 1), i = Math.min(r.c.length - 2, Math.floor(x)), f = x - i, e = v < 0 ? r.a : r.b, k = Math.abs(v), L = (q: P[], d: 0 | 1) => lerp(q[i][d], q[i + 1][d], f);
- return { p: [lerp(L(r.c, 0), L(e, 0), k), lerp(L(r.c, 1), L(e, 1), k)] as P, ang: r.ang[i], w: Math.hypot(L(r.a, 0) - L(r.b, 0), L(r.a, 1) - L(r.b, 1)) };
-};
-const fillRib = (c: Ctx, r: Rib, col: string) => { c.fillStyle = col; c.beginPath(); r.a.forEach((p, i) => (i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1]))); [...r.b].reverse().forEach((p) => c.lineTo(p[0], p[1])); c.closePath(); c.fill(); };
-const blob = (c: Ctx, pts: P[], per = 8) => { const n = pts.length, g = (i: number) => pts[((i % n) + n) % n]; c.beginPath(); for (let i = 0; i < n; i++) for (let k = 0; k < per; k++) { const t = k / per, x = cr(g(i - 1)[0], g(i)[0], g(i + 1)[0], g(i + 2)[0], t), y = cr(g(i - 1)[1], g(i)[1], g(i + 1)[1], g(i + 2)[1], t); if (i + k) c.lineTo(x, y); else c.moveTo(x, y); } c.closePath(); };
-const spot = (c: Ctx, p: P, rx: number, ry: number, a: number, col: string) => { c.fillStyle = col; c.beginPath(); c.ellipse(p[0], p[1], rx, ry, a, 0, Math.PI * 2); c.fill(); };
-
-// a foot: four toes, each its own mark, each with its claw (a cheetah's never fully sheathe). A
-// trailing hind foot shows its pads.
-const paw = (c: Ctx, r: Rib, shade: number, hind: boolean) => {
- const sh = (col: string) => (shade ? mix(col, NIGHT, shade) : col), { p, ang } = on(r, 0.88, 0), pads = hind && Math.cos(ang) < -0.35; // a hind foot trailing behind shows its sole
- for (const k of [-1.5, 1.5, -0.5, 0.5]) {
- const a = ang + k * 0.15, L = 34 - Math.abs(k) * 3;
- tuft(c, p, a, 0, L, 6.6, sh(Math.abs(k) > 1 ? CREAM : PALE), 0.3, 0.35);
- tuft(c, [p[0] + Math.cos(a) * (L - 3), p[1] + Math.sin(a) * (L - 3)], a + 0.5, 0, 8, 1.9, sh("#2a1a12"), 0);
- }
- if (pads) { const q = on(r, 0.93, 0.8); spot(c, q.p, 5, 2.3, ang, sh("#3a2418")); const t = on(r, 1, 0.7); spot(c, [t.p[0] + Math.cos(ang) * 6, t.p[1] + Math.sin(ang) * 6], 2.4, 1.7, ang, sh("#3a2418")); }
-};
-
-// a leg: its mass, the fur lying toward the foot (laid from the foot upward, so each tuft overlaps
-// the one below it), the spots thinning out toward the wrist, the fold where it meets the body.
-const limb = (c: Ctx, joints: P[], widths: number[], seed: number, shade: number, hind: boolean) => {
- // the leg starts inside the body: the haunch and the point of the shoulder taper back into it, never a cut end
- const d = Math.hypot(joints[1][0] - joints[0][0], joints[1][1] - joints[0][1]) || 1, ext = widths[0] * 0.85, pts: P[] = [[joints[0][0] - ((joints[1][0] - joints[0][0]) / d) * ext, joints[0][1] - ((joints[1][1] - joints[0][1]) / d) * ext], ...joints], w = [widths[0] * 0.45, ...widths];
- const r = ribbon(pts, w, w, 10), L = Math.round(ext + (hind ? 320 : 315)), q = rng(seed), sh = (col: string) => (shade ? mix(col, NIGHT, shade) : col);
- fillRib(c, r, sh("#c2832a"));
- for (let i = Math.floor((L * 0.88) / 7); i >= 0; i--) {
- const s = (i * 7) / L, w0 = on(r, s, 0).w, rows = Math.max(2, Math.round(w0 / 11));
- for (let j = 0; j < rows; j++) {
- const v = lerp(-0.78, 0.78, rows === 1 ? 0.5 : j / (rows - 1)) + (q() - 0.5) * 0.3, at = on(r, s + (q() - 0.5) * (6 / L), v), under = hind ? v < -0.35 : v > 0.35, pale = clamp(s * 1.5 - 0.5) * 0.55;
- tuft(c, at.p, at.ang + (q() - 0.5) * 0.22, 0, clamp(w0 * 0.8, 16, 34) * (0.75 + q() * 0.5), clamp(w0 * 0.2, 2.6, 7), sh(mix(under ? "#f4cd7e" : q() < 0.5 ? GOLD : OCHRE, CREAM, pale)), 0.08, 0.26);
- }
- }
- for (let i = 1; i * 15 < L * 0.8; i++) {
- const s = (i * 15) / L, w0 = on(r, s, 0).w, n = Math.max(1, Math.round(w0 / 19));
- for (let j = 0; j < n; j++) { const v = (n === 1 ? 0 : lerp(-0.62, 0.62, j / (n - 1))) + (q() - 0.5) * 0.3, at = on(r, s + (q() - 0.5) * 0.02 + (j % 2) * (7 / L), v), z = clamp(w0 * 0.075, 1.7, 6.2) * (0.8 + q() * 0.4); spot(c, at.p, z * 1.15, z * 0.85 * Math.sqrt(1 - v * v * 0.6), at.ang, sh(DARK)); }
- }
- // the fold: the stifle under the thigh, the back of the shoulder. Thinner than an outline, and it fades.
- const e = hind ? r.a : r.b, m = Math.floor(e.length * 0.3); c.strokeStyle = sh(DARK); c.lineWidth = 2.2; c.lineCap = "round";
- for (let i = 1; i < m; i++) { c.globalAlpha = 0.34 * (1 - i / m); c.beginPath(); c.moveTo(e[i - 1][0], e[i - 1][1]); c.lineTo(e[i][0], e[i][1]); c.stroke(); }
- c.globalAlpha = 1;
- paw(c, r, shade, hind);
-};
-
-const tail = (c: Ctx, pts: P[]) => {
- const r = ribbon(pts, TAIL_W, TAIL_W, 10), L = 299, q = rng(23);
- fillRib(c, r, "#c2832a");
- for (let i = 0; i * 11 < L; i++) { const s = (i * 11) / L; for (const v of [0.6, -0.6, 0]) { const at = on(r, s, v); tuft(c, at.p, at.ang + (q() - 0.5) * 0.25 - v * 0.12, 0, 26 + q() * 8, 6.5, v > 0.3 ? "#f4cd7e" : v < -0.3 ? "#cf8a2c" : OCHRE, 0.18); } }
- // spots that close up into rings toward the end, then the white tip
- for (let i = 1; i * 17 < L * 0.62; i++) for (const v of [-0.5, 0.25]) { const at = on(r, (i * 17) / L + (v > 0 ? 8 / L : 0), v + (q() - 0.5) * 0.2); spot(c, at.p, 5, 3.8, at.ang, DARK); }
- for (const [s, wd] of [[0.68, 9], [0.78, 11], [0.88, 12]] as const) { const k = ribbon([on(r, s - 0.006, -1.05).p, on(r, s, 0).p, on(r, s + 0.006, 1.05).p], [wd / 2, wd / 2 + 1.5, wd / 2], undefined, 6); fillRib(c, k, DARK); }
- const end = on(r, 0.95, 0); for (let j = -3; j <= 3; j++) tuft(c, end.p, end.ang + j * 0.2, 0, 30 - Math.abs(j) * 3, 6.5, j % 2 ? PALE : CREAM, 0.15);
-};
-
-// the head in profile, authored point by point in its own frame (origin mid-skull, nose toward +x).
-// The coat still opens in rings from the bridge of the nose, as it does on the face seen from the front.
-const SKULL: P[] = [[-37, 2], [-33, -16], [-19, -30], [2, -33], [20, -27], [33, -17], [45, -9], [57, -5], [61, 3], [57, 11], [50, 22], [34, 28], [10, 31], [-16, 28], [-33, 17]];
-const head = (c: Ctx, at: P, ang: number) => {
- c.save(); c.translate(at[0], at[1]); c.rotate(ang); c.scale(1.18, 1.18);
- // the far ear's tip, then the skull
- blob(c, [[-12, -28], [-17, -43], [-27, -45], [-30, -30]]); c.fillStyle = mix("#a9601f", NIGHT, 0.45); c.fill();
- blob(c, SKULL); c.fillStyle = "#c98a2e"; c.fill();
- c.save(); blob(c, SKULL); c.clip();
- const q = rng(61), N: P = [44, -8];
- for (let ring = 6; ring >= 0; ring--) { const rad = 6 + ring * 14, n = 9 + ring * 3; for (let j = 0; j < n; j++) { const a = Math.PI + lerp(-1.25, 1.35, (j + (ring % 2) * 0.5) / n), low = clamp((Math.sin(a) * -1 - 0.2) * 2.2); tuft(c, N, a + (q() - 0.5) * 0.06, rad, rad + 21, 5.2, mix(ROWS[Math.min(5, 5 - Math.min(5, ring)) ] , CREAM, low * 0.85), 0.18); } }
- // muzzle, chin and throat: pale
- blob(c, [[58, 5], [47, 1], [35, 6], [26, 16], [24, 30], [44, 32], [54, 20]]); c.fillStyle = PALE; c.fill();
- for (let j = 0; j < 9; j++) tuft(c, [50, 6], Math.PI * 0.5 + 0.25 + j * 0.16, 2, 24, 4.4, j % 2 ? CREAM : PALE, 0.14);
- c.restore();
- // crown and cheek spots, small, none on the muzzle
- for (let i = 0; i < 46; i++) { const x = -32 + q() * 56, y = -30 + q() * 54; if (Math.hypot(x - 22, y + 11) < 12 || (x > 12 && y > -4) || y > 20 - (x + 32) * 0.1) continue; spot(c, [x, y], 1.7 + q() * 1.1, 1.4 + q() * 0.8, q() * 3, DARK); }
- // the near ear, laid back by the wind: dark behind, pale inside, a fur rim
- blob(c, [[-5, -27], [-12, -44], [-27, -49], [-35, -37], [-29, -22]]); c.fillStyle = DARK; c.fill();
- for (let j = 0; j < 7; j++) tuft(c, [-14, -25], -Math.PI / 2 - 0.25 - j * 0.13, 3, 17 - Math.abs(j - 3) * 1.6, 3.2, j % 2 ? CREAM : "#e9c98a", 0.12);
- for (let j = 0; j < 9; j++) tuft(c, [-18, -31], -0.5 - j * 0.3, 13, 20, 3, j % 3 ? "#a9601f" : OCHRE, 0);
- // the tear line: from the inner corner of the eye, round the muzzle, to the corner of the mouth
- fillRib(c, ribbon([[27, -7], [30, 2], [36, 10], [37, 16]], [1.6, 3.6, 3.8, 1.4], undefined, 8), DARK);
- // the eye under its brow: lids, amber iris, pupil, the light in it
- blob(c, [[11, -10], [18, -17], [28, -15], [31, -8], [23, -5], [15, -6]]); c.fillStyle = DARK; c.fill();
- blob(c, [[14, -10], [19, -14.5], [26, -13], [28, -8.5], [22, -7], [16, -7.5]]); c.fillStyle = "#f39a1e"; c.fill();
- spot(c, [21.5, -10.5], 2.9, 3.1, 0, "#070b0e"); spot(c, [22.8, -11.8], 1, 1, 0, PALE);
- c.strokeStyle = DARK; c.lineCap = "round"; c.lineWidth = 2.4; c.beginPath(); c.moveTo(9, -15); c.quadraticCurveTo(20, -22, 31, -17); c.stroke();
- // nose pad, nostril, the mouth and the split of the lip, the chin's edge
- blob(c, [[52, -6], [58, -6], [62, 1], [60, 7], [54, 5]]); c.fillStyle = "#1a0f0c"; c.fill();
- c.strokeStyle = "rgba(255,245,222,0.4)"; c.lineWidth = 1.2; c.beginPath(); c.moveTo(54, -3); c.lineTo(59, -2); c.stroke();
- c.strokeStyle = "#1a0f0c"; c.lineWidth = 2; c.beginPath(); c.moveTo(57, 7); c.quadraticCurveTo(55, 13, 48, 14); c.quadraticCurveTo(42, 16, 36, 15); c.stroke();
- c.lineWidth = 1.2; c.globalAlpha = 0.5; c.beginPath(); c.moveTo(50, 22); c.quadraticCurveTo(40, 30, 24, 30); c.stroke(); c.globalAlpha = 1;
- for (let row = 0; row < 3; row++) for (let k = 0; k < 3; k++) spot(c, [50 - k * 5 - row, 6.5 + row * 2.6 - k * 0.6], 0.8, 0.8, 0, "#2a1a12");
- // whiskers, swept back
- c.strokeStyle = PALE; c.lineWidth = 1.1; c.globalAlpha = 0.85;
- for (let k = 0; k < 5; k++) { c.beginPath(); c.moveTo(47 - k * 2, 8 + k * 1.6); c.quadraticCurveTo(26, 14 + k * 5, -2 + k * 3, 24 + k * 7); c.stroke(); }
- c.globalAlpha = 1; c.restore();
-};
-
-/** Where her head sits on this pose: the middle of the skull. A head drawn another way (cheetahTurn's) goes here. */
-export const headAnchor = (pose: Pose): P => { const end = on(ribbon(pose.spine, SPINE_UP, SPINE_DN, 14), 1, 0); return [end.p[0] + Math.cos(end.ang) * 14, end.p[1] + Math.sin(end.ang) * 14]; };
-export const drawCheetah = (c: Ctx, pose: Pose, o: { head?: false } = {}) => {
- tail(c, pose.tail);
- limb(c, pose.hindF, HIND_W, 31, 0.36, true); limb(c, pose.foreF, FORE_W, 32, 0.36, false);
- // the body: its mass, then the coat in seven rows from the belly up, each row laid from the tail forward
- const r = ribbon(pose.spine, SPINE_UP, SPINE_DN, 14), L = 517, q = rng(7);
- fillRib(c, r, "#b9731f");
- c.fillStyle = "#e9d6ad"; c.beginPath(); for (let i = 0; i <= 60; i++) { const at = on(r, 0.14 + (i / 60) * 0.86, 0.98).p; if (i) c.lineTo(at[0], at[1]); else c.moveTo(at[0], at[1]); } for (let i = 60; i >= 0; i--) { const e = i / 60, at = on(r, 0.14 + e * 0.86, lerp(0.62, 0.42, e)).p; c.lineTo(at[0], at[1]); } c.closePath(); c.fill();
- const VS = [-0.84, -0.58, -0.3, 0, 0.28, 0.52, 0.74, 0.93], RC = [...ROWS, CREAM];
- for (let j = VS.length - 1; j >= 0; j--) for (let i = 0; i * 19 < L; i++) {
- const s = (i * 19 + (j % 2) * 9 + (q() - 0.5) * 7) / L; if (s > 1 || s < 0.05) continue;
- const at = on(r, s, VS[j]), k = clamp(at.w / 120, 0.55, 1), neck = clamp((s - 0.72) * 5), rump = 1 - clamp((s - 0.04) * 9), col = mix(mix(RC[j], CREAM, j >= 4 ? neck * 0.5 : 0), ROWS[2], j >= 4 ? rump : 0);
- tuft(c, at.p, at.ang + Math.PI - Math.max(0, VS[j]) * 0.22 + (q() - 0.5) * 0.1, 0, (40 + q() * 12) * k * (j >= 6 ? 0.62 : 1), 12 * k * (j >= 6 ? 0.8 : 1), j >= 6 ? mix(col, OCHRE, 0.1 + q() * 0.12) : mix(col, DARK, q() * 0.08), 0.22, j >= 5 ? 0.3 : 0.6);
- }
- // spots: solid, round, following the surface (they narrow toward the top and the belly line), none on the belly
- const sr = rng(5);
- for (let i = 0; i * 21 < L - 8; i++) for (let j = 0; j < 8; j++) {
- const v = -0.93 + j * 0.2 + (sr() - 0.5) * 0.09, s = (i * 21 + (j % 2) * 10.5 + (sr() - 0.5) * 6 + 8) / L, at = on(r, s, v), k = clamp(at.w / 130, 0.5, 1), z = (5.4 + sr() * 2.4) * k * (1 - clamp(v) * 0.25);
- spot(c, at.p, z * 1.12, z * 0.92 * Math.sqrt(1 - v * v * 0.72), at.ang, DARK);
- }
- limb(c, pose.hindN, HIND_W, 33, 0, true); limb(c, pose.foreN, FORE_W, 34, 0, false);
- if (o.head !== false) head(c, headAnchor(pose), pose.head);
-};
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahDusk.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahDusk.ts
deleted file mode 100644
index 280e506..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahDusk.ts
+++ /dev/null
@@ -1,206 +0,0 @@
-// CHEETAH, DUSK. A 12 s loop for the motion graphics reel. The picture is timed in frames on a
-// 120 bpm grid; the score is four bars at 80 bpm, the same 12 s, meeting it every 1.5 s.
-// The coat is rings of tapered tufts radiating from the bridge of the nose; the tear lines are the
-// one big black shape; the sun sits low behind the head and the moon is in the pupil.
-// 0-60 night. The crescent moon sets as the sun comes up behind the grass.
-// 60-180 the face makes itself: the head's mass, then the coat ring by ring from the nose
-// outward, the ears, the spots in waves, the tear lines drawn down, the muzzle, whiskers.
-// 150-170 the eyes open; the moon is already in them. One blink at 236.
-// 180-290 alive: the coat breathes in a ripple, an ear flicks, the grass moves, a slow push in.
-// 290-338 the camera goes into the left pupil. The crescent in it is carried, at one size on
-// screen, to where the moon hangs in the sky (the persistent actor across the seam).
-// 322-360 the pupil is the night; the grass comes back up. Frame 359 hands over to frame 0.
-import { rng, type Ctx, type Env, type Layer, type P } from "./core";
-import type { Film } from "./film";
-import { mix } from "./gallery";
-import { cheetahDuskScore } from "./music/pieces/cheetah";
-import { renderLoop } from "./music/render";
-
-const W = 1080, H = 1080, N = 360;
-const NIGHT = "#0d1a22", TEAL = "#2a6a70", RUST = "#b8452a", OCHRE = "#e3a23a", GOLD = "#efb84e", CREAM = "#f2e4c5", PALE = "#fff5de", CORAL = "#f2643c", DARK = "#0a1216", PUPIL = "#070b0e";
-const F: P = [540, 610], EYE_L: P = [388, 512], EYE_R: P = [692, 512], MOON: P = [760, 220], MOON_R = 46;
-const clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v));
-const ramp = (f: number, a: number, b: number) => clamp((f - a) / (b - a));
-const out3 = (t: number) => 1 - Math.pow(1 - clamp(t), 3);
-const inOut = (t: number) => { const c = clamp(t); return c < 0.5 ? 4 * c * c * c : 1 - Math.pow(-2 * c + 2, 3) / 2; };
-const back = (t: number) => { const c = clamp(t) - 1; return 1 + 2.4 * c * c * c + 1.4 * c * c; }; // lands a little past, then settles
-const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
-
-// a tuft: a tapered leaf from radius r0 to r1 along angle a, darker at its root
-const tuft = (c: Ctx, o: P, a: number, r0: number, r1: number, w: number, col: string, vein = 0.22) => {
- if (r1 - r0 < 1.5 || w < 0.6) return;
- const ca = Math.cos(a), sa = Math.sin(a), b: P = [o[0] + ca * r0, o[1] + sa * r0], t: P = [o[0] + ca * r1, o[1] + sa * r1], m = r0 + (r1 - r0) * 0.42, mx = o[0] + ca * m, my = o[1] + sa * m;
- const g = c.createLinearGradient(b[0], b[1], t[0], t[1]); g.addColorStop(0, mix(col, DARK, 0.6)); g.addColorStop(0.45, col); g.addColorStop(1, mix(col, "#ffffff", 0.16));
- c.fillStyle = g; c.beginPath(); c.moveTo(b[0], b[1]); c.quadraticCurveTo(mx - sa * w, my + ca * w, t[0], t[1]); c.quadraticCurveTo(mx + sa * w, my - ca * w, b[0], b[1]); c.fill();
- if (vein > 0) { c.strokeStyle = mix(col, DARK, 0.7); c.globalAlpha = vein; c.lineWidth = 1; c.beginPath(); c.moveTo(b[0], b[1]); c.lineTo(o[0] + ca * (r1 - 6), o[1] + sa * (r1 - 6)); c.stroke(); c.globalAlpha = 1; }
-};
-const crescent = (c: Ctx, x: number, y: number, R: number, col: string) => { // a true crescent, so it needs no ground colour behind it
- const ix = x + R * 0.5, iy = y - R * 0.24, ir = R * 0.9, out: P[] = [], inn: P[] = [];
- for (let i = 0; i < 90; i++) { const a = (i / 90) * Math.PI * 2 + 0.3, p: P = [x + Math.cos(a) * R, y + Math.sin(a) * R]; if (Math.hypot(p[0] - ix, p[1] - iy) >= ir) out.push(p); }
- for (let i = 0; i < 90; i++) { const a = (i / 90) * Math.PI * 2 + 0.3, p: P = [ix + Math.cos(a) * ir, iy + Math.sin(a) * ir]; if (Math.hypot(p[0] - x, p[1] - y) <= R) inn.push(p); }
- // both runs are contiguous once rotated to start at a gap
- const rot = (q: P[], far: (p: P) => number) => { let k = 0, best = -1; for (let i = 0; i < q.length; i++) { const d = Math.hypot(q[i][0] - q[(i + 1) % q.length][0], q[i][1] - q[(i + 1) % q.length][1]); if (d > best) { best = d; k = i + 1; } } void far; return [...q.slice(k), ...q.slice(0, k)]; };
- const A = rot(out, () => 0), B = rot(inn, () => 0).reverse();
- c.fillStyle = col; c.beginPath(); [...A, ...B].forEach((p, i) => (i ? c.lineTo(p[0], p[1]) : c.moveTo(p[0], p[1]))); c.closePath(); c.fill();
-};
-
-// ---------------------------------------------------------------- the parts, laid out once
-const COAT = [
- { r0: 318, r1: 432, n: 92, w: 20, col: "#a9601f" }, { r0: 268, r1: 368, n: 84, w: 20, col: "#cf8a2c" }, { r0: 216, r1: 310, n: 74, w: 19, col: OCHRE },
- { r0: 164, r1: 254, n: 62, w: 18, col: GOLD }, { r0: 112, r1: 198, n: 50, w: 17, col: "#f2c263" }, { r0: 62, r1: 142, n: 38, w: 15, col: "#f4cd7e" },
-];
-type T = { a: number; r0: number; r1: number; w: number; col: string; t0: number; ring: number };
-const PARTS = (() => {
- const r = rng(11);
- const neck = Array.from({ length: 6 * 14 }, (_, i) => { const row = 5 - Math.floor(i / 14), k = (i % 14) - 1; return { x: k * 94 + (row % 2) * 47 + 10, y: 820 + row * 56, col: mix(["#a9601f", "#cf8a2c", "#8f4f1c"][row % 3], DARK, 0.2 + row * 0.07 + r() * 0.1), t0: 52 + row * 5 + r() * 6 }; });
- const coat: T[] = [];
- COAT.forEach((k, i) => { for (let j = 0; j < k.n; j++) { const a = ((j + (i % 2) * 0.5) / k.n) * Math.PI * 2, down = clamp((Math.sin(a) - 0.25) * 1.7) * clamp((i - 1) / 3), len = 1 + (r() - 0.5) * 0.12; coat.push({ a, r0: k.r0, r1: k.r0 + (k.r1 - k.r0) * len, w: k.w, col: mix(mix(k.col, CREAM, down), DARK, r() * 0.1), t0: 72 + (5 - i) * 9 + (((a + Math.PI / 2) / (Math.PI * 2) + 1) % 1) * 12, ring: i }); } });
- const sr = rng(5), spots: { x: number; y: number; s: number; a: number; t0: number }[] = [];
- for (let ring = 0; ring < 9; ring++) { const rad = 150 + ring * 29, n = Math.round((rad * 2 * Math.PI) / 40);
- for (let j = 0; j < n; j++) { const a = ((j + (ring % 2) * 0.5 + (sr() - 0.5) * 0.3) / n) * Math.PI * 2, x = F[0] + Math.cos(a) * rad, y = F[1] + Math.sin(a) * rad * 0.95, s = 4.2 + ring * 0.55 + sr() * 1.8, jit = sr();
- if (Math.sin(a) > 0.2 && rad < 330) continue; if (Math.hypot(x - EYE_L[0], y - EYE_L[1]) < 132 || Math.hypot(x - EYE_R[0], y - EYE_R[1]) < 132) continue; if (Math.abs(x - 540) < 46 && y > 430) continue;
- spots.push({ x, y, s, a, t0: 128 + ring * 4 + jit * 8 }); } }
- const gr = rng(41), grass = Array.from({ length: 70 }, () => ({ x: gr() * W, h: 90 + gr() * 220, a: (gr() - 0.5) * 0.5, w: 9 + gr() * 8, col: gr() < 0.15 ? TEAL : mix(NIGHT, TEAL, gr() * 0.5), ph: gr() * 6.28 }));
- return { neck, coat, spots, grass };
-})();
-
-const ear = (c: Ctx, o: P, side: number, f: number) => {
- const g = back(ramp(f, 122, 140)); if (g <= 0) return;
- const flick = side < 0 ? Math.sin(ramp(f, 206, 222) * Math.PI * 2) * 0.16 * (1 - ramp(f, 206, 222)) : 0;
- c.save(); c.translate(o[0] + side * 40, o[1] + 70); c.rotate(flick); c.scale(g, g); c.translate(-o[0] - side * 40, -o[1] - 70);
- c.fillStyle = DARK; c.beginPath(); c.ellipse(o[0], o[1], 84, 92, side * 0.35, 0, Math.PI * 2); c.fill();
- for (let j = 0; j < 30; j++) tuft(c, [o[0] + side * 12, o[1] + 38], -Math.PI / 2 + side * 0.3 + (j / 29 - 0.5) * 2.3, 8, 78 - Math.abs(j - 14.5) * 1.8, 9, j % 2 ? CREAM : "#e9c98a", 0.15);
- for (let j = 0; j < 46; j++) tuft(c, o, (j / 46) * Math.PI * 2, 68, 100, 8, j % 3 ? "#a9601f" : OCHRE, 0);
- c.restore();
-};
-const eye = (c: Ctx, o: P, side: number, f: number, pupilCol: string, moon: boolean) => {
- const patch = ramp(f, 118, 138);
- for (let j = 0; j < 34; j++) { const g = back(clamp(patch * 1.6 - (j / 34) * 0.6)); tuft(c, o, (j / 34) * Math.PI * 2, 58, 58 + (54 + (j % 2) * 8) * g, 11 * g, j % 2 ? CREAM : PALE, 0.15); }
- const blink = 1 - 0.92 * Math.sin(ramp(f, 234, 246) * Math.PI), open = out3(ramp(f, 150, 170)) * blink; if (patch <= 0) return;
- const lid = (g: number) => { c.beginPath(); c.moveTo(o[0] - side * (86 + g), o[1] + 30 + g * 0.4); c.bezierCurveTo(o[0] - side * 40, o[1] - 62 - g, o[0] + side * 50, o[1] - 70 - g, o[0] + side * (92 + g), o[1] - 22); c.bezierCurveTo(o[0] + side * 46, o[1] + 58 + g, o[0] - side * 30, o[1] + 66 + g, o[0] - side * (86 + g), o[1] + 30 + g * 0.4); c.closePath(); };
- c.save(); c.translate(o[0], o[1]); c.scale(patch, Math.max(0.07, open) * patch); c.translate(-o[0], -o[1]);
- c.fillStyle = DARK; lid(15); c.fill();
- c.save(); lid(0); c.clip();
- const g = c.createRadialGradient(o[0], o[1], 16, o[0], o[1], 70); g.addColorStop(0, "#ffd24a"); g.addColorStop(0.55, "#f39a1e"); g.addColorStop(1, "#b84a14");
- c.fillStyle = g; c.fillRect(o[0] - 120, o[1] - 100, 240, 200);
- const r = rng(90 + side); c.lineCap = "round";
- for (let i = 0; i < 150; i++) { const a = (i / 150) * Math.PI * 2 + r() * 0.03, a0 = 30 + r() * 8, a1 = 44 + r() * 30, lt = r() < 0.4; c.strokeStyle = lt ? "#ffe9a0" : "#8a2c0c"; c.globalAlpha = 0.18 + r() * 0.3; c.lineWidth = 0.8 + r() * 1.3; c.beginPath(); c.moveTo(o[0] + Math.cos(a) * a0, o[1] + Math.sin(a) * a0); c.lineTo(o[0] + Math.cos(a) * a1, o[1] + Math.sin(a) * a1); c.stroke(); }
- c.globalAlpha = 1; c.fillStyle = "rgba(40,10,4,0.4)"; c.beginPath(); c.ellipse(o[0], o[1] - 96, 150, 66, 0, 0, Math.PI * 2); c.fill(); // the lid's shadow
- // the pupil: wide as the eye opens, narrowing in the light, widening again as the camera comes in
- const pr = 29 * (1.3 - 0.3 * out3(ramp(f, 166, 200)) + 0.35 * inOut(ramp(f, 286, 320)));
- c.fillStyle = pupilCol; c.beginPath(); c.arc(o[0], o[1] - 2, pr, 0, Math.PI * 2); c.fill();
- if (moon) crescent(c, o[0] - 10, o[1] - 12, 9.5, PALE);
- c.fillStyle = "rgba(255,245,222,0.9)"; c.globalAlpha = 1 - ramp(f, 300, 318); c.beginPath(); c.arc(o[0] + 13, o[1] + 11, 2.6, 0, Math.PI * 2); c.fill(); c.globalAlpha = 1;
- c.restore(); c.restore();
-};
-// the tear line: one black stroke from the inner corner of the eye, round the muzzle, to the mouth
-const tear = (c: Ctx, side: number, prog: number) => {
- if (prog <= 0) return;
- const p: P[] = [[540 - side * 76, 548], [540 - side * 70, 640], [540 - side * 128, 720], [540 - side * 110, 836]], bz = (t: number): P => { const u = 1 - t; return [u * u * u * p[0][0] + 3 * u * u * t * p[1][0] + 3 * u * t * t * p[2][0] + t * t * t * p[3][0], u * u * u * p[0][1] + 3 * u * u * t * p[1][1] + 3 * u * t * t * p[2][1] + t * t * t * p[3][1]]; };
- const L: P[] = [], R: P[] = [], n = 40, m = Math.max(1, Math.round(n * prog));
- for (let i = 0; i <= m; i++) { const t = i / n, a = bz(t), b = bz(Math.min(1, t + 0.01)), d = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1, nx = -(b[1] - a[1]) / d, ny = (b[0] - a[0]) / d, w = (7 + 15 * Math.sin(Math.PI * Math.pow(t, 0.6)) * (1 - t * 0.35)) * (i === m && prog < 1 ? 0.3 : 1); L.push([a[0] + nx * w, a[1] + ny * w]); R.push([a[0] - nx * w, a[1] - ny * w]); }
- c.fillStyle = DARK; c.beginPath(); [...L, ...R.reverse()].forEach(([x, y], i) => (i ? c.lineTo(x, y) : c.moveTo(x, y))); c.closePath(); c.fill();
-};
-export const duskGrass = PARTS.grass, FACE: P = F;
-const grass = (c: Ctx, f: number, grow: number) => { for (const g of PARTS.grass) tuft(c, [g.x, H + 20], -Math.PI / 2 + g.a + Math.sin(f * (Math.PI / 45) + g.ph) * 0.07, 0, g.h * grow, g.w, g.col, 0); };
-
-// the night's stars: they are out while it is night, at the start and again at the end, never still
-const STARS = (() => { const r = rng(19); return Array.from({ length: 46 }, () => ({ x: r() * W, y: r() * 760, s: 1.2 + r() * 2.2, ph: r() * 6.28, cyc: [4, 6, 8, 9, 12][Math.floor(r() * 5)] })); })(); // cyc: whole twinkles per loop, so frame 359 meets frame 0
-const stars = (c: Ctx, f: number, k: number) => { if (k <= 0) return; for (const st of STARS) { c.globalAlpha = k * (0.35 + 0.65 * (0.5 + 0.5 * Math.sin((f / N) * Math.PI * 2 * st.cyc + st.ph))); c.fillStyle = PALE; c.beginPath(); c.arc(st.x, st.y, st.s, 0, Math.PI * 2); c.fill(); } c.globalAlpha = 1; };
-
-// ---------------------------------------------------------------- the camera
-export const camAt = (f: number) => {
- const a = inOut(ramp(f, 180, 290)), b = ramp(f, 290, 338), z = Math.pow(2, lerp(0, Math.log2(1.14), a) + inOut(b) * (Math.log2(52) - Math.log2(1.14))), lk = out3(b * 1.5);
- return { z, look: [lerp(lerp(540, 506, a), EYE_L[0], lk), lerp(lerp(540, 532, a), EYE_L[1] - 2, lk)] as P };
-};
-
-const grainLayer = (env: Env): Layer => { // the paper's tooth and the dusk settling at the edges: laid once, the same on every frame
- const key = "cheetah:grain"; let L = env.cache.get(key) as Layer | undefined; if (L) return L;
- L = env.canvas(Math.round(W * env.scale), Math.round(H * env.scale)); env.cache.set(key, L);
- const c = L.ctx, q = rng(77); c.setTransform(env.scale, 0, 0, env.scale, 0, 0);
- for (let i = 0; i < 200000; i++) { const x = q() * W, y = q() * H, d = Math.hypot(x - 540, y - 520) / 740; if (q() > d * d * d * 1.1) continue; c.fillStyle = DARK; c.globalAlpha = 0.42; c.fillRect(x, y, 1.1, 1.1); }
- for (let i = 0; i < 30000; i++) { const x = q() * W, y = q() * H, lt = q() < 0.5; c.fillStyle = lt ? "#fff5de" : "#000000"; c.globalAlpha = lt ? 0.06 : 0.08; c.fillRect(x, y, 1.1, 1.1); }
- return L;
-};
-
-// The face on its own, for a caller that has set the transform: all of it, or one part. cheetahRun
-// turns this head in space, so it takes the parts as layers: the neck, the head with no features (its back), the whole head.
-export const duskFace = (c: Ctx, f: number, part: "all" | "neck" | "coat" | "head" = "all") => {
- const pupilCol = mix(PUPIL, NIGHT, ramp(f, 312, 336));
- // neck and shoulders rise
- if (part === "all" || part === "neck") for (const n of PARTS.neck) { const g = back(ramp(f, n.t0, n.t0 + 16)); tuft(c, [n.x, n.y - 70 + (1 - g) * 60], Math.PI / 2, 0, 150 * g, 52 * g, n.col, 0.3); }
- if (part === "neck") return;
- ear(c, [262, 300], -1, f); ear(c, [818, 300], 1, f);
- // the head's own mass, then the coat over it: rings of tufts from the nose outward, breathing once it is whole
- const mass = ramp(f, 70, 132); // it spreads just under the coat as the rings open, never a bare disc
- if (mass > 0) { c.fillStyle = "#b9731f"; c.beginPath(); c.ellipse(F[0], F[1], lerp(50, 372, mass), lerp(48, 352, mass), 0, 0, Math.PI * 2); c.fill(); }
- c.save(); c.translate(F[0], F[1]); c.scale(1, 0.95); c.translate(-F[0], -F[1]);
- const alive = ramp(f, 170, 200) * (1 - ramp(f, 300, 330));
- for (const t of PARTS.coat) { const g = back(ramp(f, t.t0, t.t0 + 15)); if (g <= 0) continue; const br = 1 + 0.045 * alive * Math.sin(f * (Math.PI / 45) + t.ring * 0.9); tuft(c, F, t.a, t.r0, t.r0 + (t.r1 - t.r0) * g * br, t.w * Math.min(1, g), t.col); }
- c.restore();
- for (const p of PARTS.spots) { const g = back(ramp(f, p.t0, p.t0 + 9)); if (g <= 0) continue; c.fillStyle = DARK; c.beginPath(); c.ellipse(p.x, p.y, p.s * 1.12 * g, p.s * 0.94 * g, p.a, 0, Math.PI * 2); c.fill(); }
- if (part === "coat") return;
- // the bridge of the nose: a pale fan falling from between the eyes
- for (let i = -4; i <= 4; i++) { const g = back(ramp(f, 108 + Math.abs(i) * 2, 126 + Math.abs(i) * 2)); tuft(c, [540, 452], Math.PI / 2 + i * 0.075, 20, 20 + (194 - Math.abs(i) * 12) * g, 13 * g, i % 2 ? "#f4cd7e" : "#f8dca0", 0.18); }
- tear(c, 1, inOut(ramp(f, 134, 162))); tear(c, -1, inOut(ramp(f, 134, 162)));
- eye(c, EYE_L, -1, f, pupilCol, f < 290); eye(c, EYE_R, 1, f, pupilCol, true);
- // the muzzle: two pale lobes and the chin
- const mz = ramp(f, 124, 150);
- for (let j = 0; j < 22; j++) { const g = back(clamp(mz * 1.5 - 0.25)); tuft(c, [540, 760], Math.PI / 2 + (j / 21 - 0.5) * 1.7, 30, 30 + 98 * g, 13 * g, j % 2 ? CREAM : PALE, 0.15); }
- for (const sd of [-1, 1]) for (let j = 0; j < 30; j++) { const g = back(clamp(mz * 1.6 - (j / 30) * 0.5)); tuft(c, [540 + sd * 52, 742], (j / 30) * Math.PI * 2, 6, 6 + (72 + (j % 2) * 6) * g, 12 * g, j % 2 ? PALE : CREAM, 0.15); }
- const dots = ramp(f, 150, 162); if (dots > 0) for (const sd of [-1, 1]) for (let row = 0; row < 3; row++) for (let k = 0; k < 4; k++) { c.fillStyle = "#2a1a12"; c.beginPath(); c.arc(540 + sd * (36 + k * 20 + row * 5), 742 + row * 17 - k * 3, 3.2 * dots, 0, Math.PI * 2); c.fill(); }
- // nose, mouth, whiskers
- const ns = back(ramp(f, 140, 154));
- if (ns > 0) { c.save(); c.translate(540, 690); c.scale(ns, ns); c.translate(-540, -690);
- c.fillStyle = "#1a0f0c"; c.beginPath(); c.moveTo(488, 672); c.bezierCurveTo(510, 656, 570, 656, 592, 672); c.bezierCurveTo(588, 706, 560, 728, 540, 734); c.bezierCurveTo(520, 728, 492, 706, 488, 672); c.fill();
- c.strokeStyle = "rgba(255,245,222,0.35)"; c.lineWidth = 3; c.lineCap = "round"; c.beginPath(); c.moveTo(506, 674); c.quadraticCurveTo(540, 664, 574, 674); c.stroke(); c.restore(); }
- const mo = ramp(f, 152, 166); if (mo > 0) { c.strokeStyle = "#1a0f0c"; c.lineWidth = 5; c.lineCap = "round"; c.beginPath(); c.moveTo(540, 732); c.lineTo(540, 732 + 36 * mo); if (mo >= 1) { const q = ramp(f, 166, 176); c.moveTo(540, 768); c.quadraticCurveTo(540 - 28 * q, 768 + 32 * q, 540 - 70 * q, 768 + 18 * q); c.moveTo(540, 768); c.quadraticCurveTo(540 + 28 * q, 768 + 32 * q, 540 + 70 * q, 768 + 18 * q); } c.stroke(); }
- const wh = out3(ramp(f, 160, 184)); if (wh > 0) for (const sd of [-1, 1]) for (let k = 0; k < 5; k++) { const sway = Math.sin(f * (Math.PI / 60) + k) * 6 * alive, a: P = [540 + sd * 96, 742 + k * 9], m: P = [540 + sd * 250, 720 + k * 22 + sway * 0.5], e: P = [540 + sd * (400 + k * 14), 690 + k * 46 + sway]; c.strokeStyle = PALE; c.globalAlpha = 0.85; c.lineWidth = 2; c.beginPath(); c.moveTo(a[0], a[1]); for (let i = 1; i <= 16; i++) { const t = (i / 16) * wh, u = 1 - t; c.lineTo(u * u * a[0] + 2 * u * t * m[0] + t * t * e[0], u * u * a[1] + 2 * u * t * m[1] + t * t * e[1]); } c.stroke(); }
- c.globalAlpha = 1;
-};
-// Another film may borrow this one's world (cheetahRun does): its own camera, a clock for the sun's
-// rays and the grass that runs on while the face's own time is held, the face moved aside or left
-// out, the grass and the grain left for the borrower to lay. With no options it is this film, exactly.
-export type DuskOpts = { cam?: { z: number; look: P }; world?: number; face?: false; grass?: false; grain?: false };
-export const drawDusk = (ctx: Ctx, f: number, env: Env, o: DuskOpts = {}) => {
- const c = ctx, s = env.scale, cam = o.cam ?? camAt(f), wf = o.world ?? f;
- c.setTransform(s, 0, 0, s, 0, 0); c.fillStyle = NIGHT; c.fillRect(0, 0, W, H);
- if (f < 60) stars(c, f, 1 - ramp(f, 14, 52));
- c.setTransform(s * cam.z, 0, 0, s * cam.z, s * (540 - cam.look[0] * cam.z), s * (540 - cam.look[1] * cam.z));
- // the moon, setting; the sun, rising behind the grass with its rays opening
- const set = ramp(f, 4, 52); if (set < 1) crescent(c, MOON[0] - set * set * 160, MOON[1] + set * set * 1000, MOON_R, PALE);
- const rise = out3(ramp(f, 8, 74)), sy = lerp(1700, 430, rise), rays = back(ramp(f, 40, 86));
- for (let j = 0; j < 96; j++) tuft(c, [540, sy], (j / 96) * Math.PI * 2 + wf * 0.0016, 440, 440 + (80 + (j % 2) * 26) * rays, 12, j % 2 ? RUST : "#8f3a26", 0);
- const sg = c.createRadialGradient(540, sy, 80, 540, sy, 470); sg.addColorStop(0, "#ff8a4a"); sg.addColorStop(1, CORAL); c.fillStyle = sg; c.beginPath(); c.arc(540, sy, 470, 0, Math.PI * 2); c.fill();
- if (o.face !== false) duskFace(c, f);
- if (o.grass !== false) grass(c, wf, 1);
- // screen space: the crescent carried out of the pupil to its place in the sky, and the grass coming back
- c.setTransform(s, 0, 0, s, 0, 0);
- if (f >= 290) { const u = ramp(f, 290, 338), e = inOut(u), from: P = [540 + (EYE_L[0] - 10 - cam.look[0]) * Math.min(cam.z, 1.6), 540 + (EYE_L[1] - 12 - cam.look[1]) * Math.min(cam.z, 1.6)]; crescent(c, lerp(from[0], MOON[0], e), lerp(from[1], MOON[1], e) - Math.sin(Math.PI * u) * 40, 9.5 * Math.pow(MOON_R / 9.5, e), PALE); }
- if (f >= 322) { stars(c, f, ramp(f, 326, 352)); grass(c, f, inOut(ramp(f, 322, 359))); }
- c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha = 1; if (o.grain !== false) c.drawImage(grainLayer(env).canvas, 0, 0);
-};
-const draw = (ctx: Ctx, f: number, env: Env) => drawDusk(ctx, f, env);
-
-// the score: four bars at 80 bpm are the film's 12 s exactly, so the loop is the music's own
-/** The night the film ends on, held: the stars, the crescent in its place, the grass. At t = 359 it is the film's last frame, and it runs on from there. */
-export const duskNight = (ctx: Ctx, t: number, env: Env) => {
- const c = ctx, s = env.scale;
- c.setTransform(s, 0, 0, s, 0, 0); c.fillStyle = NIGHT; c.fillRect(0, 0, W, H);
- crescent(c, MOON[0], MOON[1], MOON_R, PALE); stars(c, t, 1); grass(c, t, 1);
- c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha = 1; c.drawImage(grainLayer(env).canvas, 0, 0);
-};
-export const DUSK_PALE = PALE;
-
-const audio = (sr: number): [Float32Array, Float32Array] => {
- const n = Math.round((N / 30) * sr), L = new Float32Array(n), R = new Float32Array(n), m = renderLoop(cheetahDuskScore(), sr); // its tail folded back onto its start: no cut at the seam
- for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }
- return [L, R];
-};
-
-export const cheetahDusk: Film = {
- meta: { title: "Cheetah, dusk", W, H, fps: 30, bpm: 120, durationFrames: N, raster: "cpu", kind: "loop", poster: 260, score: { tempo: 80, form: "4 bars, looping: pad and phrase, groove, climb, half-time home" } },
- assets: { images: {} },
- shots: [{ id: "cheetah", start: 0, end: N, draw }],
- audio: Object.assign(audio, { scores: [cheetahDuskScore()] }),
-};
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRig.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRig.ts
deleted file mode 100644
index 21a61c4..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRig.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-// THE CHEETAH'S SKELETON. A rig is a set of angles; fk() turns it into the points cheetahBody draws.
-// Bones never change length, so a leg swings in arcs and folds at its joints, it never stretches.
-// Angles are in degrees, absolute, y down: 0 points forward (the animal faces right), 90 down, 180 back.
-// The gallop is the rotary gallop of the reference: two flight phases a stride, the spine folding
-// (gathered, hind feet reaching past the fore) and opening (extended), the forelegs landing one
-// after the other, then the hind legs. The head is held level at its own height whatever the body does.
-import type { P } from "./core";
-import type { Pose } from "./cheetahBody";
-
-type Leg = [number, number, number, number];
-export type Rig = {
- pitch: number; lumb: number; thor: number; // the body's tilt (nose down is positive); how far the loin and the chest fold
- headH: number; head: number; // the head's height above the ground; its own angle (nose down is positive)
- fore: Leg; foreF: Leg; // scapula, upper arm, forearm, hand
- hind: Leg; hindF: Leg; // thigh, shank, metatarsus, toes
- tail: number[]; // its five segments
-};
-
-const D = Math.PI / 180, clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v)), lerp = (a: number, b: number, t: number) => a + (b - a) * t;
-const step = (p: P, deg: number, len: number): P => [p[0] + Math.cos(deg * D) * len, p[1] + Math.sin(deg * D) * len];
-const off = (p: P, deg: number, x: number, y: number): P => { const c = Math.cos(deg * D), s = Math.sin(deg * D); return [p[0] + x * c - y * s, p[1] + x * s + y * c]; };
-export const FORE_BONES = [54, 98, 103, 60], HIND_BONES = [102, 105, 79, 34], TAIL_BONES = [65, 66, 66, 59, 43];
-const REAR = [65.1, 75.3, 43.3], FRONT = [65.3, 70, 60.3], NECK = 138; // spine segments out from the waist; the neck's chord
-const chain = (p: P, dirs: number[], bones: number[]): P[] => { const out: P[] = [p]; dirs.forEach((d, i) => out.push(step(out[i], d, bones[i]))); return out; };
-
-/** The points, with the waist at (x, y) and the ground at `ground`. */
-export const fk = (r: Rig, x: number, y: number, ground: number): Pose => {
- const waist: P = [x, y], p = r.pitch;
- const fwd = [p + 5 + r.thor * 0.3, p + 2 + r.thor * 0.7, p - 5 + r.thor], back = [p + 3.5 - r.lumb * 0.3, p + 5 - r.lumb * 0.75, p + 7 - r.lumb * 1.1];
- const ribs = step(waist, fwd[0], FRONT[0]), chest = step(ribs, fwd[1], FRONT[1]), shoulder = step(chest, fwd[2], FRONT[2]);
- const loin = step(waist, back[0] + 180, REAR[0]), hip = step(loin, back[1] + 180, REAR[1]), rump = step(hip, back[2] + 180, REAR[2]);
- // the neck reaches whatever is left between the shoulders and a head that keeps its own height
- const dy = clamp(ground - r.headH - shoulder[1], -NECK * 0.82, NECK * 0.82), dx = Math.sqrt(NECK * NECK - dy * dy), join: P = [shoulder[0] + dx, shoulder[1] + dy];
- const nx = dy / NECK, ny = -dx / NECK, bow = (t: number, b: number): P => [lerp(shoulder[0], join[0], t) + nx * b, lerp(shoulder[1], join[1], t) + ny * b];
- return {
- spine: [rump, hip, loin, waist, ribs, chest, shoulder, bow(0.38, 7), bow(0.73, 5), join],
- tail: chain(off(rump, back[2], 4, -14), r.tail, TAIL_BONES),
- foreN: chain(off(shoulder, fwd[2], -10, -24), r.fore, FORE_BONES), foreF: chain(off(shoulder, fwd[2], -2, -20), r.foreF, FORE_BONES),
- hindN: chain(off(hip, back[1], 7, 15), r.hind, HIND_BONES), hindF: chain(off(hip, back[1], 15, 17), r.hindF, HIND_BONES),
- head: r.head * D,
- };
-};
-
-const low = (leg: P[]) => Math.max(leg[3][1], leg[4][1]) + 5; // a foot's sole: the lower of its ball and its toes, plus the pad
-export const lowest = (q: Pose) => ({ fore: Math.max(low(q.foreN), low(q.foreF)), hind: Math.max(low(q.hindN), low(q.hindF)) });
-const blend = (a: number[], b: number[], t: number) => a.map((v, i) => lerp(v, b[i], t));
-export const mixRig = (a: Rig, b: Rig, t: number): Rig => ({
- pitch: lerp(a.pitch, b.pitch, t), lumb: lerp(a.lumb, b.lumb, t), thor: lerp(a.thor, b.thor, t), headH: lerp(a.headH, b.headH, t), head: lerp(a.head, b.head, t),
- fore: blend(a.fore, b.fore, t) as Leg, foreF: blend(a.foreF, b.foreF, t) as Leg, hind: blend(a.hind, b.hind, t) as Leg, hindF: blend(a.hindF, b.hindF, t) as Leg, tail: blend(a.tail, b.tail, t),
-});
-
-/** A standing pose settles onto the ground: the body tilts until fore and hind feet both bear, and its height follows. */
-export const settle = (r: Rig): { rig: Rig; y: number } => {
- let rig = r;
- for (let k = 0; k < 8; k++) { const q = fk(rig, 0, 0, 0), l = lowest(q); rig = { ...rig, pitch: rig.pitch + (Math.atan2(l.hind - l.fore, q.foreN[4][0] - q.hindN[4][0]) / D) * 0.9 }; }
- const l = lowest(fk(rig, 0, 0, 0)); return { rig, y: -Math.max(l.fore, l.hind) };
-};
-
-// ---------------------------------------------------------------- the held poses
-export const STAND: Rig = { pitch: 0, lumb: 0, thor: 0, headH: 356, head: 6, fore: [80, 118, 88, 68], foreF: [76, 108, 92, 72], hind: [58, 128, 86, 18], hindF: [66, 134, 90, 20], tail: [118, 100, 98, 122, 160] }; // the tail at rest: down behind the hocks, its tip turned up
-// the bow: forelegs walked out flat along the ground, chest down between them, the rump left high, the back hollow
-export const BOW: Rig = { pitch: 0, lumb: -22, thor: -12, headH: 150, head: -14, fore: [52, 38, 8, 2], foreF: [50, 44, 12, 4], hind: [78, 112, 88, 14], hindF: [84, 118, 92, 16], tail: [250, 262, 285, 318, 350] };
-// the crouch before the start: weight back over folded hind legs, the chest low, the head stretched forward
-export const CROUCH: Rig = { pitch: 0, lumb: 16, thor: 6, headH: 196, head: 10, fore: [88, 150, 62, 50], foreF: [84, 142, 68, 54], hind: [36, 142, 72, 12], hindF: [44, 148, 78, 14], tail: [176, 170, 176, 190, 204] };
-// the stop: forelegs braced out ahead, the rump dropped under, the tail thrown up for balance
-export const SKID: Rig = { pitch: 0, lumb: 20, thor: 2, headH: 262, head: -4, fore: [62, 62, 56, 30], foreF: [60, 70, 62, 34], hind: [30, 138, 66, 10], hindF: [40, 146, 74, 12], tail: [228, 246, 262, 280, 300] };
-
-// ---------------------------------------------------------------- the gallop
-// One stride. Keys: 0 extended flight · .14 the forefeet reach the ground · .27 over the forelegs ·
-// .40 they push off · .52 gathered flight · .66 the hind feet land ahead · .80 over the hind legs · .92 they drive off.
-const T = [0, 0.14, 0.27, 0.4, 0.52, 0.66, 0.8, 0.92];
-const FORE = [[70, 23, 15, 15], [78, 55, 50, 35], [92, 118, 78, 45], [105, 140, 125, 140], [105, 135, 172, 225], [95, 110, 150, 215], [82, 60, 95, 150], [72, 28, 30, 50]];
-const HIND = [[141, 187, 164, 159], [128, 185, 150, 150], [100, 170, 125, 135], [60, 176, 122, 122], [22, 146, 56, 30], [40, 128, 58, 8], [88, 140, 85, 10], [122, 168, 135, 100]];
-// lumb thor pitch tail height of the waist in flight
-const BODY = [[-12, -4, 0, 188, 262], [-8, -1, 3, 180, 266], [6, 5, 4, 176, 286], [36, 13, 2, 190, 292], [64, 22, 0, 212, 300], [54, 17, -3, 218, 296], [20, 5, -4, 204, 288], [-6, -3, -2, 194, 272]];
-const TAIL_CURL = [0, -10, 4, 20, 34];
-const cyc = (V: number[][], ph: number): number[] => {
- const n = T.length, f = ((ph % 1) + 1) % 1; let i = n - 1; for (let k = 0; k < n; k++) if (f >= T[k]) i = k;
- const tt = (k: number) => T[((k % n) + n) % n] + Math.floor(k / n), vv = (k: number) => V[((k % n) + n) % n], t1 = tt(i), t2 = tt(i + 1), h = t2 - t1, u = (f - t1) / h, u2 = u * u, u3 = u2 * u;
- return vv(i).map((v1, c) => { const v2 = vv(i + 1)[c], m1 = ((v2 - vv(i - 1)[c]) / (t2 - tt(i - 1))) * h, m2 = ((vv(i + 2)[c] - v1) / (tt(i + 2) - t1)) * h; return (2 * u3 - 3 * u2 + 1) * v1 + (u3 - 2 * u2 + u) * m1 + (-2 * u3 + 3 * u2) * v2 + (u3 - u2) * m2; });
-};
-// the far legs run the same stride a little later: one forefoot lands, then the other
-const FAR_FORE = 0.085, FAR_HIND = 0.07;
-export const gallopRig = (ph: number): Rig => {
- const b = cyc(BODY, ph);
- return { pitch: b[2], lumb: b[0], thor: b[1], headH: 300, head: 5 + b[2] * 0.3, fore: cyc(FORE, ph) as Leg, foreF: cyc(FORE, ph - FAR_FORE) as Leg, hind: cyc(HIND, ph) as Leg, hindF: cyc(HIND, ph - FAR_HIND) as Leg, tail: TAIL_CURL.map((k, i) => { const a = cyc(BODY, ph - 0.09 * i)[3]; return 196 + (a - 196) * (1 + i * 0.18) + k; }) }; // each segment follows the one before it, later and wider: the whip of the tail
-};
-// how firmly the feet are on the ground through the stride: two stances, two flights
-const stance = (ph: number) => { const f = ((ph % 1) + 1) % 1, bump = (c: number, w: number) => { const d = Math.min(Math.abs(f - c), 1 - Math.abs(f - c)); return clamp(1 - d / w); }; const s = Math.max(bump(0.27, 0.15), bump(0.8, 0.15)); return s * s * (3 - 2 * s); };
-/** The waist's height (negative, above the ground at 0) at this point of the stride: on its feet in the stances, carried through the air between. */
-export const gallopY = (ph: number, rig = gallopRig(ph)): number => { const l = lowest(fk(rig, 0, 0, 0)), contact = -Math.max(l.fore, l.hind), air = Math.min(contact, -cyc(BODY, ph)[4]); return lerp(air, contact, stance(ph)); };
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts
deleted file mode 100644
index 441971c..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRun.ts
+++ /dev/null
@@ -1,210 +0,0 @@
-// CHEETAH, RUN. 27 s, looping. It is cheetahDusk with a run opened up in the middle of it, in one
-// continuous shot with no cut and no wipe.
-// The story in three sentences: She wakes at dusk. She stretches and runs across the whole country
-// for the joy of it. She stops, turns back to us, and the night closes over, ready to begin again.
-// The token: the low sun, which stays put through every move while everything nearer goes by.
-// The two moves the film is for:
-// THE TURN. The camera pulls back from the face and comes round to her side in one move. The face
-// is the same drawing, wrapped on a head and turned in space (cheetahTurn); her body swings out
-// from behind it, edge-on at first, as the ground comes up under her feet. Back the same way.
-// THE RUN. She is held in frame and the country goes by in layers at their own speeds, and it
-// changes as she covers ground: thorn savanna, a kopje where the birds go up, a shallow pan she
-// goes through in spray, grass again (cheetahScenery).
-// The picture is timed in frames on a 120 bpm grid (a beat is 15 frames, and so is a stride); the
-// score is nine bars at 80 bpm, the same 27 s.
-// 0-255 cheetahDusk 0-255: night, the sun, the face making itself, the eyes, alive, a blink
-// 255-300 the turn: front to side, pulling back
-// 300-390 the stretch: down into the bow (338), held and deepened, up again (390)
-// 390-405 she gathers
-// 405-575 the run: off the hind legs at 405, at speed by 450, a stride every 15 frames
-// 575-630 forefeet braced, the slide, the dust goes past her, she stands
-// 648-690 the turn back
-// 690-810 cheetahDusk 262-360: the face, the camera into the eye, the night. 809 hands over to 0.
-import { rng, type Ctx, type Env, type Layer, type P } from "./core";
-import type { Film } from "./film";
-import { mix } from "./gallery";
-import { drawCheetah, headAnchor, type Pose } from "./cheetahBody";
-import { camAt, drawDusk, DUSK_PALE, duskGrass, duskNight, FACE } from "./cheetahDusk";
-import { logoCentred, setType } from "./kinetic";
-import { cheetahRunScore, cheetahRunSignedScore } from "./music/pieces/cheetahRun";
-import { renderLoop, renderPiece } from "./music/render";
-import { BOW, CROUCH, fk, gallopRig, gallopY, lowest, mixRig, settle, SKID, STAND, type Rig } from "./cheetahRig";
-import { country, drawBurst, drawFar, drawFlock, drawLens, drawPan, inPan, leaf, type Burst } from "./cheetahScenery";
-import { HEAD_K, turnedHead, turnedNeck } from "./cheetahTurn";
-
-const W = 1080, H = 1080, N = 810, GROUND = 852, FLOOR = GROUND + 24;
-const NIGHT = "#0d1a22", TEAL = "#2a6a70", RUST = "#b8452a", PALE = "#fff5de", DARK = "#0a1216";
-const clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v));
-const ramp = (f: number, a: number, b: number) => clamp((f - a) / (b - a));
-const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
-const inOut = (t: number) => { const c = clamp(t); return c < 0.5 ? 4 * c * c * c : 1 - Math.pow(-2 * c + 2, 3) / 2; };
-const out3 = (t: number) => 1 - Math.pow(1 - clamp(t), 3);
-const smooth = (t: number) => { const c = clamp(t); return c * c * (3 - 2 * c); };
-const back = (t: number) => { const c = clamp(t) - 1; return 1 + 2.4 * c * c * c + 1.4 * c * c; };
-
-// ---------------------------------------------------------------- the cue table (frames)
-const CUE = { swing: 255, side: 300, bow: 338, hold: 362, up: 390, go: 405, speed: 450, brake: 575, slid: 606, stood: 630, swingBack: 648, face: 690, eye: 720 } as const;
-const STRIDE = 15, PH0 = 0.82; // a stride in frames; where in the stride she leaves the ground at CUE.go
-const phase = (F: number) => PH0 + (F - CUE.go) / STRIDE;
-// how fast the ground goes by (0-1), and how far it has gone. The far total is chosen so the near
-// grass, which is cheetahDusk's own, is back exactly where that film left it when she stops.
-const pace = (F: number) => smooth(ramp(F, CUE.go, CUE.speed)) * (1 - smooth(ramp(F, CUE.brake - 12, CUE.slid)));
-const NEAR = 1.6, WRAP = 1400, TOP = 84; // the near grass's depth factor and its wrap; her top speed in px of ground per frame
-const TRAVEL = (() => { const sub = 8, acc = [0]; for (let i = 1; i <= N * sub; i++) acc.push(acc[i - 1] + pace((i - 0.5) / sub) / sub); const total = acc[acc.length - 1], want = (Math.round((total * TOP * NEAR) / WRAP) * WRAP) / NEAR, k = want / (total * TOP); return (F: number) => { const x = clamp(F, 0, N) * sub, i = Math.min(N * sub - 1, Math.floor(x)); return lerp(acc[i], acc[i + 1], x - i) * TOP * k; }; })(); // px of ground gone by
-const LAND = country(TRAVEL(N));
-const frameAt = (g: number) => { let a: number = CUE.go, b: number = CUE.slid; for (let i = 0; i < 24; i++) { const m = (a + b) / 2; if (TRAVEL(m) < g) a = m; else b = m; } return b; };
-
-// ---------------------------------------------------------------- her performance
-const S = { stand: settle(STAND), bow: settle(BOW), crouch: settle(CROUCH), skid: settle(SKID) };
-const HIND_X = 400, TRACK_X = 548; // where her hind foot stands on screen; where the camera holds her waist as she runs
-const idle = (r: Rig, F: number): Rig => ({ ...r, headH: r.headH + Math.sin(F * (Math.PI / 45)) * 2.5, tail: r.tail.map((a, i) => a + Math.sin(F * (Math.PI / 30) - i * 0.7) * (2 + i * 2.2)) });
-const held = (F: number): Rig => { // every pose she holds, and the moves between them
- if (F < CUE.side) return S.stand.rig;
- if (F < CUE.bow) return mixRig(S.stand.rig, S.bow.rig, inOut(ramp(F, CUE.side, CUE.bow)));
- if (F < CUE.hold) { const d = Math.sin(ramp(F, CUE.bow, CUE.hold) * Math.PI), q = Math.sin(F * 1.9) * d; return { ...S.bow.rig, lumb: S.bow.rig.lumb - 7 * d, headH: S.bow.rig.headH + 14 * d, head: S.bow.rig.head - 6 * d, tail: S.bow.rig.tail.map((a, i) => a + q * i * 1.6 + d * i * 3) }; }
- if (F < CUE.up) return mixRig(S.bow.rig, S.stand.rig, back(ramp(F, CUE.hold, CUE.up)));
- if (F < CUE.go) return mixRig(S.stand.rig, S.crouch.rig, inOut(ramp(F, CUE.up, CUE.go)));
- return mixRig(S.skid.rig, S.stand.rig, back(ramp(F, CUE.slid, CUE.stood)));
-};
-const standing = (F: number) => { const s = settle(idle(held(F), F)), q = fk(s.rig, 0, s.y, 0); return { rig: s.rig, y: s.y, x: HIND_X - q.hindN[4][0] }; };
-const lead = (F: number) => 46 * Math.sin(ramp(F, CUE.go, CUE.speed + 30) * Math.PI) - 40 * Math.sin(ramp(F, CUE.brake - 6, CUE.stood) * Math.PI);
-const poseAt = (F: number): Pose => {
- if (F < CUE.go || F >= CUE.slid) { const s = standing(F); return fk(s.rig, s.x + (F >= CUE.slid ? lerp(60, 0, smooth(ramp(F, CUE.slid, CUE.stood + 20))) + lead(F) : 0), s.y + FLOOR, FLOOR); }
- // running: the stride, taken up out of the crouch and given back to the braced stop
- const ph = phase(F), g = gallopRig(ph), a = standing(CUE.go - 0.001), b = standing(CUE.slid), wIn = out3(ramp(F, CUE.go, CUE.go + 9)), wOut = inOut(ramp(F, CUE.brake, CUE.brake + 13));
- let rig = mixRig(a.rig, g, wIn), y = lerp(a.y, gallopY(ph, g), wIn), x = lerp(a.x, TRACK_X, smooth(ramp(F, CUE.go, CUE.go + 24)));
- if (wOut > 0) { rig = mixRig(rig, b.rig, wOut); y = lerp(y, b.y, wOut); x = lerp(x, b.x + 60, wOut); }
- const l = lowest(fk(rig, 0, y, 0)), sink = Math.max(l.fore, l.hind); if (sink > 0) y -= sink; // never through the ground
- return fk(rig, x + lead(F), y + FLOOR, FLOOR);
-};
-// what her feet throw up, each where it was made on the ground: a kick at every footfall, a long cloud from the braced stop
-const BURSTS = (() => {
- const out: (Burst & { born: number; g: number })[] = [];
- const add = (born: number, x: number, big: number, seed: number) => { const g = TRAVEL(born) + (x - 540); out.push({ born, g, x, y: FLOOR, age: 0, seed, wet: inPan(LAND, g), big }); };
- for (let n = 0; n < 13; n++) for (const [ph, fore] of [[0.2, true], [0.68, false]] as const) { const born = CUE.go + (n + ph - PH0) * STRIDE; if (born < CUE.go + 2 || born > CUE.brake + 2) continue; const q = poseAt(born); add(born, fore ? q.foreN[4][0] : q.hindN[4][0], fore ? 0.85 : 1.25, 300 + n * 2 + (fore ? 1 : 0)); }
- for (let i = 0; i < 9; i++) { const born = CUE.brake + 3 + i * 3.5, q = poseAt(born); add(born, q.foreN[4][0] + 10, 1.9 - i * 0.08, 500 + i); }
- return out;
-})();
-const bursts = (c: Ctx, F: number, wet: boolean) => { const X = TRAVEL(F); for (const b of BURSTS) if (b.wet === wet && F >= b.born && F < b.born + 20) drawBurst(c, { ...b, x: b.x - (X - TRAVEL(b.born)) * (wet ? 1 : 0.92), age: F - b.born }); };
-// the frame takes a small knock as each pair of feet comes down
-const knock = (F: number) => { if (F < CUE.go || F > CUE.brake + 20) return 0; const ph = (((phase(F) % 1) + 1) % 1), since = Math.min((ph - 0.2 + 1) % 1, (ph - 0.68 + 1) % 1) * STRIDE; return 4.5 * pace(F) * Math.exp(-since / 2.4) * Math.cos(since * 1.9); };
-
-// ---------------------------------------------------------------- the world
-// cheetahDusk's blade, mark for mark, so the grass is one grass across both seams
-const blade = (c: Ctx, o: P, a: number, len: number, w: number, col: string) => {
- if (len < 1.5 || w < 0.6) return;
- const ca = Math.cos(a), sa = Math.sin(a), t: P = [o[0] + ca * len, o[1] + sa * len], m = len * 0.42, mx = o[0] + ca * m, my = o[1] + sa * m;
- const g = c.createLinearGradient(o[0], o[1], t[0], t[1]); g.addColorStop(0, mix(col, DARK, 0.6)); g.addColorStop(0.45, col); g.addColorStop(1, mix(col, "#ffffff", 0.16));
- c.fillStyle = g; c.beginPath(); c.moveTo(o[0], o[1]); c.quadraticCurveTo(mx - sa * w, my + ca * w, t[0], t[1]); c.quadraticCurveTo(mx + sa * w, my - ca * w, o[0], o[1]); c.fill();
-};
-const wrap = (x: number, span: number, lo: number) => ((((x - lo) % span) + span) % span) + lo;
-const SCENE = (() => {
- const q = rng(3);
- // the near grass: cheetahDusk's seventy blades where that film has them, and more beyond its frame for when the camera is further back
- const more = rng(43), near = [...duskGrass, ...Array.from({ length: 22 }, (_, i) => ({ x: i % 2 ? -160 + more() * 160 : W + more() * 160, h: 90 + more() * 220, a: (more() - 0.5) * 0.5, w: 9 + more() * 8, col: more() < 0.15 ? TEAL : mix(NIGHT, TEAL, more() * 0.5), ph: more() * 6.28 }))];
- const far = Array.from({ length: 150 }, () => ({ x: q() * 1320, h: 26 + q() * 60, w: 5 + q() * 5, col: mix(NIGHT, TEAL, q() * 0.55), dy: q() * 10, a: (q() - 0.5) * 0.5, ph: q() * 6.28 }));
- const streaks = Array.from({ length: 34 }, () => ({ x: q() * 2200, y: 700 + q() * 150, len: 140 + q() * 420, w: 2.2 + q() * 4.5, col: mix(RUST, NIGHT, 0.35 + q() * 0.5), al: 0.3 + q() * 0.3 }));
- const flecks = Array.from({ length: 14 }, () => ({ x: q() * 2600, y: 880 + q() * 180, len: 200 + q() * 300, w: 1.4 + q() * 1.6, al: 0.1 + q() * 0.14 }));
- return { near, far, streaks, flecks };
-})();
-const SIDE_CAM = { z: 410 / 470, look: [540, 430 - 8 / (410 / 470)] as P }; // the sun where the look still has it: (540, 548), radius 410
-const PIVOT: P = [540, FLOOR - 130];
-// a camera of its own for the side: in on her for the stretch, back out to give the run its room, in a little as she flies
-const push = (F: number) => 1 + 0.26 * inOut(ramp(F, CUE.side, CUE.bow)) * (1 - inOut(ramp(F, CUE.up - 6, CUE.go + 22))) + 0.07 * smooth(ramp(F, CUE.speed, CUE.speed + 45)) * (1 - smooth(ramp(F, CUE.brake - 30, CUE.brake))) + 0.12 * inOut(ramp(F, CUE.slid, CUE.stood + 6)) * (1 - inOut(ramp(F, CUE.swingBack - 18, CUE.swingBack)));
-
-const grainLayer = (env: Env): Layer => { // the paper's tooth and the dusk settling at the edges: cheetahDusk's, grain for grain
- const key = "cheetahRun:grain"; let L = env.cache.get(key) as Layer | undefined; if (L) return L;
- L = env.canvas(Math.round(W * env.scale), Math.round(H * env.scale)); env.cache.set(key, L);
- const c = L.ctx, q = rng(77); c.setTransform(env.scale, 0, 0, env.scale, 0, 0);
- for (let i = 0; i < 200000; i++) { const x = q() * W, y = q() * H, d = Math.hypot(x - 540, y - 520) / 740; if (q() > d * d * d * 1.1) continue; c.fillStyle = DARK; c.globalAlpha = 0.42; c.fillRect(x, y, 1.1, 1.1); }
- for (let i = 0; i < 30000; i++) { const x = q() * W, y = q() * H, lt = q() < 0.5; c.fillStyle = lt ? "#fff5de" : "#000000"; c.globalAlpha = lt ? 0.06 : 0.08; c.fillRect(x, y, 1.1, 1.1); }
- return L;
-};
-
-const side = (ctx: Ctx, F: number, env: Env) => {
- const c = ctx, s = env.scale, out = F < CUE.swingBack, w = out ? ramp(F, CUE.swing, CUE.side) : 1 - ramp(F, CUE.swingBack, CUE.face), e = inOut(w), turning = w < 1;
- // cheetahDusk's world through a camera that pulls back as it comes round: its sun stays, far off
- const tau = out ? lerp(255, 262, ramp(F, CUE.swing, CUE.side)) : 262, d = camAt(tau), Z = push(F), zz = Math.exp(lerp(Math.log(d.z), Math.log(SIDE_CAM.z), e)) * Z;
- const cam = { z: zz, look: [lerp(d.look[0], SIDE_CAM.look[0], e) + ((PIVOT[0] - 540) * (Z - 1)) / zz, lerp(d.look[1], SIDE_CAM.look[1], e) + ((PIVOT[1] - 540) * (Z - 1)) / zz] as P };
- drawDusk(c, tau, env, { cam, world: F, face: false, grass: false, grain: false });
- // her, and how the turn places her: the head's centre on screen, its size, how far round we are
- const pose = poseAt(F), anchor = headAnchor(pose), yaw = (Math.PI / 2) * e, k0 = d.z, k = Math.exp(lerp(Math.log(k0), Math.log(HEAD_K), e)), kb = k / HEAD_K, sx = Math.sin(yaw);
- const P0: P = [(FACE[0] - d.look[0]) * d.z + 540, (FACE[1] - d.look[1]) * d.z + 540], hc: P = [lerp(P0[0], anchor[0], e), lerp(P0[1], anchor[1], e)];
- // the ground comes up under her as the camera pulls back: everything that stands on it rides on this line
- const drop = turning ? hc[1] + (FLOOR - anchor[1]) * kb - FLOOR : 0, shake = knock(F);
- const screen = () => c.setTransform(s * Z, 0, 0, s * Z, s * PIVOT[0] * (1 - Z), s * (PIVOT[1] * (1 - Z) + drop + shake));
- const v = pace(F), X = TRAVEL(F), lean = smooth(v);
- if (drop < 1400) {
- screen();
- drawFar(c, LAND, X, F, GROUND, lean);
- drawFlock(c, LAND, X, F, GROUND, frameAt);
- for (const g of SCENE.streaks) leaf(c, wrap(g.x - X * 0.8, 2200, -500) + g.len, g.y, Math.PI, g.len * (0.4 + 0.6 * v), g.w, g.col, g.al * v);
- c.fillStyle = mix(NIGHT, DARK, 0.35); c.fillRect(-40, GROUND, W + 80, H - GROUND + 400);
- for (const g of SCENE.far) leaf(c, wrap(g.x - X, 1320, -120), GROUND + 6 + g.dy, -Math.PI / 2 + g.a * (1 - lean) + Math.sin(F * (Math.PI / 45) + g.ph) * 0.06 * (1 - lean) - lean * 1.1, g.h * (1 + lean * 0.35), g.w, g.col);
- drawPan(c, LAND, X, F, GROUND, v);
- }
- const SWAP = 0.64; // past this point of the turn the head is small and nearly side-on, and the profile head takes over
- // the chest under the face goes first: it is a front, and a front narrows away and sinks behind her as we come round
- if (turning && yaw < 0.36) { c.save(); c.setTransform(s, 0, 0, s, 0, 0); c.beginPath(); c.rect(-10, -10, hc[0] + 240 * k * Math.cos(yaw) + 10, H + 20); c.clip(); turnedNeck(c, env, out ? 255 : 262, yaw, hc[0], hc[1] + (1 - Math.cos(yaw)) * 1500 * k, k); c.restore(); }
- if (sx > 0.03) {
- // her body: edge-on behind the face at first, its full length by the time we are beside her
- if (turning) c.setTransform(s * kb * sx, 0, 0, s * kb, s * (hc[0] - anchor[0] * kb * sx), s * (hc[1] - anchor[1] * kb)); else screen();
- const l = lowest(pose), air = clamp((FLOOR - Math.max(l.fore, l.hind)) / 60), x0 = pose.spine[0][0], x1 = pose.spine[9][0];
- for (let i = 0; i < 5; i++) { c.fillStyle = DARK; c.globalAlpha = 0.2 * (1 - air * 0.45); c.beginPath(); c.ellipse((x0 + x1) / 2 + 20, FLOOR + 8, ((x1 - x0) * 0.62 + 40) * (1 - i * 0.11) * (1 - air * 0.12), 15 - i * 2.1, 0, 0, Math.PI * 2); c.fill(); }
- c.globalAlpha = 1;
- bursts(c, F, false);
- drawCheetah(c, pose, turning && w < SWAP ? { head: false } : {});
- bursts(c, F, true);
- }
- if (turning && w < SWAP) turnedHead(c, env, out ? 255 : 262, yaw, hc[0], hc[1], k);
- // the near grass, in cheetahDusk's own camera: its blades, swept over and streaming while she runs
- c.setTransform(s * cam.z, 0, 0, s * cam.z, s * (540 - cam.look[0] * cam.z), s * (540 - cam.look[1] * cam.z));
- for (const g of SCENE.near) blade(c, [wrap(g.x - X * NEAR, WRAP, -160), H + 20], -Math.PI / 2 + g.a * (1 - lean * 0.8) + Math.sin(F * (Math.PI / 45) + g.ph) * 0.07 - lean * 1.02, g.h * (1 + lean * 0.45), g.w, g.col);
- screen();
- drawLens(c, LAND, X, H);
- for (const g of SCENE.flecks) leaf(c, wrap(g.x - X * 2.1, 2600, -600) + g.len, g.y, Math.PI, g.len, g.w, PALE, g.al * v);
- c.setTransform(1, 0, 0, 1, 0, 0); c.globalAlpha = 1; c.drawImage(grainLayer(env).canvas, 0, 0);
-};
-
-const draw = (ctx: Ctx, F: number, env: Env) => {
- if (F < CUE.swing) return drawDusk(ctx, F, env);
- if (F < CUE.face) return side(ctx, F, env);
- drawDusk(ctx, F < CUE.eye ? lerp(262, 270, ramp(F, CUE.face, CUE.eye)) : F - 450, env, { world: F });
-};
-
-// the score: nine bars at 80 bpm are the film's 27 s exactly, so the loop is the music's own
-const audio = (sr: number): [Float32Array, Float32Array] => {
- const n = Math.round((N / 30) * sr), L = new Float32Array(n), R = new Float32Array(n), m = renderLoop(cheetahRunScore(), sr); // its tail folded back onto its start: no cut at the seam
- for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }
- return [L, R];
-};
-
-export const cheetahRun: Film = {
- meta: { title: "Cheetah, run", W, H, fps: 30, bpm: 120, durationFrames: N, raster: "cpu", kind: "loop", poster: 500, score: { tempo: 80, form: "9 bars of 12/8, looping: drone and cell, the cycle enters, one long note, held breath and go, the cell in her stride, the stop, home" }, sync: [{ frame: 405, label: "she goes" }, { frame: 575, label: "forefeet braced" }] },
- assets: { images: {} },
- shots: [{ id: "run", start: 0, end: N, draw }],
- audio: Object.assign(audio, { scores: [cheetahRunScore()] }),
-};
-
-// ---------------------------------------------------------------- the signed cut, for posting
-// The loop played once, then four seconds on the night it ends in: the wordmark is written in the
-// sky in the moon's own white, its dot landing on the score's last note, and the address is set
-// under it. The stars and the grass keep moving; nothing else is added to the picture.
-const END = N + 120, SIGN = { write: N + 10, dot: N + 38, url: N + 48, set: N + 66 };
-const signed = (ctx: Ctx, F: number, env: Env) => {
- if (F < N) return draw(ctx, F, env);
- duskNight(ctx, F - 450, env);
- logoCentred(ctx, env, 540, 452, 92, ramp(F, SIGN.write, SIGN.write + (SIGN.dot - SIGN.write) / 0.9), { color: DUSK_PALE, pen: false });
- setType(ctx, env, "github.com/alexgreensh/anidoodle", 540, 628, 34, ramp(F, SIGN.url, SIGN.set), { color: DUSK_PALE, align: "center", weight: 600, track: 0.01 });
-};
-const signedAudio = (sr: number): [Float32Array, Float32Array] => {
- const n = Math.round((END / 30) * sr), L = new Float32Array(n), R = new Float32Array(n), m = renderPiece(cheetahRunSignedScore(), sr);
- for (let i = 0; i < n && i < m.L.length; i++) { L[i] = m.L[i]; R[i] = m.R[i]; }
- return [L, R];
-};
-export const cheetahRunSigned: Film = {
- meta: { title: "Cheetah, run (signed)", W, H, fps: 30, bpm: 120, durationFrames: END, raster: "cpu", kind: "story", poster: 500, score: { tempo: 80, form: "the nine bars once, then a tenth that closes them: the cell lands on the tonic and rings" }, sync: [{ frame: 405, label: "she goes" }, { frame: 575, label: "forefeet braced" }] },
- assets: { images: {} },
- shots: [{ id: "run", start: 0, end: END, draw: signed }],
- audio: Object.assign(signedAudio, { scores: [cheetahRunSignedScore()] }),
-};
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRunSigned.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRunSigned.ts
deleted file mode 100644
index 188015c..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahRunSigned.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// The signed cut of "Cheetah, run", for posting: the film once, then the wordmark and the address on the night it ends in.
-export { cheetahRunSigned } from "./cheetahRun";
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts
deleted file mode 100644
index 85928ea..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahScenery.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-// THE COUNTRY SHE RUNS THROUGH. Speed is read from the world, so the world is in layers at their own
-// distances, and each goes by at its own rate: the sun does not move at all, the far range creeps,
-// the acacias drift, the scrub and rocks pass, the grass at her feet streams, and now and then
-// something close to the lens whips across the whole frame. It is also a journey, not a treadmill:
-// what she passes changes as the ground goes by under her.
-// the thorn savanna (acacias, termite mounds) · a kopje (boulders, dead trees; the birds go up
-// here) · a shallow pan (water, reeds, the sun laid down in it, spray off her feet) · grass again.
-// Every element has a place on the ground, G, in px of ground travelled; a layer at depth factor f
-// puts it on screen at 540 + (G - X) * f, where X is how far she has run. Nothing wraps, nothing repeats.
-import { rng, type Ctx, type P } from "./core";
-import { mix } from "./gallery";
-
-const NIGHT = "#0d1a22", TEAL = "#2a6a70", RUST = "#b8452a", CORAL = "#f2643c", PALE = "#fff5de", DARK = "#0a1216", OCHRE = "#e3a23a";
-const clamp = (v: number, a = 0, b = 1) => Math.max(a, Math.min(b, v));
-const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
-export const leaf = (c: Ctx, x: number, y: number, a: number, len: number, w: number, col: string, alpha = 1) => {
- if (alpha <= 0.004 || len < 1) return;
- const ca = Math.cos(a), sa = Math.sin(a), tx = x + ca * len, ty = y + sa * len, mx = x + ca * len * 0.42, my = y + sa * len * 0.42;
- c.globalAlpha = alpha; c.fillStyle = col; c.beginPath(); c.moveTo(x, y); c.quadraticCurveTo(mx - sa * w, my + ca * w, tx, ty); c.quadraticCurveTo(mx + sa * w, my - ca * w, x, y); c.fill(); c.globalAlpha = 1;
-};
-const UP = -Math.PI / 2;
-
-// ---------------------------------------------------------------- the things that stand in it
-// an umbrella thorn: a leaning trunk, a fork of boughs, and the flat crown laid in tiers
-const acacia = (c: Ctx, x: number, base: number, h: number, seed: number, col: string, lit: string) => {
- const q = rng(seed), lean = (q() - 0.5) * 0.3, fx = x + lean * h * 0.4, fy = base - h * 0.5;
- leaf(c, x, base + 4, UP + lean * 0.8, h * 0.58, h * 0.055, col);
- for (const a of [-1.0, -0.45, 0.2, 0.8]) { const ang = UP + a + (q() - 0.5) * 0.2, len = h * (0.42 + q() * 0.16), tx = fx + Math.cos(ang) * len, ty = fy + Math.sin(ang) * len; leaf(c, fx, fy, ang, len, h * 0.026, col); const w = h * (0.34 + q() * 0.2); for (let k = 0; k < 3; k++) leaf(c, tx - w * (0.5 + (q() - 0.5) * 0.3), ty - k * h * 0.03 + q() * 4, 0, w * (1 - k * 0.18), h * (0.05 - k * 0.008), k === 2 ? lit : col); }
-};
-const deadTree = (c: Ctx, x: number, base: number, h: number, seed: number, col: string) => { const q = rng(seed), lean = (q() - 0.5) * 0.3; leaf(c, x, base + 4, UP + lean, h, h * 0.05, col); for (let k = 0; k < 5; k++) { const t = 0.35 + q() * 0.55, sd = k % 2 ? 1 : -1; leaf(c, x + Math.cos(UP + lean) * h * t, base + Math.sin(UP + lean) * h * t, UP + lean + sd * (0.5 + q() * 0.6), h * (0.2 + q() * 0.25), h * 0.016, col); } };
-const mound = (c: Ctx, x: number, base: number, h: number, col: string) => { leaf(c, x, base + 6, UP, h, h * 0.42, col); leaf(c, x + h * 0.2, base + 6, UP + 0.12, h * 0.6, h * 0.3, col); };
-const bush = (c: Ctx, x: number, base: number, h: number, seed: number, col: string, lit: string) => { const q = rng(seed); for (let k = 0; k < 9; k++) leaf(c, x + (q() - 0.5) * h * 0.5, base + 5, UP + (k / 8 - 0.5) * 1.9 + (q() - 0.5) * 0.2, h * (0.6 + q() * 0.4), h * 0.2, k % 4 === 0 ? lit : col); };
-// boulders: each a lens lying on the one below it
-const kopje = (c: Ctx, x: number, base: number, h: number, seed: number, col: string, lit: string) => { const q = rng(seed); for (let k = 0; k < 5; k++) { const w = h * (1.1 - k * 0.17) * (0.8 + q() * 0.4), ox = (q() - 0.5) * h * 0.5, y = base - k * h * 0.2 - h * 0.06; leaf(c, x + ox - w / 2, y, 0, w, h * (0.34 - k * 0.03), k === 4 ? lit : col); } };
-const reeds = (c: Ctx, x: number, base: number, h: number, seed: number, col: string, F: number, lean: number) => { const q = rng(seed); for (let k = 0; k < 7; k++) { const a = UP + (q() - 0.5) * 0.4 + Math.sin(F * (Math.PI / 45) + k) * 0.05 - lean * 0.7, len = h * (0.6 + q() * 0.4), ox = (q() - 0.5) * h * 0.4; leaf(c, x + ox, base + 5, a, len, 3.2, col); if (k % 2) leaf(c, x + ox + Math.cos(a) * len * 0.82, base + 5 + Math.sin(a) * len * 0.82, a, len * 0.2, 5.5, mix(col, OCHRE, 0.35)); } };
-
-// ---------------------------------------------------------------- where everything stands
-export type Country = ReturnType<typeof country>;
-/** Lay the country out along `total` px of ground. */
-export const country = (total: number) => {
- const z = (g: number) => (g < total * 0.31 ? "thorn" : g < total * 0.6 ? "kopje" : g < total * 0.86 ? "pan" : "grass");
- const q = rng(911), span = (f: number) => [-760 / f, total + 760 / f] as const;
- type Item = { g: number; h: number; seed: number; kind: string };
- const scatter = (f: number, gap: (zone: string) => number, kind: (zone: string, r: number) => string, h: (kind: string, r: number) => number): Item[] => { const [a, b] = span(f), out: Item[] = []; for (let g = a; g < b; ) { const zone = z(g), k = kind(zone, q()); out.push({ g, h: h(k, q()), seed: Math.floor(q() * 1e6), kind: k }); g += gap(zone) * (0.55 + q() * 0.9); } return out; };
- const trees = scatter(0.22, (zn) => (zn === "thorn" ? 1150 : zn === "kopje" ? 1900 : zn === "pan" ? 4200 : 1500), (zn, r) => (zn === "kopje" && r < 0.55 ? "dead" : "acacia"), (k, r) => (k === "dead" ? 190 + r * 130 : 240 + r * 190));
- const mid = scatter(0.5, (zn) => (zn === "pan" ? 430 : zn === "kopje" ? 520 : 640), (zn, r) => (zn === "thorn" ? (r < 0.4 ? "mound" : "bush") : zn === "kopje" ? (r < 0.7 ? "kopje" : "bush") : zn === "pan" ? "reeds" : "bush"), (k, r) => (k === "mound" ? 95 + r * 85 : k === "kopje" ? 130 + r * 130 : k === "reeds" ? 105 + r * 75 : 62 + r * 52));
- const lens = [0.1, 0.27, 0.43, 0.57, 0.7, 0.83, 0.93].map((t, i) => ({ g: total * t + (q() - 0.5) * 300, seed: 40 + i, kind: i % 3 === 1 ? "trunk" : "grass" }));
- const flock = Array.from({ length: 18 }, () => ({ dx: (q() - 0.5) * 520, t0: q() * 9, vx: -1 + q() * 5, vy: 5 + q() * 6, size: 0.7 + q() * 0.6, ph: q() * 6.28 }));
- return { total, zone: z, trees, mid, lens, flock, flockG: total * 0.37, pan: [total * 0.6 + 260, total * 0.86 - 260] as const };
-};
-
-// ---------------------------------------------------------------- drawing it, back to front
-const ridge = (c: Ctx, X: number, f: number, horizon: number, h0: number, h1: number, ph: number, col: string) => {
- c.fillStyle = col; c.beginPath(); c.moveTo(-20, horizon + 30);
- for (let x = -20; x <= 1100; x += 14) { const u = x + X * f + ph, n = 0.5 + 0.5 * (Math.sin(u / 211) * 0.5 + Math.sin(u / 97 + 1.7) * 0.3 + Math.sin(u / 43 + 0.6) * 0.2), peak = Math.pow(n, 1.6); c.lineTo(x, horizon - lerp(h0, h1, peak)); }
- c.lineTo(1100, horizon + 30); c.closePath(); c.fill();
-};
-/** Everything behind her: the two ranges, the trees, the scrub and rocks. `horizon` is the ground line on screen. */
-export const drawFar = (c: Ctx, w: Country, X: number, F: number, horizon: number, lean: number) => {
- ridge(c, X, 0.03, horizon, 40, 170, 0, mix(CORAL, NIGHT, 0.6));
- ridge(c, X, 0.075, horizon, 16, 92, 900, mix(RUST, NIGHT, 0.8));
- const tree = mix(NIGHT, TEAL, 0.1), treeLit = mix(RUST, NIGHT, 0.55), near = mix(NIGHT, TEAL, 0.2), nearLit = mix(TEAL, NIGHT, 0.45);
- for (const t of w.trees) { const x = 540 + (t.g - X) * 0.22; if (x < -260 || x > 1340) continue; if (t.kind === "dead") deadTree(c, x, horizon, t.h, t.seed, tree); else acacia(c, x, horizon, t.h, t.seed, tree, treeLit); }
- for (const m of w.mid) { const x = 540 + (m.g - X) * 0.5; if (x < -200 || x > 1280) continue; if (m.kind === "mound") mound(c, x, horizon, m.h, mix(RUST, NIGHT, 0.72)); else if (m.kind === "kopje") kopje(c, x, horizon, m.h, m.seed, near, mix(RUST, NIGHT, 0.6)); else if (m.kind === "reeds") reeds(c, x, horizon, m.h, m.seed, nearLit, F, lean); else bush(c, x, horizon, m.h, m.seed, near, nearLit); }
-};
-/** The pan: shallow water lying on the ground she runs over, with the sun laid down in it. */
-export const drawPan = (c: Ctx, w: Country, X: number, F: number, horizon: number, v: number) => {
- const a = 540 + (w.pan[0] - X), b = 540 + (w.pan[1] - X); if (b < -40 || a > 1120) return;
- const x0 = Math.max(-20, a), x1 = Math.min(1100, b), y0 = horizon + 8, y1 = horizon + 86;
- c.save(); c.beginPath(); c.moveTo(x0 - (a > -20 ? 60 : 0), y1); c.lineTo(x0, y0); c.lineTo(x1, y0); c.lineTo(x1 + (b < 1100 ? 60 : 0), y1); c.closePath(); c.clip();
- c.fillStyle = mix(TEAL, NIGHT, 0.52); c.fillRect(-80, y0, 1240, y1 - y0);
- const q = rng(70);
- // the sun in it, in broken bars under the sun itself; then the ripples going by
- for (let i = 0; i < 26; i++) { const yy = y0 + 4 + q() * (y1 - y0 - 8), half = 70 + q() * 230 * (1 - (yy - y0) / (y1 - y0) * 0.5), dx = (q() - 0.5) * 60 + Math.sin(F * 0.21 + i) * 9; leaf(c, 540 + dx - half, yy, 0, half * 2, 2.2 + q() * 2.6, i % 3 ? CORAL : "#ff8a4a", 0.5 + q() * 0.35); }
- for (let i = 0; i < 30; i++) { const gx = q() * 2400, yy = y0 + 3 + q() * (y1 - y0 - 6), len = 60 + q() * 200; leaf(c, ((((gx - X) % 2400) + 2400) % 2400) - 600, yy, 0, len * (1 + v), 1.2 + q() * 1.4, PALE, 0.1 + q() * 0.16); }
- c.restore();
-};
-export const inPan = (w: Country, g: number) => g > w.pan[0] + 30 && g < w.pan[1] - 30;
-/** The birds she puts up as she comes through the kopje: out of the grass ahead of her, up and across the sun. */
-export const drawFlock = (c: Ctx, w: Country, X: number, F: number, horizon: number, frameAt: (g: number) => number) => {
- const t0 = frameAt(w.flockG - 700); if (F < t0) return;
- const col = mix(NIGHT, DARK, 0.4);
- for (const b of w.flock) {
- const t = F - t0 - b.t0; if (t < 0 || t > 110) continue;
- const x = 540 + (w.flockG - X) * 0.82 + b.dx + b.vx * t, y = horizon - 6 - b.vy * t * (1 - t / 260) - Math.sin(t * 0.25 + b.ph) * 6, flap = Math.sin(t * 0.85 + b.ph), s = 13 * b.size;
- if (x < -60 || x > 1140 || y < -40) continue;
- leaf(c, x, y, Math.PI + 0.25 + flap * 0.75, s * 1.5, s * 0.36, col); leaf(c, x, y, -0.25 - flap * 0.75, s * 1.5, s * 0.36, col); leaf(c, x - s * 0.5, y, 0, s, s * 0.22, col);
- }
-};
-/** What crosses close to the lens: a spray of grass, or a thorn trunk with a bough, dark and huge, gone in a few frames. */
-export const drawLens = (c: Ctx, w: Country, X: number, bottom: number) => {
- for (const o of w.lens) {
- const x = 540 + (o.g - X) * 3.1; if (x < -700 || x > 1780) continue;
- const q = rng(o.seed), col = mix(NIGHT, DARK, 0.55);
- if (o.kind === "trunk") { leaf(c, x - 60, bottom + 60, UP + 0.06, 1500, 150, col); leaf(c, x - 30, bottom - 620, UP + 1.05, 700, 46, col); leaf(c, x - 60, bottom - 760, UP - 0.9, 560, 38, col); }
- else for (let k = 0; k < 16; k++) leaf(c, x + (q() - 0.5) * 420, bottom + 60, UP - 0.75 + (q() - 0.5) * 0.5, 520 + q() * 560, 26 + q() * 30, k % 5 === 0 ? mix(TEAL, NIGHT, 0.6) : col);
- }
-};
-export type Burst = { x: number; y: number; age: number; seed: number; wet: boolean; big: number };
-/** What her feet throw up: dust off the plain, spray out of the pan. */
-export const drawBurst = (c: Ctx, b: Burst) => {
- const q = rng(b.seed), n = b.wet ? 16 : 11, life = b.wet ? 13 : 18, k = b.age / life; if (k < 0 || k > 1) return;
- for (let i = 0; i < n; i++) {
- const a = b.wet ? UP + (q() - 0.5) * 1.9 : Math.PI + 0.15 + q() * 0.95, sp = 0.4 + q() * 0.6, d = q();
- if (b.wet) { const vx = Math.cos(a) * 9 * sp * b.big, vy = Math.sin(a) * 15 * sp * b.big, t = b.age; leaf(c, b.x + vx * t, b.y + vy * t + 0.75 * t * t, Math.atan2(vy + 1.5 * t, vx), 9 + sp * 13, 2.4 + d * 1.6, d < 0.4 ? PALE : mix(PALE, TEAL, 0.45), 0.9 * (1 - k)); }
- else leaf(c, b.x - d * 70 * k * b.big, b.y - 4 - d * 56 * k * b.big, a, (24 + d * 58) * b.big * Math.min(1, k * 3), (7 + q() * 8) * b.big, mix(mix(OCHRE, PALE, 0.4), NIGHT, 0.12 + q() * 0.25), (0.62 - d * 0.15) * (1 - k));
- }
-};
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahTurn.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahTurn.ts
deleted file mode 100644
index 7df4fad..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/cheetahTurn.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-// THE HEAD THAT TURNS. cheetahDusk's face is a flat drawing; here it is wrapped onto a head (a ball,
-// with the muzzle standing out of it) and that head is turned about its upright axis, so the camera
-// can come round from the front to the side and it is the same face all the way: at yaw 0 it is the
-// drawing, untouched; by 90 degrees one eye and one tear line are left, the nose is the profile's
-// leading edge, and the back of the head has come round from behind, in the same coat.
-// How: the face is drawn once into a layer and laid over a grid of small triangles. Each corner of the
-// grid has a depth; turning moves it sideways by that depth; each triangle carries its piece of the
-// drawing across with an affine map. Nothing is generated and nothing is sampled from a clock.
-import { type Ctx, type Env, type Layer, type P } from "./core";
-import { duskFace, FACE } from "./cheetahDusk";
-
-const R = 372, SQ = 0.95, OVER = 1.25; // the head's radius in the drawing; its slight flattening; the layer's oversampling
-const X0 = 60, X1 = 1020, Y0 = 150, Y1 = 1070, NX = 34, NY = 32;
-type Part = "neck" | "coat" | "head";
-const layer = (env: Env, f: number, part: Part): Layer => {
- const key = `cheetahTurn:${part}:${f}`; let L = env.cache.get(key) as Layer | undefined; if (L) return L;
- const k = env.scale * OVER; L = env.canvas(Math.round(1080 * k), Math.round(1080 * k)); env.cache.set(key, L);
- L.ctx.setTransform(k, 0, 0, k, 0, 0); duskFace(L.ctx, f, part); L.ctx.setTransform(1, 0, 0, 1, 0, 0);
- return L;
-};
-const ball = (x: number, y: number) => { const dx = x - FACE[0], dy = (y - FACE[1]) / SQ, r2 = dx * dx + dy * dy; return r2 < R * R ? Math.sqrt(R * R - r2) : 0; };
-// the front of the head: the ball, and the muzzle pushed forward out of it below the eyes
-const front = (x: number, y: number) => ball(x, y) + 150 * Math.exp(-((x - 540) ** 2 + (y - 735) ** 2) / (2 * 105 * 105));
-const GRID = (() => { const g: { x: number; y: number; zf: number; zb: number; in: boolean }[] = []; for (let j = 0; j <= NY; j++) for (let i = 0; i <= NX; i++) { const x = X0 + ((X1 - X0) * i) / NX, y = Y0 + ((Y1 - Y0) * j) / NY, b = ball(x, y); g.push({ x, y, zf: front(x, y), zb: -b, in: b > 0 }); } return g; })();
-
-/** The head, turned by `yaw` radians (0 faces us, positive brings the nose round to the right), its centre at (cx, cy) on screen, drawn at scale k. */
-export const turnedHead = (c: Ctx, env: Env, f: number, yaw: number, cx: number, cy: number, k: number) => {
- const s = env.scale, cs = Math.cos(yaw), sn = Math.sin(yaw), head = layer(env, f, "head"), coat = layer(env, f, "coat");
- const put = (x: number, y: number, z: number): [number, number, number] => [cx + k * ((x - FACE[0]) * cs + z * sn), cy + k * (y - FACE[1]), -(x - FACE[0]) * sn + z * cs];
- const F = GRID.map((g) => put(g.x, g.y, g.zf)), B = yaw > 0.02 ? GRID.map((g) => put(g.x, g.y, g.zb)) : [];
- const tris: { img: Layer; a: number; b: number; c: number; v: [number, number, number][]; d: number }[] = [];
- for (let j = 0; j < NY; j++) for (let i = 0; i < NX; i++) {
- const p = j * (NX + 1) + i, q = p + 1, r = p + NX + 1, t = r + 1;
- for (const [a, b, cc] of [[p, q, r], [q, t, r]] as const) {
- const area = (v: [number, number, number][]) => (v[b][0] - v[a][0]) * (v[cc][1] - v[a][1]) - (v[cc][0] - v[a][0]) * (v[b][1] - v[a][1]);
- if (area(F) > 0.02 * k * k) tris.push({ img: head, a, b, c: cc, v: F, d: F[a][2] + F[b][2] + F[cc][2] }); // facing us
- if (B.length && GRID[a].in && GRID[b].in && GRID[cc].in && area(B) < -0.02 * k * k) tris.push({ img: coat, a, b, c: cc, v: B, d: B[a][2] + B[b][2] + B[cc][2] }); // the back, come round
- }
- }
- tris.sort((m, n) => m.d - n.d);
- const o = OVER;
- for (const t of tris) {
- const s0 = GRID[t.a], s1 = GRID[t.b], s2 = GRID[t.c], d0 = t.v[t.a], d1 = t.v[t.b], d2 = t.v[t.c];
- const ax = s1.x - s0.x, ay = s1.y - s0.y, bx = s2.x - s0.x, by = s2.y - s0.y, det = ax * by - bx * ay; if (!det) continue;
- const ux = d1[0] - d0[0], uy = d1[1] - d0[1], vx = d2[0] - d0[0], vy = d2[1] - d0[1];
- const m11 = (ux * by - vx * ay) / det, m12 = (vx * ax - ux * bx) / det, m21 = (uy * by - vy * ay) / det, m22 = (vy * ax - uy * bx) / det;
- const tx = d0[0] - m11 * s0.x - m12 * s0.y, ty = d0[1] - m21 * s0.x - m22 * s0.y;
- // clip to the triangle, grown a hair so neighbours leave no seam, then lay the drawing through the map
- const gx = (d0[0] + d1[0] + d2[0]) / 3, gy = (d0[1] + d1[1] + d2[1]) / 3, grow = (p: [number, number, number]): P => { const dx = p[0] - gx, dy = p[1] - gy, l = Math.hypot(dx, dy) || 1; return [p[0] + (dx / l) * 0.8, p[1] + (dy / l) * 0.8]; };
- const e0 = grow(d0), e1 = grow(d1), e2 = grow(d2);
- c.save(); c.setTransform(s, 0, 0, s, 0, 0); c.beginPath(); c.moveTo(e0[0], e0[1]); c.lineTo(e1[0], e1[1]); c.lineTo(e2[0], e2[1]); c.closePath(); c.clip();
- c.setTransform(m11 / o, m21 / o, m12 / o, m22 / o, s * tx, s * ty); c.drawImage(t.img.canvas, 0, 0); c.restore();
- }
-};
-
-/** The chest under the face, as cheetahDusk has it: a flat front that narrows away as the camera comes round. */
-export const turnedNeck = (c: Ctx, env: Env, f: number, yaw: number, cx: number, cy: number, k: number) => {
- const w = Math.cos(yaw) ** 2; if (w < 0.03) return;
- const s = env.scale, L = layer(env, f, "neck");
- c.save(); c.setTransform(s * k * w, 0, 0, s * k, s * (cx - FACE[0] * k * w), s * (cy - FACE[1] * k)); c.drawImage(L.canvas, 0, 0, 1080, 1080); c.restore();
-};
-/** The size the turned head must be drawn at to stand in for the profile head cheetahBody draws. */
-export const HEAD_K = 0.118;
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetah.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetah.ts
deleted file mode 100644
index 14652a1..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetah.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-// CHEETAH, DUSK: the score. Four bars at 80 bpm, exactly the film's 12 s, written to loop.
-// Chill lo-fi electronic in D major, a drifting IV-iii-vi-V: Gmaj9, F#m7, Bm9, A11.
-// BARS [film]: 1 pad and a first phrase, no drums [night, the sun comes up] · 2 the groove enters,
-// the phrase answers itself [the face makes itself] · 3 the phrase climbs, a high counter-line
-// joins [alive] · 4 half-time, the line falls back home [into the eye], and round again.
-import { type Piece } from "../plan";
-import { composePiece, type Material } from "../compose";
-
-export const cheetahDuskMaterial = (): Material => ({
- style: "lofiElectronic", title: "Cheetah, dusk", seed: 4107, mood: "calm", bpm: 80, key: "D", mode: "major", swing: 0.55, loop: true, tail: 1.2, levels: { lead: 2.8, counter: -5, chords: -2, snare: -1.5 },
- chords: {
- Gmaj9: { voicing: "[B3 D4 F#4 A4]", bass: "G1:2.5 r:.5 G1:1" },
- "F#m7": { voicing: "[A3 C#4 E4 F#4]", bass: "F#1:2.5 r:.5 C#2:1" },
- Bm9: { voicing: "[A3 C#4 D4 F#4]", bass: "B1:2.5 r:.5 F#1:1" },
- A11: { voicing: "[G3 B3 D4 E4]", bass: "A1:2.5 r:.5 E2:1" },
- },
- motifs: {
- rise: "r:1 F#5:.5 A5:.5 B5:1.5 A5:.5",
- answer: "r:.5 E5:.5 F#5:.5 A5:1 F#5:.5 E5:1",
- climb: "r:1 D5:.5 F#5:.5 A5:1 B5:.5 D6:.5",
- home: "C#6:1.5 B5:.5 A5:1 r:1",
- rest: "r:4",
- glint: "r:2 F#6:.5 E6:.5 D6:1",
- settle: "r:1 E6:.5 C#6:.5 A5:2",
- },
- grooves: {
- main: { kick: ["C4:1 r:.5 C4:[email protected] r:.5 C4:[email protected]"], snare: ["r:1 C4:1 r:1 C4:1"], ghost: ["r:3.5 C4:[email protected]"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"], cycle: "piece" },
- half: { kick: ["C4:2.5 C4:[email protected]"], snare: ["r:2 C4:2"], hat: ["C4:[email protected] C4:[email protected] C4:[email protected] C4:[email protected]"], cycle: "piece" },
- },
- sections: [
- { kind: "intro", bars: 1, harmony: ["Gmaj9"], lead: ["rise"], chordVel: 0.8 },
- { kind: "hook", bars: 2, harmony: ["F#m7", "Bm9"], lead: ["answer", "climb"], counter: ["rest", "glint"] },
- { kind: "half", bars: 1, harmony: ["A11"], lead: ["home"], counter: ["settle"] },
- ],
-});
-export const cheetahDuskScore = (): Piece => composePiece(cheetahDuskMaterial());
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetahRun.ts b/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetahRun.ts
deleted file mode 100644
index 00f3b8e..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/canvas-core/music/pieces/cheetahRun.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-// CHEETAH, RUN: the score. Nine bars of 12/8 at 80 bpm, exactly the film's 27 s, written to loop.
-// One idea held all the way through: a G drone, the G major pentatonic, one marimba cell that grows,
-// and a hand-percussion cycle that comes in under it, fills for the run and thins away again. It
-// draws on East African mallet and lyre music for its shape (a drone, a cycling pattern, a melody
-// that returns to the drone note); every note here is written for this film.
-// The cell: up from the fifth through the sixth to the tonic, D E G. The 12/8 lilt never changes, so
-// the run is the same music at full strength, not a different piece: her stride is 15 frames, a
-// quarter note here, six to the bar across the bar's four beats.
-// BARS [film]: 1 the drone and the cell, alone [night, the sun] · 2-3 the cell answers itself, the
-// drums begin [the face makes itself, alive] · 4 one long note over a harp sweep [the turn, the bow] ·
-// 5 the drone steps to E, two beats held, then a run of eighths up [she gathers; she goes at 405] ·
-// 6 the cell in her stride, the highest note, full drums [at speed] · 7 three strides and everything
-// stops [forefeet braced at 575] · 8-9 the cell comes home, the drone turns back [she stands, the
-// turn back, into the eye], and round again.
-import { type Piece } from "../plan";
-import { composePiece, type Material } from "../compose";
-
-export const cheetahRunMaterial = (): Material => ({
- style: "world", title: "Cheetah, run", seed: 5521, mood: "joy", bpm: 80, key: "G", mode: "majorPentatonic", meter: "12/8", loop: true, tail: 1.2,
- voices: { lead: "marimba" }, levels: { lead: 4, counter: -5, kick: -4.5, ghost: -6, perc: 8, chords: -3 }, moodControls: { energy: 0.5, warmth: 0.5, brightness: 0.68, tension: 0.4, space: 0.5 },
- chords: {
- G: { voicing: "[G2 D3 G3]", bass: "G1:4" },
- E: { voicing: "[E2 B2 E3]", bass: "E1:4" },
- D: { voicing: "[D3 A3 D4]", bass: "D2:4" },
- },
- motifs: {
- call: "r:2 D5:1/3 E5:1/3 G5:4/3",
- answer: "E5:1/3 D5:1/3 B4:1/3 D5:1 r:1 D5:1/3 E5:1/3 G5:1/3",
- alive: "A5:2/3 G5:1/3 E5:1 D5:1/3 E5:1/3 G5:1/3 D5:1",
- stretch: "E5:1/3 G5:1/3 A5:7/3 G5:1",
- gather: "r:2 B4:1/3 D5:1/3 E5:1/3 G5:1/3 A5:1/3 B5:1/3",
- stride: "D6:2/[email protected] B5:2/3 A5:2/3 G5:2/3 A5:2/3 B5:2/3",
- brace: "D6:2/[email protected] B5:2/3 G5:2/3 r:2",
- stand: "r:1 D5:1/3 E5:1/3 G5:1/3 E5:1 D5:1",
- home: "r:1 B4:1/3 D5:1/3 E5:1/3 D5:2",
- rest: "r:4",
- echo: "r:3 G4:1/3 D5:1/3 G5:1/3",
- sweep: "G3:1/3 D4:1/3 G4:1/3 B4:1/3 D5:1/3 G5:1/3 r:2",
- roll: "G4:1/3 D5:1/3 G5:1/3 D5:1/3 B4:1/3 D5:1/3 G4:1/3 D5:1/3 G5:1/3 D5:1/3 B4:1/3 D5:1/3",
- rollStop: "G4:1/3 D5:1/3 G5:1/3 D5:1/3 r:8/3",
- settle: "r:2 [G4 D5]:2",
- },
- grooves: {
- // the cycle: a low stroke on one and a lighter one on three, a rim answer, a shaker on the lilt
- cycle: { kick: ["G2:2 G2:[email protected] r:1"], ghost: ["r:1 C4:1/[email protected] r:2/3 r:1 C4:1/[email protected] r:2/3"], perc: ["C4:1/[email protected] r:1/3 C4:1/[email protected] C4:1/[email protected] r:1/3 C4:1/[email protected] C4:1/[email protected] r:1/3 C4:1/[email protected] C4:1/[email protected] r:1/3 C4:1/[email protected]"] },
- thin: { kick: ["G2:2 r:2"], perc: ["C4:1/[email protected] r:2/3 r:1 C4:1/[email protected] r:2/3 r:1"] },
- launch: { kick: ["r:2 G2:1 G2:[email protected]"], ghost: ["r:2 C4:2/3 C4:2/[email protected] C4:2/3"], perc: ["r:2 C4:1/[email protected] C4:1/[email protected] C4:1/[email protected] C4:1/[email protected] C4:1/[email protected] C4:1/[email protected]"] },
- gallop: { kick: ["G2:1 G2:[email protected] G2:1 G2:[email protected]", "G2:1 G2:1/[email protected] r:8/3"], ghost: ["C4:2/3 C4:2/[email protected] C4:2/3 C4:2/[email protected] C4:2/3 C4:2/[email protected]", "C4:2/3 C4:2/[email protected] r:8/3"], perc: [SHAKE, "C4:1/[email protected] C4:1/[email protected] C4:1/[email protected] C4:1/[email protected] r:8/3"] },
- },
- sections: [
- { kind: "intro", bars: 1, harmony: ["G"], lead: ["call"], energy: 0.35 },
- { kind: "verse", bars: 3, harmony: ["G", "~", "~"], lead: ["answer", "alive", "stretch"], counter: ["rest", "echo", "sweep"], groove: "cycle", energy: 0.45 },
- { kind: "build", bars: 1, harmony: ["E"], lead: ["gather"], groove: "launch", energy: 0.6 },
- { kind: "drop", bars: 2, harmony: ["G", "~"], lead: ["stride", "brace"], counter: ["roll", "rollStop"], groove: "gallop", energy: 0.9 },
- { kind: "breath", bars: 2, harmony: ["G", "D"], lead: ["stand", "home"], counter: ["settle", "rest"], groove: "thin", energy: 0.35 },
- ],
-});
-export const cheetahRunScore = (): Piece => composePiece(cheetahRunMaterial());
-// The signed cut: the same nine bars played once, then a tenth that closes them. The cell one last
-// time, landing on the tonic and held, over a rolled harp chord and one soft low stroke; no cycle.
-// The ending takes away: it is the quietest bar of the piece, and it is left to ring.
-export const cheetahRunSignedMaterial = (): Material => {
- const m = cheetahRunMaterial();
- return { ...m, title: "Cheetah, run (signed)", loop: false, tail: 2.2,
- motifs: { ...m.motifs, sign: "r:1 D5:1/[email protected] E5:1/[email protected] G5:7/[email protected]", signHarp: "G3:1/[email protected] D4:1/[email protected] G4:1/[email protected] r:1 [G4 D5]:[email protected]" },
- grooves: { ...m.grooves, last: { kick: ["G2:[email protected]"] } },
- sections: [...m.sections, { kind: "outro", bars: 1, harmony: ["G"], lead: ["sign"], counter: ["signHarp"], groove: "last", energy: 0.25 }] };
-};
-export const cheetahRunSignedScore = (): Piece => composePiece(cheetahRunSignedMaterial());
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahDusk.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahDusk.ts
deleted file mode 100644
index e34f643..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahDusk.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { cheetahDusk } from "../canvas-core/cheetahDusk";
-import { mountFilm } from "./page";
-
-mountFilm(cheetahDusk);
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRun.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRun.ts
deleted file mode 100644
index 0a471e6..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRun.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { cheetahRun } from "../canvas-core/cheetahRun";
-import { mountFilm } from "./page";
-
-mountFilm(cheetahRun);
diff --git a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRunSigned.ts b/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRunSigned.ts
deleted file mode 100644
index b45360e..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/src/hosts/page-cheetahRunSigned.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import { cheetahRunSigned } from "../canvas-core/cheetahRunSigned";
-import { mountFilm } from "./page";
-
-mountFilm(cheetahRunSigned);
diff --git a/plugins/anidoodle/skills/anidoodle/engine/test/cheetahRig.test.ts b/plugins/anidoodle/skills/anidoodle/engine/test/cheetahRig.test.ts
deleted file mode 100644
index 1448dd8..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/test/cheetahRig.test.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-// CHEETAH RIG TESTS. The skeleton (src/canvas-core/cheetahRig.ts) is pure arithmetic, so the things
-// that make her move like an animal and not like rubber are held to numbers here: node tools/test.mjs
-import { BOW, CROUCH, fk, FORE_BONES, gallopRig, gallopY, HIND_BONES, lowest, mixRig, settle, SKID, STAND, TAIL_BONES } from "../src/canvas-core/cheetahRig";
-import type { P } from "../src/canvas-core/core";
-
-export const name = "cheetahRig";
-export const run = (ok: (cond: boolean, label: string) => void) => {
- const dist = (a: P, b: P) => Math.hypot(a[0] - b[0], a[1] - b[1]);
- const bones = (pts: P[], B: number[]) => Math.max(...B.map((b, i) => Math.abs(dist(pts[i], pts[i + 1]) - b)));
-
- // 1. bones never change length, in the stride or in a blend between two held poses
- let worst = 0, finite = true;
- for (let i = 0; i < 400; i++) {
- const q = fk(i % 2 ? gallopRig(i / 400) : mixRig(STAND, BOW, i / 400), 0, 0, 0);
- worst = Math.max(worst, bones(q.foreN, FORE_BONES), bones(q.foreF, FORE_BONES), bones(q.hindN, HIND_BONES), bones(q.hindF, HIND_BONES), bones(q.tail, TAIL_BONES));
- for (const pts of [q.spine, q.tail, q.foreN, q.foreF, q.hindN, q.hindF]) for (const p of pts) if (!Number.isFinite(p[0]) || !Number.isFinite(p[1])) finite = false;
- }
- ok(worst < 1e-6, `every leg and tail bone keeps its length (worst error ${worst.toExponential(1)} px)`);
- ok(finite, "every point is finite through the stride and the blends");
-
- // 2. the stride is a loop: phase 1 is phase 0, and no joint jumps between neighbouring frames
- const a = fk(gallopRig(0), 0, gallopY(0), 0), b = fk(gallopRig(1), 0, gallopY(1), 0);
- ok(dist(a.foreN[4], b.foreN[4]) < 1e-6 && dist(a.hindN[4], b.hindN[4]) < 1e-6 && dist(a.tail[5], b.tail[5]) < 1e-6, "the stride closes: phase 1 lands exactly on phase 0");
- let jump = 0; const at = (ph: number) => fk(gallopRig(ph), 0, gallopY(ph), 0);
- for (let i = 0; i < 300; i++) { const p = at(i / 300), q = at((i + 1) / 300); for (const k of ["foreN", "foreF", "hindN", "hindF"] as const) jump = Math.max(jump, dist(p[k][4], q[k][4])); }
- ok(jump < 12, `no foot jumps within the stride (largest move in 1/300 of a stride: ${jump.toFixed(1)} px)`);
-
- // 3. she never goes through the ground, and she really leaves it twice a stride
- const lowAt = (ph: number) => { const l = lowest(fk(gallopRig(ph), 0, gallopY(ph), 0)); return Math.max(l.fore, l.hind); };
- let sink = -Infinity, flights = 0, wasAir = lowAt(299 / 300) < -12; // the stride is a loop: start from where the last one ended
- for (let i = 0; i < 300; i++) { const low = lowAt(i / 300); sink = Math.max(sink, low); const air = low < -12; if (air && !wasAir) flights++; wasAir = air; }
- ok(sink < 0.01, `no foot below the ground in the stride (lowest ${sink.toFixed(2)} px)`);
- ok(flights === 2, `two flight phases a stride, the extended and the gathered (found ${flights})`);
-
- // 4. the spine folds and opens: the hips come well forward under her in the gathered phase
- const span = (ph: number) => { const q = at(ph); return q.spine[6][0] - q.spine[1][0]; };
- ok(span(0) - span(0.52) > 20, `shoulder-to-hip distance closes in the gathered phase (${span(0).toFixed(0)} px extended, ${span(0.52).toFixed(0)} px gathered)`);
- const g = at(0.56); ok(Math.max(g.hindN[4][0], g.hindF[4][0]) > Math.min(g.foreN[4][0], g.foreF[4][0]), "gathered, a hind foot reaches past a forefoot");
-
- // 5. the head rides level while the body works under it
- let hi = Infinity, lo = -Infinity, hipHi = Infinity, hipLo = -Infinity;
- for (let i = 0; i < 100; i++) { const q = at(i / 100); hi = Math.min(hi, q.spine[9][1]); lo = Math.max(lo, q.spine[9][1]); hipHi = Math.min(hipHi, q.spine[1][1]); hipLo = Math.max(hipLo, q.spine[1][1]); }
- ok(lo - hi < 4 && hipLo - hipHi > 30, `the head moves ${(lo - hi).toFixed(1)} px through a stride while the hips move ${(hipLo - hipHi).toFixed(0)} px`);
-
- // 6. a held pose stands on all four feet
- for (const [n, r] of Object.entries({ STAND, BOW, CROUCH, SKID })) { const s = settle(r), l = lowest(fk(s.rig, 0, s.y, 0)); ok(Math.abs(l.fore) < 2 && Math.abs(l.hind) < 2, `${n} settles with fore and hind feet on the ground (${l.fore.toFixed(1)}, ${l.hind.toFixed(1)} px)`); }
- const s = settle(BOW), q = fk(s.rig, 0, s.y, 0); ok(q.spine[1][1] < q.spine[6][1] - 120, "in the bow the hips stay high above the shoulders");
-};
diff --git a/plugins/anidoodle/skills/anidoodle/engine/test/craft.test.ts b/plugins/anidoodle/skills/anidoodle/engine/test/craft.test.ts
deleted file mode 100644
index 8cac9e3..0000000
--- a/plugins/anidoodle/skills/anidoodle/engine/test/craft.test.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-// CRAFT TESTS (music/craft.ts): every metric on a small good example and a small bad one, so a
-// threshold that drifts or a metric that stops seeing is caught with no render and no human.
-import { craftReport, contourClass, classifyCadence, syncopation, metricWeight, development, type Finding } from "../src/canvas-core/music/craft";
-import { line, type Piece, type Part, type Role, type InstId, type Meter, type Note } from "../src/canvas-core/music/plan";
-import type { StyleId, MoodId } from "../src/canvas-core/music/tables";
-import type { ModeId } from "../src/canvas-core/music/theory";
-import { DEMOS, FIXTURES, composePiece, type Material } from "../src/canvas-core/music/index";
-import { breach } from "../src/canvas-core/music/blind/breach";
-import { stillwater } from "../src/canvas-core/music/blind/stillwater";
-import { morningCrumb } from "../src/canvas-core/music/blind/morningCrumb";
-import { skywardKids } from "../src/canvas-core/music/blind/skywardKids";
-
-type P = { id: string; inst: InstId; role: Role; src: string };
-const piece = (o: { style?: StyleId; mood?: MoodId; key?: string; mode?: ModeId; meter?: Meter; tempo?: number; bars: number; parts: P[]; harmony?: [number, string][]; sections?: [string, number][]; loop?: boolean }): Piece => {
- const meter = o.meter ?? "4/4", bpb = meter === "3/4" ? 3 : meter === "6/8" ? 2 : 4;
- const parts: Part[] = o.parts.map((x) => ({ id: x.id, inst: x.inst, role: x.role, notes: line(0, x.src, { role: x.role, bpb }) }));
- let from = 0; const arrangement = (o.sections ?? [["a", o.bars]]).map(([id, bars]) => { const a = { id, kind: id, from, bars }; from += bars; return a; });
- return { title: "t", seed: 1, tail: 1, parts, harmony: (o.harmony ?? [[0, "I"]]).map(([t, name]) => ({ t, name })), arrangement,
- plan: { style: o.style ?? "folk", tempo: o.tempo ?? 90, meter, loop: o.loop, sections: [{ id: "a", bars: o.bars, mood: o.mood ?? "calm", key: o.key ?? "C", mode: o.mode ?? "major", melody: ["stepwise"], dyn: [0.6, 0.6] }] } };
-};
-const has = (fs: Finding[], area: string, re: RegExp, level?: Finding["level"]) => fs.some((f) => f.area === area && re.test(f.msg) && (!level || f.level === level));
-const n = (p: number, t: number): Note => ({ p, t, d: 1, v: 0.7, role: "melody" });
-
-export const name = "craft (melody, harmony, rhythm, tension, mood metrics)";
-export const run = (ok: (cond: boolean, label: string) => void) => {
- const C = "[C3 E3 G3]:4", G = "[B2 D3 G3]:4", F = "[A2 C3 F3]:4";
- const bassC = "C2:4", bassG = "G1:4", bassF = "F1:4";
-
- // ---------------- melody: contour classes (Huron 1996)
- ok(contourClass([n(60, 0), n(64, 1), n(67, 2), n(64, 3), n(60, 4)]) === "arch", "contour: C E G E C is an arch");
- ok(contourClass([n(67, 0), n(65, 1), n(64, 2), n(62, 3), n(60, 4)]) === "descending", "contour: G F E D C descends");
- ok(contourClass([n(60, 0), n(60, 1), n(61, 2), n(60, 3)]) === "level", "contour: a line within a semitone is level");
-
- // ---------------- melody: leap recovery
- const leapy = piece({ bars: 4, harmony: [[0, "C"], [4, "G"], [8, "C"], [12, "G"]], parts: [
- { id: "lead", inst: "piano", role: "melody", src: "C4:1 A4:1 D5:1 G5:1 | C4:1 A4:1 D5:1 G5:1 | C4:1 A4:1 D5:1 G5:1 | C4:1 A4:1 D5:1 G5:1" },
- { id: "chords", inst: "piano", role: "accomp", src: [C, G, C, G].join(" | ") }, { id: "bass", inst: "bass", role: "bass", src: [bassC, bassG, bassC, bassG].join(" | ") }] });
- const recovered = piece({ bars: 4, harmony: [[0, "C"], [4, "G"], [8, "C"], [12, "G"]], parts: [
- { id: "lead", inst: "piano", role: "melody", src: "C4:1 A4:1 G4:1 F4:1 | E4:1 C5:1 B4:1 A4:1 | G4:1 E5:1 D5:1 C5:1 | B4:2 G4:2" },
- { id: "chords", inst: "piano", role: "accomp", src: [C, G, C, G].join(" | ") }, { id: "bass", inst: "bass", role: "bass", src: [bassC, bassG, bassC, bassG].join(" | ") }] });
- const rl = craftReport(leapy), rr = craftReport(recovered);
- ok(has(rl.findings, "melody", /leaps/, "warn"), `leaps that keep climbing warn (${rl.melody.leaps} leaps, ${rl.melody.leapsRecovered} turned back)`);
- ok(!has(rr.findings, "melody", /leaps/) && rr.melody.leapsRecovered === rr.melody.leaps, "leaps filled in by step pass");
- ok(rr.melody.stepShare > rl.melody.stepShare, `step share: stepwise line ${rr.melody.stepShare.toFixed(2)} > leapy line ${rl.melody.stepShare.toFixed(2)}`);
- // arpeggio idiom exemption: the same climb is a note, not a warning, in chiptune
- ok(has(craftReport({ ...leapy, plan: { ...leapy.plan, style: "chiptune" } }).findings, "melody", /leaps/, "info"), "arpeggio idioms (chiptune) get a note, not a warning");
-
- // ---------------- melody: motif development (Schoenberg: repetition, sequence, variation)
- ok(development([n(60, 0), n(62, 1), n(64, 2)], [[n(60, 0), n(62, 1), n(64, 2)]]) === "exact", "development: the same cell is exact");
- ok(development([n(62, 0), n(64, 1), n(66, 2)], [[n(60, 0), n(62, 1), n(64, 2)]]) === "sequence", "development: the cell a step up is a sequence");
- ok(development([n(62, 0), n(59, 1), n(64, 2)], [[n(60, 0), n(62, 1), n(64, 2)]]) === "varied", "development: same rhythm, new intervals is varied");
- ok(development([n(62, 0), n(59, 0.5), n(71, 2.5)], [[n(60, 0), n(62, 1), n(64, 2)]]) === "new", "development: new rhythm and intervals is new");
- const motif = "E4:.5 G4:.5 A4:1 r:2", seqd = piece({ bars: 4, parts: [{ id: "lead", inst: "piano", role: "melody", src: [motif, "F4:.5 A4:.5 B4:1 r:2", "G4:.5 B4:.5 C5:1 r:2", "E4:.5 G4:.5 C5:1 r:2"].join(" | ") }] });
- const random = piece({ bars: 4, parts: [{ id: "lead", inst: "piano", role: "melody", src: ["E4:1.5 D5:.5 r:2", "B3:.25 G4:.25 F4:2.5 r:1", "C5:1 A3:1 r:2", "F4:.75 E5:.25 G5:.5 r:2.5"].join(" | ") }] });
- const same = piece({ bars: 5, parts: [{ id: "lead", inst: "piano", role: "melody", src: Array(5).fill(motif).join(" | ") }] });
- ok(craftReport(seqd).melody.repetition >= 0.66 && !has(craftReport(seqd).findings, "melody", /bring back|exact copies/), `a developed motif returns (${craftReport(seqd).melody.repetition.toFixed(2)}) without a warning`);
- ok(has(craftReport(random).findings, "melody", /bring back/), "a line where nothing returns warns");
- ok(has(craftReport(same).findings, "melody", /exact copies/), "a photocopied motif warns");
-
- // ---------------- melody: phrase endings, strong beats, climax
- const ends = (last: string) => piece({ bars: 4, harmony: [[0, "C"], [4, "G"], [8, "F"], [12, "C"]], parts: [
- { id: "lead", inst: "piano", role: "melody", src: `E4:1 F4:1 G4:1 r:1 | D4:1 C4:1 B3:1 r:1 | C4:1 A3:1 ${last}:1 r:1 | ${last}:1 D4:1 ${last}:1 r:1` },
- { id: "chords", inst: "piano", role: "accomp", src: [C, G, F, C].join(" | ") }, { id: "bass", inst: "bass", role: "bass", src: [bassC, bassG, bassF, bassC].join(" | ") }] });
- ok(craftReport(ends("C4")).melody.stableEnds === 1, "phrases ending on chord tones: 100 %");
- ok(craftReport(ends("B3")).melody.stableEnds < 0.6 && has(craftReport(ends("B3")).findings, "melody", /end on a chord tone/), "phrases ending off the chord warn");
- ok(has(craftReport(ends("B3")).findings, "melody", /last note/), "a last note off the home triad is named");
- const peak = (early: boolean) => piece({ bars: 8, parts: [{ id: "lead", inst: "piano", role: "melody", src: Array.from({ length: 8 }, (_, i) => (i === (early ? 0 : 5) ? "C4:.5 D4:.5 E4:.5 A5:.5 G4:1 F4:1" : "C4:.5 D4:.5 E4:.5 F4:.5 E4:1 D4:1")).join(" | ") }] });
- ok(has(craftReport(peak(true)).findings, "melody", /peaks/), "the climax in the first bar warns");
- ok(!has(craftReport(peak(false)).findings, "melody", /peaks/) && Math.abs(craftReport(peak(false)).melody.climax!.at - 0.72) < 0.1, `the climax at ${Math.round(craftReport(peak(false)).melody.climax!.at * 100)} % passes`);
-
- // ---------------- range per instrument
- const vib = (src: string) => craftReport(piece({ bars: 1, parts: [{ id: "chords", inst: "vibes", role: "accomp", src }] })).findings;
- ok(has(vib("[C3 E3 G3]:4"), "range", /outside what/, "error"), "vibes at C3 (5 st below F3) is an error");
- ok(has(vib("[E3 A3 C4]:4"), "range", /outside what/, "warn"), "vibes at E3 (1 st below) is a warning: extended models exist");
- ok(!vib("[A3 C4 E4]:4").some((f) => f.area === "range"), "vibes in range: no range finding");
- ok(!craftReport(piece({ bars: 1, parts: [{ id: "bass", inst: "bass", role: "bass", src: "E1:4" }] })).findings.some((f) => f.area === "range"), "a bass on E1 is its home, not out of range");
-
- // ---------------- harmony: cadences
- ok(classifyCadence(7, 0) === "authentic" && classifyCadence(5, 0) === "plagal" && classifyCadence(10, 0) === "modal", "cadences: V-I authentic, IV-I plagal, bVII-I modal");
- ok(classifyCadence(0, 7) === "half" && classifyCadence(7, 9) === "deceptive", "cadences: ending on V is half, V-vi deceptive");
- const endOn = (fin: [string, string]) => piece({ bars: 4, sections: [["a", 2], ["b", 2]], harmony: [[0, "C"], [4, "F"], [8, "G"], [12, fin[0]]], parts: [
- { id: "chords", inst: "piano", role: "accomp", src: [C, F, G, fin[1]].join(" | ") }, { id: "bass", inst: "bass", role: "bass", src: [bassC, bassF, bassG, fin[0] === "C" ? bassC : bassG].join(" | ") },
- { id: "lead", inst: "piano", role: "melody", src: "E4:4 | F4:4 | D4:4 | C4:4" }] });
- const home = craftReport(endOn(["C", C])), away = craftReport(endOn(["G", G]));
- ok(home.harmony.cadences.at(-1)!.type === "authentic" && !has(home.findings, "harmony", /ends/), "a piece ending V-I is home");
- ok(has(away.findings, "harmony", /ends half/, "warn"), "a piece ending on V warns (away from home)");
- ok(has(craftReport({ ...endOn(["G", G]), plan: { ...endOn(["G", G]).plan, style: "suspense" } }).findings, "harmony", /ends/, "info"), "suspense may end open (a note, not a warning)");
-
- // ---------------- harmony: voice leading (parallels, doublings, style-aware)
- const pv = (style: StyleId, b: string) => craftReport(piece({ style, bars: 2, harmony: [[0, "C"], [4, "D"]], parts: [{ id: "chords", inst: "choir", role: "accomp", src: `[C4 G4 E5]:4 | ${b}:4` }] })).findings;
- ok(has(pv("choral", "[D4 A4 F5]"), "harmony", /parallel/, "warn"), "choral: parallel 5ths C-G to D-A warn");
- ok(!has(pv("choral", "[B3 G4 D5]"), "harmony", /parallel/), "choral: contrary/oblique motion passes");
- ok(has(pv("rock", "[D4 A4 F5]"), "harmony", /parallel/, "info"), "rock: the same fifths are the idiom (a note)");
- const dbl = craftReport(piece({ style: "orchestral", bars: 2, parts: [{ id: "chords", inst: "strings", role: "accomp", src: "[E3 G3 C4 E4]:4 | [F3 A3 C4 F4]:4" }] }));
- ok(dbl.harmony.parallels === 0 && dbl.harmony.octaveDoublings === 1, "orchestral: an octave-doubled voice moving is doubling, not a parallel");
- ok(craftReport(piece({ bars: 2, parts: [{ id: "chords", inst: "piano", role: "accomp", src: "[C4 E4 G4]:4 | [C5 E5 G5]:4" }] })).harmony.meanMotion > craftReport(piece({ bars: 2, parts: [{ id: "chords", inst: "piano", role: "accomp", src: "[C4 E4 G4]:4 | [C4 F4 A4]:4" }] })).harmony.meanMotion, "voice motion: a leap of the whole chord moves more than an inversion");
-
- // ---------------- harmony: mud (low interval limits)
- const mud = (src: string) => craftReport(piece({ bars: 1, parts: [{ id: "chords", inst: "piano", role: "accomp", src }] })).harmony.mud.length;
- ok(mud("[C2 E2 G2]:4") > 0, "a close C2-E2 third is mud");
- ok(mud("[C2 G2 E3]:4") === 0, "the same chord spread (C2 G2 E3) is clear");
- ok(mud("[C2 C3]:4") === 0, "octaves are never mud");
-
- // ---------------- harmony: the melody under the chords
- ok(has(craftReport(piece({ bars: 2, parts: [{ id: "chords", inst: "piano", role: "accomp", src: "[C4 E4 G4 C5]:4 | [C4 E4 G4 C5]:4" }, { id: "lead", inst: "piano", role: "melody", src: "E4:1 F4:1 G4:1 A4:1 | G4:1 F4:1 E4:1 D4:1" }] })).findings, "harmony", /under/), "a melody buried under the chord voicing warns");
-
- // ---------------- rhythm: metric weights, syncopation
- ok(metricWeight(0, 4, false) === 4 && metricWeight(2, 4, false) === 3 && metricWeight(1, 4, false) === 2 && metricWeight(0.5, 4, false) === 1 && metricWeight(0.25, 4, false) === 0, "metric weights 4/4: downbeat 4, mid-bar 3, beat 2, 8th 1, 16th 0");
- ok(metricWeight(1 / 3, 2, true) === 1 && metricWeight(1, 2, true) === 2, "metric weights 6/8: dotted-quarter beats 2, eighths 1");
- ok(syncopation([0, 1, 2, 3, 4], 4, false).index === 0, "syncopation: quarter notes on the beat = 0");
- ok(syncopation([0, 1.5, 3, 4], 4, false).index > 0 && syncopation([0, 1.5, 3, 4], 4, false).share > 0.3, "syncopation: an 'and of 2' held over beat 3 counts");
- const groove = (kick: string) => craftReport(piece({ style: "hipHop", bars: 4, parts: [{ id: "kick", inst: "kick", role: "drum", src: kick }, { id: "bass", inst: "bass", role: "bass", src: "C2:4 | C2:4 | C2:4 | C2:4" }, { id: "lead", inst: "piano", role: "melody", src: "C4:4 | D4:4 | E4:4 | C4:4" }] }));
- ok(has(groove("C4:1 C4:1 C4:1 C4:1 | C4:1 C4:1 C4:1 C4:1 | C4:1 C4:1 C4:1 C4:1 | C4:1 C4:1 C4:1 C4:1").findings, "rhythm", /no syncopation/), "hip-hop with every hit on the beat: no syncopation warns");
- ok(!has(groove("C4:1.5 C4:.5 r:2 | C4:1.5 C4:1 C4:1.5 | C4:1.5 C4:.5 r:2 | C4:1.5 C4:1 C4:1.5").findings, "rhythm", /no syncopation/), "an anticipated kick grooves");
- ok(has(groove("C4:4 | r:.75 C4:.25 C4:3 | C4:.5 C4:.5 C4:.5 C4:2.5 | r:3.5 C4:.5").findings, "rhythm", /changes almost every bar/), "a kick pattern that never repeats warns (groove consistency)");
- ok(has(craftReport(piece({ bars: 2, harmony: [[0.5, "C"], [2.5, "F"], [4.5, "G"], [6.5, "C"]], parts: [{ id: "chords", inst: "piano", role: "accomp", src: "r:.5 [C3 E3 G3]:2 [A2 C3 F3]:1.5 | r:.5 [B2 D3 G3]:2 [C3 E3 G3]:1.5" }] })).findings, "rhythm", /between beats/), "chord changes on off-beats warn");
- const rep = craftReport(piece({ bars: 8, sections: [["a", 4], ["b", 4]], parts: [{ id: "lead", inst: "piano", role: "melody", src: Array(8).fill("C4:1 E4:1 G4:1 E4:1").join(" | ") }] }));
- ok(rep.rhythm.repeatedSections.includes("b") && has(rep.findings, "rhythm", /note for note/), "a section repeating the previous note for note is dead air");
-
- // ---------------- tension: flat vs shaped
- const sec = (x: string) => Array(2).fill(x).join(" | ");
- const flat = craftReport(piece({ bars: 6, sections: [["a", 2], ["b", 2], ["c", 2]], parts: [{ id: "lead", inst: "piano", role: "melody", src: [sec("C4:1 D4:1 E4:1 D4:1"), sec("C4:1 E4:1 D4:1 E4:1"), sec("D4:1 C4:1 E4:1 C4:1")].join(" | ") }, { id: "chords", inst: "piano", role: "accomp", src: Array(6).fill(C).join(" | ") }] }));
- ok(has(flat.findings, "tension", /flat/), `a piece with no arc warns (sections ${flat.tension.sections.map((s) => s.value).join(", ")})`);
- const arc = craftReport(piece({ bars: 6, sections: [["a", 2], ["b", 2], ["c", 2]], harmony: [[0, "C"], [8, "G"], [16, "C"]], parts: [
- { id: "lead", inst: "piano", role: "melody", src: [sec("C4:2 D4:2"), sec("G4:.5 A4:.5 B4:.5 C5:.5 D5:.5 E5:.5 F5:.5 G5:.5"), sec("E4:4")].join(" | ") },
- { id: "chords", inst: "piano", role: "accomp", src: [C, C, "[B2 D3 F3 G3]:4", "[B2 D3 F3 G3]:4", C, C].join(" | ") }, { id: "bass", inst: "bass", role: "bass", src: [bassC, bassC, "G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5", "G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5", bassC, bassC].join(" | ") }] }));
- ok(!arc.findings.some((f) => f.area === "tension") && arc.tension.sections[1].value > arc.tension.sections[0].value && arc.tension.sections[1].value > arc.tension.sections[2].value, `rise, peak, release (${arc.tension.sections.map((s) => s.value).join(" < > ")}) passes`);
-
- // intensity, not only harmony (Farbood 2012): a home-chord tutti climax and an EDM drop are the peak; the same sections thin and quiet are not
- const mat = (style: StyleId, mood: MoodId, secs: Material["sections"], extra: Partial<Material> = {}): Material => ({ style, title: "t", seed: 2, mood, bpm: style === "house" ? 124 : 76, key: "C", mode: "major", ...extra,
- chords: { I: { voicing: "[E3 G3 C4]", bass: "C2:4" }, vi: { voicing: "[E3 A3 C4]", bass: "A1:4" }, IV: { voicing: "[F3 A3 C4]", bass: "F1:4" }, V: { voicing: "[D3 G3 B3 F4]", bass: "G1:2 G1:2" }, Vb9: { voicing: "[D3 G3 B3 F4 Ab4]", bass: "G1:2 G1:2" }, Vsus: { voicing: "[D3 G3 C4 F4]", bass: "G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5" } },
- grooves: { main: { family: style === "house" ? "fourFloor" : "pulse", density: 0.5, variation: 0.3 }, build: { family: "build", density: 0.8, variation: 0.2 }, drop: { family: style === "house" ? "fourFloor" : "pulse", density: 0.95, variation: 0.3, fill: true } }, sections: secs });
- const climax = (tutti: boolean) => mat("cinematic", "hopeful", [
- { id: "intro", kind: "intro", bars: 2, harmony: ["I", "vi"], lead: "E4:4 | C4:4", chordVel: 0.6, energy: 0.3 },
- { id: "verse", kind: "verse", bars: 2, harmony: ["IV", "vi"], lead: "F4:2 A4:2 | G4:2 E4:2", groove: null, energy: 0.45 },
- { id: "lean", kind: "verse", bars: 2, harmony: ["Vb9", "Vb9"], lead: "G4:.5 A4:.5 B4:.5 D5:.5 F5:.5 D5:.5 B4:.5 D5:.5 | F5:.5 Ab5:.5 F5:.5 D5:.5 B4:.5 D5:.5 F5:1", bass: "G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5 G1:.5", groove: null, energy: 0.6 },
- tutti ? { id: "climax", kind: "swell", bars: 2, harmony: ["I", "I"], lead: "C6:1 B5:.5 G5:.5 E5:1 G5:1 | C6:2 G5:2", counter: "E5:2 G5:2 | E5:4", arp: "C4:.5 E4:.5 G4:.5 C5:.5 E5:.5 G5:.5 C6:.5 G5:.5 | C4:.5 E4:.5 G4:.5 C5:.5 E5:.5 G5:.5 C6:.5 G5:.5", chordVel: 1.1, energy: 0.95 }
- : { id: "climax", kind: "breath", bars: 2, harmony: ["I", "I"], lead: "C4:4 | r:4", chordVel: 0.4, energy: 0.2 },
- { id: "outro", kind: "outro", bars: 2, harmony: ["IV", "I"], lead: "A4:2 G4:2 | E4:4", chordVel: 0.6, energy: 0.3 }]);
- const drop = (full: boolean) => mat("house", "drive", [
- { id: "groove", kind: "groove", bars: 2, harmony: ["vi", "IV"], lead: "r:4 | r:4", energy: 0.5 },
- { id: "build", kind: "build", bars: 2, harmony: ["Vsus", "V"], lead: "G4:.5 G4:.5 A4:.5 A4:.5 B4:.5 B4:.5 C5:.5 D5:.5 | D5:.25 D5:.25 D5:.25 D5:.25 E5:.25 E5:.25 F5:.25 F5:.25 G5:1 r:1", groove: "build", energy: 0.65 },
- full ? { id: "drop", kind: "drop", bars: 4, harmony: ["I", "vi", "IV", "I"], lead: "C6:.75 G5:.75 E5:.5 G5:1 C6:1 | A5:.75 E5:.75 C5:.5 E5:1 A5:1 | F5:.75 C6:.75 A5:.5 F5:1 A5:1 | G5:.75 E5:.75 C5:.5 C6:2", arp: Array(4).fill("C5:.25 E5:.25 G5:.25 C6:.25 ".repeat(4).trim()), groove: "drop", energy: 0.95 }
- : { id: "drop", kind: "breakdown", bars: 4, harmony: ["I", "vi", "IV", "I"], lead: "C5:4 | r:4 | r:4 | r:4", groove: null, chordVel: 0.5, energy: 0.3 },
- { id: "button", kind: "outro", bars: 1, harmony: ["I"], lead: "C5:1 r:3", energy: 0.4 }], { meter: "4/4" });
- const peakOf = (m: Material) => { const t = craftReport(composePiece(m)).tension.sections; return t.reduce((a, x) => (x.value > a.value ? x : a)); };
- const cg = peakOf(climax(true)), cb = peakOf(climax(false)), dg = peakOf(drop(true)), dbad = peakOf(drop(false));
- ok(cg.id === "climax", `a home-chord tutti climax reads as the peak (${craftReport(composePiece(climax(true))).tension.sections.map((x) => `${x.id} ${x.value}`).join(", ")})`);
- ok(cb.id !== "climax", `the same home chord thin and quiet is not the peak (peak: ${cb.id})`);
- ok(dg.id === "drop", `an EDM drop reads as the peak over its build (${craftReport(composePiece(drop(true))).tension.sections.map((x) => `${x.id} ${x.value}`).join(", ")})`);
- ok(dbad.id !== "drop", `a "drop" that thins out is not the peak (peak: ${dbad.id})`);
- const lvl = (o: { loop?: boolean; mood?: MoodId }) => craftReport(piece({ bars: 6, mood: o.mood ?? "joy", loop: o.loop, sections: [["a", 2], ["b", 2], ["c", 2]], parts: [{ id: "lead", inst: "piano", role: "melody", src: [sec("C4:1 D4:1 E4:1 D4:1"), sec("C4:1 E4:1 D4:1 E4:1"), sec("D4:1 C4:1 E4:1 C4:1")].join(" | ") }, { id: "chords", inst: "piano", role: "accomp", src: Array(6).fill(C).join(" | ") }] })).findings;
- ok(has(lvl({}), "tension", /flat/, "warn") && has(lvl({ loop: true }), "tension", /flat/, "info") && has(lvl({ mood: "calm" }), "tension", /flat/, "info"), "a flat curve warns, but a loop or a calm piece stays level on purpose (a note, not a warning)");
-
- // ---------------- mood fit
- const moody = (tempo: number, mode: ModeId) => craftReport(piece({ mood: "calm", tempo, mode, bars: 2, parts: [{ id: "lead", inst: "piano", role: "melody", src: "E5:1 D5:.5 C5:.5 D5:1 E5:1 | D5:1 C5:.5 D5:.5 E5:1 C5:1" }, { id: "chords", inst: "piano", role: "accomp", src: `${C} | ${C}` }, { id: "bass", inst: "bass", role: "bass", src: "C2:4 | C2:4" }] }));
- ok(!has(moody(72, "major").findings, "mood", /./), "calm at 72 bpm in major fits");
- ok(has(moody(150, "major").findings, "mood", /tempo 150/), "calm at 150 bpm warns on tempo");
- ok(has(moody(72, "phrygian").findings, "mood", /mode phrygian/), "calm in phrygian (minor family) warns on mode");
- ok(!has(moody(72, "lydian").findings, "mood", /mode/), "calm in lydian (major family) passes: the family is the cue");
-
- // ---------------- only real errors are errors
- ok(craftReport(leapy).findings.every((f) => f.level !== "error"), "craft never errors on taste: only impossible ranges are errors");
-
- // ---------------- shipped music never carries an unplayable note (a craft ERROR). The fixtures are deliberately bad
- // for other guards (ghost, novelty), not for range, so they are held to this too; add a name here only for a fixture
- // written to fail the range check.
- const RANGE_FIXTURES: string[] = [];
- const shipped: [string, () => Piece][] = [...Object.entries(DEMOS), ...Object.entries(FIXTURES).filter(([k]) => !RANGE_FIXTURES.includes(k)),
- ...([["breach", breach], ["stillwater", stillwater], ["morningCrumb", morningCrumb], ["skywardKids", skywardKids]] as const).map(([k, m]) => [`blind/${k}`, () => composePiece(m())] as [string, () => Piece])] as [string, () => Piece][];
- for (const [k, make] of shipped) { const errs = craftReport(make()).findings.filter((f) => f.level === "error"); ok(!errs.length, `${k}: no unplayable notes${errs.length ? ` (${errs.map((f) => f.msg).join("; ")})` : ""}`); }
-};
diff --git a/scripts/sync-codex-marketplace-plugin.sh b/scripts/sync-codex-marketplace-plugin.sh
index e70b537..c13d9c1 100755
--- a/scripts/sync-codex-marketplace-plugin.sh
+++ b/scripts/sync-codex-marketplace-plugin.sh
@@ -36,14 +36,32 @@ mkdir -p "${STAGE}/assets"
cp "${REPO_ROOT}/assets/icon.png" "${STAGE}/assets/icon.png"
cd "${REPO_ROOT}"
# The installed plugin leaves out what only the repository needs: anidoodle's own launch films
-# (launch, launch2, launch3, launchClip and their helpers and pages), the public-domain reference
-# image they show, and the gallery sheet and the tool that rebuilds it (the docs link to it online).
-EXCLUDE='/canvas-core/(launch|launch2|launch3|launchClip|launchCode|typeOptions|typeStyles)\.ts$|/hosts/page-(launch|launch2|launch3|launchClip|typeOptions|typeStyles)\.ts$|/engine/assets/refs/|/engine/tools/gallery\.mjs$|^skills/anidoodle/assets/styles\.jpg$|/engine/package-lock\.json$|/music/blind/'
+# (launch, launch2, launch3, launchClip and their helpers and pages) and its showcase films (the
+# cheetah films, their scores, pages and rig test), the public-domain reference image they show,
+# and the gallery sheet and the tool that rebuilds it (the docs link to it online).
+# A test that needs a left-out file is left out with it (craft.test.ts reads the blind pieces).
+EXCLUDE='/canvas-core/(launch|launch2|launch3|launchClip|launchCode|typeOptions|typeStyles)\.ts$|/hosts/page-(launch|launch2|launch3|launchClip|typeOptions|typeStyles)\.ts$|/engine/assets/refs/|/engine/tools/gallery\.mjs$|^skills/anidoodle/assets/styles\.jpg$|/engine/package-lock\.json$|/music/blind/|/canvas-core/cheetah[A-Za-z]*\.ts$|/music/pieces/cheetah[A-Za-z]*\.ts$|/hosts/page-cheetah[A-Za-z]*\.ts$|/test/cheetahRig\.test\.ts$|/test/craft\.test\.ts$'
count=0
while IFS= read -r f; do
mkdir -p "${STAGE}/$(dirname "$f")"; cp -p "$f" "${STAGE}/$f"; count=$((count + 1))
done < <(git ls-files skills/ | grep -v -E "${EXCLUDE}")
+# a showcase or launch film in the installed plugin is a leak of the repository's own promotion: refuse to publish one
+leaked="$(cd "${STAGE}" && find . -type f \( -iname 'cheetah*' -o -iname 'page-cheetah*' -o -name 'launch[0-9]*.ts' -o -name 'launchClip.ts' \) | head -5)"
+[ -z "${leaked}" ] || { echo "ERROR: repository-only films reached the plugin folder:" >&2; echo "${leaked}" >&2; exit 5; }
+# what is left must stand on its own: every relative import in the staged engine's sources and tests resolves
+# to a staged file (the tools are skipped: they hold import lines inside the code they generate)
+if command -v node >/dev/null 2>&1; then
+ node -e '
+ const fs = require("fs"), path = require("path"), root = process.argv[1], bad = [];
+ const walk = (d) => fs.readdirSync(d, { withFileTypes: true }).flatMap((e) => e.isDirectory() ? walk(path.join(d, e.name)) : [path.join(d, e.name)]);
+ for (const f of [path.join(root, "src"), path.join(root, "test")].flatMap(walk).filter((f) => /\.ts$/.test(f))) for (const m of fs.readFileSync(f, "utf8").matchAll(/^\s*(?:import|export)\b[^"\x27;]*?from\s+["\x27](\.{1,2}\/[^"\x27]+)["\x27]/gm)) {
+ const t = path.resolve(path.dirname(f), m[1]);
+ if (![t, t + ".ts", t + ".mjs", t + ".json", path.join(t, "index.ts")].some((c) => fs.existsSync(c) && fs.statSync(c).isFile())) bad.push(path.relative(root, f) + " -> " + m[1]);
+ }
+ if (bad.length) { console.error("ERROR: the plugin folder imports files it leaves out:\n " + bad.slice(0, 10).join("\n ")); process.exit(6); }
+ ' "${STAGE}/skills/anidoodle/engine" || exit 6
+fi
[ -f "${STAGE}/skills/anidoodle/SKILL.md" ] || { echo "ERROR: SKILL.md missing after copy (is it committed?)" >&2; exit 4; }
[ "${count}" -ge 50 ] || { echo "ERROR: only ${count} files copied; expected the whole skill" >&2; exit 4; }
diff --git a/skills/anidoodle/engine/package-lock.json b/skills/anidoodle/engine/package-lock.json
index 803f7be..da20b4c 100644
--- a/skills/anidoodle/engine/package-lock.json
+++ b/skills/anidoodle/engine/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "anidoodle-engine",
- "version": "0.6.3",
+ "version": "0.6.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "anidoodle-engine",
- "version": "0.6.3",
+ "version": "0.6.4",
"dependencies": {
"esbuild": "0.25.12"
},
diff --git a/skills/anidoodle/engine/package.json b/skills/anidoodle/engine/package.json
index 08d287f..a7ad999 100644
--- a/skills/anidoodle/engine/package.json
+++ b/skills/anidoodle/engine/package.json
@@ -1,6 +1,6 @@
{
"name": "anidoodle-engine",
- "version": "0.6.3",
+ "version": "0.6.4",
"private": true,
"type": "module",
"description": "Portable art core + backend adapters for illustrations, animations and films drawn entirely in code.",