/**
* Claude's stand-ins (CLAUDE.md §2, art/placeholders/): plain SVG shapes that test form and
* layout until a real picture is accepted. They are deliberately simple. A stand-in that
* looked finished would hide that the real picture is still missing.
*/
import type { Asset, Manifest } from './manifest.js';
import { cellBoxes, cellSize } from './prompt.js';
const C = {
rose: '#c85a6e',
petal: '#f2b5be',
blush: '#e8899b',
leaf: '#7fa07a',
moss: '#4f6e52',
ink: '#3a2730',
paper: '#fbf6f1',
soil: '#8a6248',
wood: '#b98a5a',
meadow: '#a9c48e',
amber: '#f2b860',
coral: '#e9846a',
night: '#2e3561',
lamp: '#f4d58d',
fox: '#bc4a22',
cream: '#f3e3c8',
foxLeg: '#5a3a33',
strawberry: '#d2554e',
blueberry: '#5b6fa6',
raspberry: '#c2456a',
blackberry: '#3f2e4a',
hip: '#d0632e'
} as const;
type Eyes = 'open' | 'half' | 'closed' | 'down' | 'squeeze';
type Mouth = 'smile' | 'small' | 'open' | 'puff';
interface RoseLook {
readonly stage: 'bud' | 'opening' | 'half' | 'full';
readonly eyes: Eyes;
readonly mouth: Mouth;
readonly blush?: boolean;
/** Degrees the bloom leans from the stem top; negative is left. */
readonly tilt?: number;
readonly leaves?: 'normal' | 'down' | 'up' | 'raised';
readonly back?: boolean;
readonly drops?: boolean;
readonly bend?: number;
}
/** The rose in a 200 × 520 box: bloom near the top, stem down to the bottom edge. */
function rose(look: RoseLook): string {
const r = { bud: 30, opening: 44, half: 58, full: 74 }[look.stage];
const bend = look.bend ?? 0;
const stem = ``;
const thorns = [430, 300, 220]
.map((y, i) => ``)
.join('');
const leafRot = { normal: [-35, 35, -30], down: [10, -10, 15], up: [-60, 60, -55], raised: [-35, 80, -30] }[look.leaves ?? 'normal'];
const leaf = (x: number, y: number, dir: number, rot: number): string =>
``;
const leaves = leaf(100, 400, -1, leafRot[0] ?? 0) + leaf(100 + bend * 0.5, 330, 1, leafRot[1] ?? 0) + leaf(100 + bend, 250, -1, leafRot[2] ?? 0);
const count = look.stage === 'opening' ? 5 : 8;
const petals =
look.stage === 'bud'
? `
`
: Array.from({ length: count }, (_, i) => {
const a = (i / count) * Math.PI * 2;
return ``;
}).join('') + ``;
const eye = (x: number): string => {
const y = 124;
switch (look.eyes) {
case 'open': return ``;
case 'half': return ``;
case 'closed': return ``;
case 'down': return ``;
case 'squeeze': return ``;
}
};
const mouth = {
smile: ``,
small: ``,
open: ``,
puff: ``
}[look.mouth];
const blush = look.blush ? `` : '';
const face = look.back ? '' : eye(91) + eye(109) + mouth + blush;
const drops = look.drops
? [[64, 92], [138, 104], [120, 70]].map(([x, y]) => ``).join('')
: '';
const bloom = `${petals}${face}${drops}`;
return stem + thorns + leaves + bloom;
}
interface FoxLook {
readonly pose: 'sit' | 'stand' | 'lie' | 'curl';
readonly eyes: 'open' | 'half' | 'closed';
/** Faces right instead of left. */
readonly right?: boolean;
/** The head turned back over the shoulder. */
readonly back?: boolean;
/** Seen from behind: no face. */
readonly behind?: boolean;
readonly petal?: boolean;
readonly fluffed?: boolean;
/** Degrees the head tilts. */
readonly tilt?: number;
}
/** The fox in a 300 × 240 box, facing left unless `right`, feet on the bottom edge. */
function fox(look: FoxLook): string {
const ink = `stroke="${C.ink}" stroke-width="4"`;
const leg = (x: number, y0: number, y1: number): string => ``;
const thick = look.fluffed ? 8 : 0;
const tail = (d: string): string =>
`` +
`` +
``;
const head = (x: number, y: number, r: number): string => {
const k = look.back ? -1 : 1;
const ears = [-0.55, 0.35].map((o) => ``).join('');
if (look.behind) return ears + ``;
const eye = (ex: number): string =>
look.eyes === 'open'
? ``
: ``;
const snout = x - k * r * 0.75;
return ears + `
${eye(x - k * 13)}${eye(x + k * 9)}
${look.petal ? `` : ''}`;
};
let body: string;
switch (look.pose) {
case 'sit':
body = tail('M185 215 Q 250 205 240 150') + ``
+ `` + leg(140, 175, 225) + leg(168, 175, 225)
+ head(look.back ? 175 : 145, 72, 38);
break;
case 'stand':
body = tail('M235 120 Q 280 110 290 60') + leg(110, 140, 225) + leg(130, 140, 225) + leg(200, 140, 225) + leg(220, 140, 225)
+ `` + head(look.back ? 215 : 80, 98, 34);
break;
case 'lie':
body = tail('M250 205 Q 285 215 290 180') + ``
+ leg(70, 215, 222) + head(72, 178, 32);
break;
case 'curl':
body = `` + tail('M205 200 Q 170 235 110 205') + head(125, 168, 30);
break;
}
return look.right ? `${body}` : body;
}
const FOXES: Record = {
'fox-watching': { pose: 'sit', eyes: 'open', back: true },
'fox-curious': { pose: 'stand', eyes: 'open', tilt: -14 },
'fox-sitting': { pose: 'sit', eyes: 'half' },
'fox-resting': { pose: 'lie', eyes: 'half' },
'fox-petted': { pose: 'sit', eyes: 'closed', tilt: -18 },
'fox-brushed': { pose: 'sit', eyes: 'half', fluffed: true, tilt: 8 },
'fox-eating': { pose: 'stand', eyes: 'closed', tilt: -30 },
'fox-asleep': { pose: 'curl', eyes: 'closed' },
'fox-trotting': { pose: 'stand', eyes: 'open' },
'fox-leading': { pose: 'stand', eyes: 'open', right: true, back: true },
'fox-carrying-petal': { pose: 'stand', eyes: 'half', petal: true },
'fox-visiting': { pose: 'sit', eyes: 'half', tilt: 16 }
};
/** Place a drawing made in a w × h box centred in the target, filling about 76 %. */
function fit(body: string, w: number, h: number, W: number, H: number, fill = 0.76): string {
const s = Math.min((W * fill) / w, (H * fill) / h);
return `${body}`;
}
const ROSES: Record = {
'rose-bud': { stage: 'bud', eyes: 'closed', mouth: 'small' },
'rose-opening': { stage: 'opening', eyes: 'half', mouth: 'small' },
'rose-half-bloom': { stage: 'half', eyes: 'half', mouth: 'smile' },
'rose-full-bloom': { stage: 'full', eyes: 'half', mouth: 'smile', tilt: -4 },
'rose-thirsty': { stage: 'full', eyes: 'down', mouth: 'small', tilt: 14, leaves: 'down' },
'rose-overwatered': { stage: 'full', eyes: 'squeeze', mouth: 'puff', leaves: 'down', drops: true },
'rose-windblown': { stage: 'full', eyes: 'squeeze', mouth: 'small', bend: 22, tilt: 18, leaves: 'up' },
'rose-blushing': { stage: 'full', eyes: 'closed', mouth: 'smile', blush: true, leaves: 'raised' },
'rose-sleepy': { stage: 'half', eyes: 'closed', mouth: 'smile', tilt: 10 },
'rose-speaking': { stage: 'full', eyes: 'open', mouth: 'open', leaves: 'raised' },
'rose-waiting': { stage: 'half', eyes: 'down', mouth: 'small', tilt: -18, leaves: 'down' },
'rose-watching-sunset': { stage: 'full', eyes: 'open', mouth: 'small', back: true, tilt: -10 },
'rose-tickled': { stage: 'full', eyes: 'squeeze', mouth: 'smile', blush: true, leaves: 'down' },
'rose-gentle': { stage: 'full', eyes: 'open', mouth: 'small', leaves: 'raised', tilt: 6 }
};
/** The care things, each in a 200 × 200 box. */
const PROPS: Record = {
'watering-can': `
`,
windbreak: Array.from({ length: 9 }, (_, i) => ``).join('')
+ `
`,
'weed-clump': [60, 100, 140].map((x, i) => ``).join('')
+ ``,
'fallen-petals': [[60, 110, -20], [110, 90, 25], [140, 130, 60]].map(([x, y, r]) => ``).join(''),
'petal-folded': `
`,
'petal-open': ``,
'garden-chair': `
`
};
const berries = (fill: string, at: readonly (readonly [number, number])[], r: number, leaves = 1): string =>
Array.from({ length: leaves }, (_, i) => ``).join('')
+ ``
+ at.map(([x, y]) => ``).join('');
const bush = (extra: string): string =>
[[60, 120, 50], [140, 120, 50], [100, 80, 56], [100, 140, 46]].map(([x, y, r]) => ``).join('')
+ `` + extra;
/** The fox's food and the bush, each in a 200 × 200 box like PROPS. */
const MORE_PROPS: Record = {
'wild-strawberries': berries(C.strawberry, [[70, 120], [110, 140], [140, 105]], 22, 2),
blueberries: berries(C.blueberry, [[70, 120], [100, 140], [130, 120], [85, 95], [118, 95]], 16, 2),
raspberries: berries(C.raspberry, [[72, 120], [110, 138], [138, 108]], 22),
blackberries: berries(C.blackberry, [[72, 120], [110, 138], [138, 108]], 22),
'rose-hips': ``
+ [[70, 125], [130, 125]].map(([x, y]) => ``).join(''),
'leaf-plate': ``,
'bush-resting': bush(''),
'bush-flowering': bush([[55, 100], [100, 60], [145, 105], [90, 135], [125, 150]].map(([x, y]) => ``).join('')),
'bush-ripe': bush([[60, 105], [138, 108], [100, 70]].map(([x, y]) => ``).join('')),
'fox-brush': ``
+ Array.from({ length: 12 }, (_, i) => ``).join('')
};
const meadow = (path: string): string =>
`${path}`;
const lantern = (lit: boolean): string =>
(lit ? `` : '')
+ ``
+ ``
+ ``
+ ``
+ (lit ? `` : '');
/** Tall things, each in a 200 × 400 box: the path stretches and the lanterns. */
const TALL: Record = {
'path-prints': meadow([340, 290, 240, 190, 140, 95, 55].map((y, i) => ``).join('')),
'path-trail': meadow(``),
'path-road': meadow(``
+ [[52, 360], [148, 360], [70, 260], [130, 255], [80, 160], [118, 150], [88, 70], [110, 65]].map(([x, y]) => ``).join('')),
'lantern-unlit': lantern(false),
'lantern-lit': lantern(true)
};
const ink = (w = 4): string => `stroke="${C.ink}" stroke-width="${w}"`;
/** The pictures added with the art board v2 (STYLE.md, 2026-11-07), each in a 200 × 200 box. */
const V2_PROPS: Record = {
'weeds-growing': ``
+ [70, 100, 130].map((x, i) => ``).join(''),
'watering-can-pouring': ``
+ ``
+ ``
+ [[16, 170], [30, 182]].map(([x, y]) => ``).join(''),
'wind-gust': [60, 100, 140].map((y, i) => ``).join('')
+ ``,
'water-drops': [[70, 80, 14], [120, 70, 10], [100, 120, 16], [140, 130, 9], [60, 140, 8]].map(([x, y, r]) => ``).join(''),
'letter-header': ``
+ ``
+ ``,
'geographers-book': ``
+ ``
+ [92, 110, 128].map((y) => ``).join('')
+ ``,
'petal-trace': ``,
'foxes-meeting': ``,
'visitor-hedgehog': ``
+ ``
+ Array.from({ length: 7 }, (_, i) => ``).join(''),
'visitor-robin': ``
+ ``,
'visitor-snail': ``
+ ``,
'visitor-moth': ``
+ ``,
'visitor-ladybird': ``
+ [[74, 100], [126, 100], [80, 135], [120, 135]].map(([x, y]) => ``).join(''),
'visitor-owl': ``
+ ``,
'memento-feather': ``,
'memento-pebble': ``,
'memento-acorn-cup': ``,
'memento-snail-shell': ``,
'memento-pressed-flower': ``
+ Array.from({ length: 5 }, (_, i) => { const a = (i / 5) * Math.PI * 2; return ``; }).join('') + ``,
'memento-seed-head': ``
+ Array.from({ length: 10 }, (_, i) => { const a = (i / 10) * Math.PI * 2; return ``; }).join(''),
'sky-light': ``
};
const streetLamp = (lit: boolean): string =>
(lit ? `` : '')
+ ``
+ ``;
/** Tall things added with v2, each in a 200 × 400 box. */
const V2_TALL: Record = {
'wave-lamp-unlit': streetLamp(false),
'wave-lamp-lit': streetLamp(true)
};
/** A planet stand-in: a grassy hilltop with the shapes of what its grown-up left there (never a sphere). */
function planet(W: number, H: number, id: string): string {
const top = Math.round(H * 0.6);
const things: Record = {
'planet-king': ``,
'planet-vain': ``,
'planet-businessman': ``
+ [[-100, 6], [-60, 4], [40, 7]].map(([x, n]) => Array.from({ length: n ?? 0 }, (_, i) => ``).join('')).join('') + ``,
'planet-lamplighter': `${streetLamp(false)}`,
'planet-geographer': ``
};
return ``
+ ``
+ `${drawing(things, id)}`;
}
type Pose = 'stand' | 'walk' | 'pour' | 'pull' | 'sweep' | 'carry' | 'reach' | 'sit';
/** The gardener's stand-in in a 120 × 200 box, feet on the bottom edge, facing right (STYLE.md §3b). */
function gardener(pose: Pose, boy = false): string {
const skin = '#cf9a72', hair = '#7a4b2e', cloth = C.leaf, apron = '#efe4d2';
const lean = { stand: 0, walk: 4, pour: 10, pull: 28, sweep: 18, carry: 6, reach: 14, sit: 0 }[pose];
const arm = { stand: 8, walk: -12, pour: -70, pull: -150, sweep: -40, carry: -80, reach: -95, sit: -30 }[pose];
const legs = pose === 'sit'
? ``
: ``;
const body = boy
? ``
: ``;
const held = pose === 'pour' ? ``
: pose === 'carry' ? Array.from({ length: 4 }, (_, i) => ``).join('') : '';
const braids = boy ? '' : ``;
return `${legs}
${body}
${held}
${braids}
`;
}
const GARDENER_POSES: Record = {
'gardener-stand': 'stand', 'gardener-walk': 'walk', 'gardener-pour': 'pour', 'gardener-pull': 'pull',
'gardener-sweep': 'sweep', 'gardener-carry': 'carry', 'gardener-reach': 'reach', 'gardener-sit': 'sit'
};
/** Her home planet's stand-in (STYLE.md S2): a round meadow world, the empty bed on top, the wall and the chair. */
function homePlanet(W: number, H: number, light: 'day' | 'golden' | 'night'): string {
const meadow = { day: C.meadow, golden: '#c9b07a', night: '#3c4a6a' }[light];
const cx = W / 2, cy = H * 0.58, r = W * 0.35;
return `
`;
}
/** The share frame's stand-in: meadow along the bottom and up the sides, the middle left empty. */
function shareFrame(W: number, H: number): string {
return ``
+ ``
+ [[0.2, 0.84], [0.7, 0.82]].map(([x, y]) => ``).join('');
}
function garden(W: number, H: number, time: 'morning' | 'day' | 'sunset' | 'night'): string {
const tint = {
morning: { field: '#b8d1a0', far: '#c9dbe0', wall: '#b4a596', light: '#ffffff' },
day: { field: C.meadow, far: '#b9cfa8', wall: '#a8957f', light: '#fff6d8' },
sunset: { field: '#c9b07a', far: '#d9a98a', wall: '#a07b62', light: C.amber },
night: { field: '#3c4a6a', far: '#46557a', wall: '#3a4466', light: C.lamp }
}[time];
const h = Math.round(H * 0.4);
const bedY = Math.round(H * 0.72);
return `
`;
}
function single(a: Asset): string {
const { width: W, height: H } = a;
switch (a.type) {
case 'sheet': {
if (a.character === 'gardener') {
// The girl along the top, the boy along the bottom; the side and back views are flipped stand-ins.
const row = (boy: boolean, y: number): string =>
[0, 1, 2, 3].map((i) => `${gardener('stand', boy)}`).join('');
return `${row(false, 40)}${row(true, 560)}`;
}
if (a.character === 'fox') {
const views: FoxLook[] = [{ pose: 'sit', eyes: 'half' }, { pose: 'stand', eyes: 'half' }, { pose: 'stand', eyes: 'half', tilt: -8 }, { pose: 'sit', eyes: 'half', behind: true }];
const figures = views.map((l, i) => `${fox(l)}`).join('');
const heads: FoxLook[] = [{ pose: 'sit', eyes: 'half' }, { pose: 'sit', eyes: 'open', tilt: -14 }, { pose: 'sit', eyes: 'closed' }];
// Close-ups: only the head, cropped by a nested viewBox.
const close = heads.map((l, i) => ``).join('');
return `${figures}${close}`;
}
const looks: RoseLook[] = [
{ stage: 'full', eyes: 'half', mouth: 'smile' },
{ stage: 'full', eyes: 'half', mouth: 'smile', tilt: -12 },
{ stage: 'full', eyes: 'half', mouth: 'small', tilt: -20 },
{ stage: 'full', eyes: 'half', mouth: 'small', back: true }
];
const figures = looks.map((l, i) => `${rose(l)}`).join('');
const heads: RoseLook[] = [
{ stage: 'full', eyes: 'half', mouth: 'smile' },
{ stage: 'half', eyes: 'closed', mouth: 'smile' },
{ stage: 'full', eyes: 'closed', mouth: 'smile', blush: true }
];
// Close-ups: only the bloom, cropped by a nested viewBox.
const close = heads.map((l, i) => ``).join('');
return `${figures}${close}`;
}
case 'sprite':
return fit(drawing({ ...PROPS, ...V2_PROPS }, a.id), 200, 200, W, H, 0.7);
case 'layer': {
if (a.id.startsWith('planet-')) return planet(W, H, a.id);
if (a.id.startsWith('home-planet-')) return homePlanet(W, H, a.id.endsWith('golden') ? 'golden' : a.id.endsWith('night') ? 'night' : 'day');
if (a.id === 'share-frame') return shareFrame(W, H);
const time = (['morning', 'day', 'sunset', 'night'] as const).find((t) => a.id.endsWith(t)) ?? 'day';
return garden(W, H, time);
}
case 'icon':
if (a.id === 'favicon-mark') {
// A bloom of a few bold petals, no face: it must read at 16 px.
const petals = Array.from({ length: 6 }, (_, i) => {
const t = (i / 6) * Math.PI * 2;
return ``;
}).join('');
return `${petals}`;
}
if (a.id === 'app-icon-maskable') {
return `
`;
}
return `
`;
case 'spritesheet':
return sheet(a);
}
}
/** A stand-in drawing by id. A picture with none fails the build rather than showing an empty box. */
function drawing(from: Record, id: string): string {
const d = from[id];
if (d === undefined) throw new Error(`tools/art-prep/src/placeholders.ts has no stand-in drawing for "${id}"`);
return d;
}
/** One cell's drawing, sized to the cell it ships at. */
function cellBody(id: string, W: number, H: number): string {
const look = ROSES[id];
if (look) return fit(rose(look), 200, 520, W, H);
const pose = FOXES[id];
if (pose) return fit(fox(pose), 300, 240, W, H);
const gardenerPose = GARDENER_POSES[id];
if (gardenerPose) return fit(gardener(gardenerPose), 120, 200, W, H);
if (id in TALL || id in V2_TALL) return fit(drawing({ ...TALL, ...V2_TALL }, id), 200, 400, W, H);
return fit(drawing({ ...PROPS, ...MORE_PROPS, ...V2_PROPS }, id), 200, 200, W, H, 0.7);
}
function sheet(a: Asset): string {
const g = a.grid ?? { cols: 1, rows: 1 };
return cellBoxes(a.width, a.height, g.cols, g.rows)
.map((b, i) => {
const c = a.cells?.[i];
if (!c) return '';
const w = b.x1 - b.x0, h = b.y1 - b.y0;
return ``;
})
.join('');
}
const wrap = (id: string, W: number, H: number, body: string): string =>
`\n`;
/** Every stand-in the board and the app may show: one per asset and one per sprite-sheet cell. */
export function placeholders(m: Manifest): Map {
const out = new Map();
for (const a of m.assets) {
out.set(a.id, wrap(a.id, a.width, a.height, single(a)));
if (a.type === 'spritesheet') {
const { width, height } = cellSize(a);
for (const c of a.cells ?? []) out.set(c.id, wrap(c.id, width, height, cellBody(c.id, width, height)));
}
}
return out;
}