512 lines
39 KiB
TypeScript
512 lines
39 KiB
TypeScript
/**
|
||
* 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 = `<path d="M100 520 Q ${100 + bend} 340 ${100 + bend * 1.6} 170" fill="none" stroke="${C.moss}" stroke-width="9" stroke-linecap="round"/>`;
|
||
const thorns = [430, 300, 220]
|
||
.map((y, i) => `<path d="M${100 + (bend * (520 - y)) / 350 + (i % 2 ? 4 : -4)} ${y} l${i % 2 ? 12 : -12} -6 l${i % 2 ? -10 : 10} -6z" fill="${C.moss}"/>`)
|
||
.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 =>
|
||
`<ellipse cx="${x + dir * 30}" cy="${y}" rx="34" ry="14" fill="${C.leaf}" stroke="${C.ink}" stroke-width="3" transform="rotate(${rot} ${x} ${y})"/>`;
|
||
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'
|
||
? `<path d="M100 ${130 - r * 1.6} C ${100 + r} ${130 - r}, ${100 + r} ${130 + r * 0.6}, 100 ${130 + r * 0.7} C ${100 - r} ${130 + r * 0.6}, ${100 - r} ${130 - r}, 100 ${130 - r * 1.6}z" fill="${C.rose}" stroke="${C.ink}" stroke-width="3"/>
|
||
<path d="M70 ${150} q30 20 60 0 l-8 18 h-44z" fill="${C.leaf}" stroke="${C.ink}" stroke-width="3"/>`
|
||
: Array.from({ length: count }, (_, i) => {
|
||
const a = (i / count) * Math.PI * 2;
|
||
return `<circle cx="${(100 + Math.cos(a) * r * 0.55).toFixed(1)}" cy="${(130 + Math.sin(a) * r * 0.55).toFixed(1)}" r="${(r * 0.55).toFixed(1)}" fill="${C.rose}" stroke="${C.ink}" stroke-width="3"/>`;
|
||
}).join('') + `<circle cx="100" cy="130" r="${(r * 0.62).toFixed(1)}" fill="${C.petal}" stroke="${C.ink}" stroke-width="3"/>`;
|
||
|
||
const eye = (x: number): string => {
|
||
const y = 124;
|
||
switch (look.eyes) {
|
||
case 'open': return `<circle cx="${x}" cy="${y}" r="4.5" fill="${C.ink}"/>`;
|
||
case 'half': return `<path d="M${x - 6} ${y} q6 5 12 0" fill="${C.ink}" stroke="${C.ink}" stroke-width="3"/>`;
|
||
case 'closed': return `<path d="M${x - 6} ${y} q6 6 12 0" fill="none" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`;
|
||
case 'down': return `<path d="M${x - 6} ${y + 3} q6 4 12 0" fill="none" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`;
|
||
case 'squeeze': return `<path d="M${x - 6} ${y - 4} l12 4 l-12 4" fill="none" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`;
|
||
}
|
||
};
|
||
const mouth = {
|
||
smile: `<path d="M93 142 q7 7 14 0" fill="none" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`,
|
||
small: `<path d="M96 144 h8" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`,
|
||
open: `<ellipse cx="100" cy="145" rx="6" ry="5" fill="${C.ink}"/>`,
|
||
puff: `<circle cx="100" cy="145" r="4" fill="${C.ink}"/><circle cx="84" cy="140" r="7" fill="${C.blush}" opacity=".7"/><circle cx="116" cy="140" r="7" fill="${C.blush}" opacity=".7"/>`
|
||
}[look.mouth];
|
||
const blush = look.blush ? `<circle cx="82" cy="138" r="8" fill="${C.blush}"/><circle cx="118" cy="138" r="8" fill="${C.blush}"/>` : '';
|
||
const face = look.back ? '' : eye(91) + eye(109) + mouth + blush;
|
||
const drops = look.drops
|
||
? [[64, 92], [138, 104], [120, 70]].map(([x, y]) => `<path d="M${x} ${y} q5 9 0 12 q-5 -3 0 -12z" fill="#9cc3d8" stroke="${C.ink}" stroke-width="2"/>`).join('')
|
||
: '';
|
||
const bloom = `<g transform="translate(${bend * 1.6} 0) rotate(${look.tilt ?? 0} 100 170)">${petals}${face}${drops}</g>`;
|
||
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 => `<path d="M${x} ${y0} V ${y1}" stroke="${C.foxLeg}" stroke-width="14" stroke-linecap="round"/>`;
|
||
const thick = look.fluffed ? 8 : 0;
|
||
const tail = (d: string): string =>
|
||
`<path d="${d}" fill="none" stroke="${C.ink}" stroke-width="${38 + thick}" stroke-linecap="round"/>` +
|
||
`<path d="${d}" fill="none" stroke="${C.fox}" stroke-width="${30 + thick}" stroke-linecap="round"/>` +
|
||
`<path d="${d}" fill="none" stroke="${C.foxLeg}" stroke-width="${32 + thick}" stroke-dasharray="6 26" opacity=".45"/>`;
|
||
const head = (x: number, y: number, r: number): string => {
|
||
const k = look.back ? -1 : 1;
|
||
const ears = [-0.55, 0.35].map((o) => `<path d="M${x + o * r * k - 12} ${y - r * 0.6} l12 -${r * 0.9} l12 ${r * 0.9}z" fill="${C.fox}" ${ink}/>`).join('');
|
||
if (look.behind) return ears + `<circle cx="${x}" cy="${y}" r="${r}" fill="${C.fox}" ${ink}/>`;
|
||
const eye = (ex: number): string =>
|
||
look.eyes === 'open'
|
||
? `<circle cx="${ex}" cy="${y - 4}" r="4" fill="${C.ink}"/>`
|
||
: `<path d="M${ex - 6} ${y - 4} q6 ${look.eyes === 'half' ? 4 : 6} 12 0" fill="${look.eyes === 'half' ? C.ink : 'none'}" stroke="${C.ink}" stroke-width="3" stroke-linecap="round"/>`;
|
||
const snout = x - k * r * 0.75;
|
||
return ears + `<g transform="rotate(${look.tilt ?? 0} ${x} ${y})"><circle cx="${x}" cy="${y}" r="${r}" fill="${C.fox}" ${ink}/>
|
||
<ellipse cx="${snout + k * 6}" cy="${y + r * 0.35}" rx="${r * 0.55}" ry="${r * 0.38}" fill="${C.cream}" ${ink}/>
|
||
<circle cx="${x - k * 12}" cy="${y - r * 0.45}" r="5" fill="${C.cream}"/><circle cx="${x + k * 10}" cy="${y - r * 0.45}" r="5" fill="${C.cream}"/>
|
||
${eye(x - k * 13)}${eye(x + k * 9)}<circle cx="${snout - k * 6}" cy="${y + r * 0.3}" r="5" fill="${C.ink}"/>
|
||
${look.petal ? `<ellipse cx="${snout - k * 10}" cy="${y + r * 0.75}" rx="16" ry="9" fill="${C.cream}" ${ink}/>` : ''}</g>`;
|
||
};
|
||
let body: string;
|
||
switch (look.pose) {
|
||
case 'sit':
|
||
body = tail('M185 215 Q 250 205 240 150') + `<ellipse cx="160" cy="150" rx="50" ry="64" fill="${C.fox}" ${ink}/>`
|
||
+ `<ellipse cx="148" cy="160" rx="24" ry="38" fill="${C.cream}"/>` + 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)
|
||
+ `<ellipse cx="165" cy="128" rx="80" ry="38" fill="${C.fox}" ${ink}/>` + head(look.back ? 215 : 80, 98, 34);
|
||
break;
|
||
case 'lie':
|
||
body = tail('M250 205 Q 285 215 290 180') + `<ellipse cx="170" cy="192" rx="92" ry="30" fill="${C.fox}" ${ink}/>`
|
||
+ leg(70, 215, 222) + head(72, 178, 32);
|
||
break;
|
||
case 'curl':
|
||
body = `<circle cx="150" cy="160" r="66" fill="${C.fox}" ${ink}/>` + tail('M205 200 Q 170 235 110 205') + head(125, 168, 30);
|
||
break;
|
||
}
|
||
return look.right ? `<g transform="translate(300 0) scale(-1 1)">${body}</g>` : body;
|
||
}
|
||
|
||
const FOXES: Record<string, FoxLook> = {
|
||
'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 `<g transform="translate(${((W - w * s) / 2).toFixed(1)} ${((H - h * s) / 2).toFixed(1)}) scale(${s.toFixed(4)})">${body}</g>`;
|
||
}
|
||
|
||
const ROSES: Record<string, RoseLook> = {
|
||
'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<string, string> = {
|
||
'watering-can': `<rect x="50" y="80" width="90" height="80" rx="18" fill="${C.leaf}" stroke="${C.ink}" stroke-width="5"/>
|
||
<path d="M60 80 q35 -55 70 0" fill="none" stroke="${C.ink}" stroke-width="7"/>
|
||
<path d="M52 110 L12 70" stroke="${C.ink}" stroke-width="10" stroke-linecap="round"/><circle cx="12" cy="68" r="10" fill="${C.leaf}" stroke="${C.ink}" stroke-width="4"/>`,
|
||
windbreak: Array.from({ length: 9 }, (_, i) => `<path d="M${30 + i * 18} ${150 - Math.sin((i / 8) * Math.PI) * 18} v-${90 - Math.sin((i / 8) * Math.PI) * 10}" stroke="${C.wood}" stroke-width="12" stroke-linecap="round"/>`).join('')
|
||
+ `<path d="M24 100 Q100 75 176 100" fill="none" stroke="${C.soil}" stroke-width="6"/><path d="M24 128 Q100 103 176 128" fill="none" stroke="${C.soil}" stroke-width="6"/>
|
||
<path d="M30 150 v30 M170 150 v30" stroke="${C.soil}" stroke-width="8" stroke-linecap="round"/>`,
|
||
'weed-clump': [60, 100, 140].map((x, i) => `<path d="M${x} 140 l-18 -${60 + i * 12} l14 12 l4 -${30 + i * 6} l8 24 l12 -20 l-6 ${60 + i * 8}z" fill="${C.leaf}" stroke="${C.ink}" stroke-width="4"/>`).join('')
|
||
+ `<path d="M70 140 q10 30 -6 44 M100 140 q-4 26 10 40 M130 140 q8 22 -2 38" fill="none" stroke="${C.soil}" stroke-width="4"/>`,
|
||
'fallen-petals': [[60, 110, -20], [110, 90, 25], [140, 130, 60]].map(([x, y, r]) => `<ellipse cx="${x}" cy="${y}" rx="34" ry="22" fill="${C.rose}" stroke="${C.ink}" stroke-width="4" transform="rotate(${r} ${x} ${y})"/>`).join(''),
|
||
'petal-folded': `<circle cx="100" cy="100" r="86" fill="${C.lamp}" opacity=".35"/><path d="M100 30 C 170 60, 160 160, 100 170 C 40 160, 30 60, 100 30z" fill="${C.rose}" stroke="${C.ink}" stroke-width="5"/>
|
||
<path d="M100 30 C 120 90, 120 130, 100 170" fill="none" stroke="${C.petal}" stroke-width="6"/>`,
|
||
'petal-open': `<path d="M100 20 C 190 50, 190 160, 100 182 C 10 160, 10 50, 100 20z" fill="${C.petal}" stroke="${C.ink}" stroke-width="5"/>`,
|
||
'garden-chair': `<rect x="60" y="40" width="80" height="70" rx="8" fill="${C.wood}" stroke="${C.ink}" stroke-width="5"/>
|
||
<path d="M70 55 h60 M70 75 h60 M70 95 h60" stroke="${C.soil}" stroke-width="4"/>
|
||
<path d="M50 110 h100 l-10 24 h-80z" fill="${C.petal}" stroke="${C.ink}" stroke-width="5"/>
|
||
<path d="M62 134 v46 M138 134 v46 M80 134 v36 M120 134 v36" stroke="${C.wood}" stroke-width="9" stroke-linecap="round"/>`
|
||
};
|
||
|
||
const berries = (fill: string, at: readonly (readonly [number, number])[], r: number, leaves = 1): string =>
|
||
Array.from({ length: leaves }, (_, i) => `<ellipse cx="${80 + i * 40}" cy="58" rx="30" ry="13" fill="${C.leaf}" stroke="${C.ink}" stroke-width="4" transform="rotate(${i ? 25 : -25} ${80 + i * 40} 58)"/>`).join('')
|
||
+ `<path d="M100 40 V 80" stroke="${C.moss}" stroke-width="5"/>`
|
||
+ at.map(([x, y]) => `<circle cx="${x}" cy="${y}" r="${r}" fill="${fill}" stroke="${C.ink}" stroke-width="4"/>`).join('');
|
||
|
||
const bush = (extra: string): string =>
|
||
[[60, 120, 50], [140, 120, 50], [100, 80, 56], [100, 140, 46]].map(([x, y, r]) => `<circle cx="${x}" cy="${y}" r="${r}" fill="${C.leaf}" stroke="${C.ink}" stroke-width="4"/>`).join('')
|
||
+ `<path d="M70 70 q30 -14 60 0 M50 120 q20 -10 40 0 M115 125 q20 -10 40 0" fill="none" stroke="${C.moss}" stroke-width="4"/>` + extra;
|
||
|
||
/** The fox's food and the bush, each in a 200 × 200 box like PROPS. */
|
||
const MORE_PROPS: Record<string, string> = {
|
||
'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': `<circle cx="100" cy="115" r="80" fill="${C.lamp}" opacity=".3"/><path d="M100 30 V 70 M100 70 L 70 90 M100 70 L 130 90" stroke="${C.moss}" stroke-width="5" fill="none"/>`
|
||
+ [[70, 125], [130, 125]].map(([x, y]) => `<ellipse cx="${x}" cy="${y}" rx="24" ry="34" fill="${C.hip}" stroke="${C.ink}" stroke-width="4"/><path d="M${(x ?? 0) - 8} ${(y ?? 0) + 34} l8 10 l8 -10" fill="${C.foxLeg}"/>`).join(''),
|
||
'leaf-plate': `<path d="M20 110 Q 100 10 185 100 Q 100 190 20 110z" fill="${C.leaf}" stroke="${C.ink}" stroke-width="5"/><path d="M20 110 Q 100 100 185 100" fill="none" stroke="${C.moss}" stroke-width="5"/>`,
|
||
'bush-resting': bush(''),
|
||
'bush-flowering': bush([[55, 100], [100, 60], [145, 105], [90, 135], [125, 150]].map(([x, y]) => `<circle cx="${x}" cy="${y}" r="9" fill="${C.paper}" stroke="${C.ink}" stroke-width="3"/><circle cx="${x}" cy="${y}" r="3" fill="${C.amber}"/>`).join('')),
|
||
'bush-ripe': bush([[60, 105], [138, 108], [100, 70]].map(([x, y]) => `<ellipse cx="${x}" cy="${y}" rx="20" ry="15" fill="${C.lamp}" stroke="${C.moss}" stroke-width="3"/>`).join('')),
|
||
'fox-brush': `<path d="M30 110 Q 30 70 100 70 Q 170 70 170 110z" fill="${C.wood}" stroke="${C.ink}" stroke-width="5"/>`
|
||
+ Array.from({ length: 12 }, (_, i) => `<path d="M${40 + i * 11} 112 v26" stroke="${C.cream}" stroke-width="6" stroke-linecap="round"/>`).join('')
|
||
};
|
||
|
||
const meadow = (path: string): string =>
|
||
`<ellipse cx="100" cy="200" rx="92" ry="190" fill="${C.meadow}" stroke="${C.ink}" stroke-width="3" stroke-dasharray="10 8"/>${path}`;
|
||
const lantern = (lit: boolean): string =>
|
||
(lit ? `<circle cx="140" cy="170" r="60" fill="${C.lamp}" opacity=".45"/>` : '')
|
||
+ `<path d="M60 390 V 80 Q 60 40 100 40 Q 140 40 140 80 V 110" fill="none" stroke="${C.wood}" stroke-width="14" stroke-linecap="round"/>`
|
||
+ `<rect x="115" y="130" width="50" height="72" rx="8" fill="${lit ? C.lamp : '#e8eef0'}" stroke="${C.ink}" stroke-width="5"/>`
|
||
+ `<path d="M115 130 l25 -18 l25 18" fill="${C.foxLeg}" stroke="${C.ink}" stroke-width="4"/>`
|
||
+ `<rect x="133" y="160" width="14" height="30" fill="${C.paper}" stroke="${C.ink}" stroke-width="3"/>`
|
||
+ (lit ? `<path d="M140 160 q-8 -12 0 -22 q8 10 0 22z" fill="${C.amber}" stroke="${C.ink}" stroke-width="2"/>` : '');
|
||
|
||
/** Tall things, each in a 200 × 400 box: the path stretches and the lanterns. */
|
||
const TALL: Record<string, string> = {
|
||
'path-prints': meadow([340, 290, 240, 190, 140, 95, 55].map((y, i) => `<ellipse cx="${100 + (i % 2 ? 12 : -12) * (1 - i / 9)}" cy="${y}" rx="${9 - i}" ry="${7 - i * 0.7}" fill="${C.soil}"/>`).join('')),
|
||
'path-trail': meadow(`<path d="M92 385 Q 120 260 96 160 T 100 15" fill="none" stroke="#c8d8a8" stroke-width="22" stroke-linecap="round"/><path d="M92 385 Q 120 260 96 160 T 100 15" fill="none" stroke="${C.soil}" stroke-width="5" stroke-dasharray="4 18"/>`),
|
||
'path-road': meadow(`<path d="M60 388 Q 110 260 88 160 T 92 15 L 108 15 Q 120 120 112 170 T 140 388z" fill="${C.soil}" stroke="${C.ink}" stroke-width="4"/>`
|
||
+ [[52, 360], [148, 360], [70, 260], [130, 255], [80, 160], [118, 150], [88, 70], [110, 65]].map(([x, y]) => `<circle cx="${x}" cy="${y}" r="7" fill="#c9bcae" stroke="${C.ink}" stroke-width="2"/>`).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<string, string> = {
|
||
'weeds-growing': `<ellipse cx="100" cy="160" rx="80" ry="22" fill="${C.soil}" opacity=".85"/>`
|
||
+ [70, 100, 130].map((x, i) => `<path d="M${x} 160 l-14 -${40 + i * 10} l12 10 l2 -${22 + i * 5} l8 18 l10 -16 l-4 ${44 + i * 8}z" fill="${C.leaf}" ${ink()}/>`).join(''),
|
||
'watering-can-pouring': `<g transform="rotate(24 100 110)"><rect x="70" y="80" width="90" height="80" rx="18" fill="${C.leaf}" ${ink(5)}/>`
|
||
+ `<path d="M80 80 q35 -55 70 0" fill="none" ${ink(7)}/><path d="M72 110 L32 70" ${ink(10)} stroke-linecap="round"/></g>`
|
||
+ `<path d="M24 66 q-6 40 -4 90" fill="none" stroke="#9cc3d8" stroke-width="6" stroke-linecap="round"/>`
|
||
+ [[16, 170], [30, 182]].map(([x, y]) => `<circle cx="${x}" cy="${y}" r="5" fill="#9cc3d8" ${ink(2)}/>`).join(''),
|
||
'wind-gust': [60, 100, 140].map((y, i) => `<path d="M20 ${y} q60 -30 110 0 t60 -10" fill="none" stroke="${i === 1 ? C.cream : C.petal}" stroke-width="10" stroke-linecap="round"/>`).join('')
|
||
+ `<ellipse cx="150" cy="70" rx="16" ry="7" fill="${C.leaf}" ${ink(3)} transform="rotate(-30 150 70)"/><ellipse cx="80" cy="150" rx="14" ry="6" fill="${C.leaf}" ${ink(3)} transform="rotate(20 80 150)"/>`,
|
||
'water-drops': [[70, 80, 14], [120, 70, 10], [100, 120, 16], [140, 130, 9], [60, 140, 8]].map(([x, y, r]) => `<path d="M${x} ${(y ?? 0) - (r ?? 0) * 1.6} q${r} ${(r ?? 0) * 1.6} 0 ${(r ?? 0) * 2.6} q-${r} -${r} 0 -${(r ?? 0) * 2.6}z" fill="#9cc3d8" ${ink(3)}/>`).join(''),
|
||
'letter-header': `<rect x="20" y="60" width="160" height="110" rx="6" fill="${C.wood}" ${ink()}/>`
|
||
+ `<path d="M40 70 h120 v90 h-120z" fill="${C.paper}" ${ink(3)}/><path d="M100 70 v90" stroke="${C.ink}" stroke-width="2"/>`
|
||
+ `<ellipse cx="128" cy="110" rx="18" ry="11" fill="${C.rose}" ${ink(3)} transform="rotate(-25 128 110)"/><path d="M60 150 q20 -40 40 -60" fill="none" stroke="${C.moss}" stroke-width="4"/>`,
|
||
'geographers-book': `<path d="M20 70 q40 -14 80 0 q40 -14 80 0 v90 q-40 -14 -80 0 q-40 -14 -80 0z" fill="${C.paper}" ${ink(5)}/>`
|
||
+ `<path d="M100 70 v90" ${ink(3)}/><path d="M16 66 v100 h168 v-100" fill="none" stroke="${C.moss}" stroke-width="8"/>`
|
||
+ [92, 110, 128].map((y) => `<path d="M34 ${y} h52 M114 ${y} h52" stroke="#d8cfc4" stroke-width="2"/>`).join('')
|
||
+ `<path d="M120 160 v30 l6 -8 l6 8 v-30" fill="${C.amber}" ${ink(2)}/>`,
|
||
'petal-trace': `<path d="M100 30 C 175 55, 170 165, 100 175 C 35 165, 30 60, 100 30z" fill="${C.cream}" ${ink(5)}/><path d="M100 50 q20 50 0 110" fill="none" stroke="#e0cfb2" stroke-width="3"/>`,
|
||
'foxes-meeting': `<svg x="0" y="50" width="200" height="100" viewBox="0 0 600 260">${fox({ pose: 'sit', eyes: 'half', right: true })}<g transform="translate(300 0)">${fox({ pose: 'sit', eyes: 'half' })}</g></svg>`,
|
||
'visitor-hedgehog': `<ellipse cx="110" cy="120" rx="62" ry="40" fill="${C.wood}" ${ink()}/>`
|
||
+ `<ellipse cx="54" cy="128" rx="26" ry="20" fill="${C.cream}" ${ink()}/><circle cx="30" cy="130" r="5" fill="${C.ink}"/><circle cx="50" cy="120" r="3.5" fill="${C.ink}"/>`
|
||
+ Array.from({ length: 7 }, (_, i) => `<path d="M${90 + i * 13} 86 l6 -18 l6 18" fill="${C.foxLeg}"/>`).join(''),
|
||
'visitor-robin': `<ellipse cx="110" cy="110" rx="50" ry="40" fill="#8a7a52" ${ink()}/><circle cx="74" cy="92" r="26" fill="#8a7a52" ${ink()}/>`
|
||
+ `<ellipse cx="86" cy="116" rx="26" ry="24" fill="${C.coral}"/><path d="M48 92 l-16 4 l16 4z" fill="${C.wood}" ${ink(2)}/><circle cx="68" cy="86" r="3.5" fill="${C.ink}"/><path d="M150 106 l34 -8 l-10 22z" fill="#8a7a52" ${ink(3)}/>`,
|
||
'visitor-snail': `<circle cx="120" cy="105" r="42" fill="${C.wood}" ${ink()}/><path d="M120 105 m-26 0 a26 26 0 1 1 26 26 a14 14 0 1 1 -14 -14" fill="none" ${ink(3)}/>`
|
||
+ `<path d="M30 150 h150 q-10 -14 -40 -14 h-70 q-30 -10 -40 -40" fill="${C.cream}" ${ink()}/><path d="M42 98 l-6 -26 M54 100 l2 -26" ${ink(3)}/>`,
|
||
'visitor-moth': `<path d="M100 100 q-70 -60 -80 10 q20 40 80 0z M100 100 q70 -60 80 10 q-20 40 -80 0z" fill="${C.cream}" ${ink()}/>`
|
||
+ `<ellipse cx="100" cy="110" rx="9" ry="30" fill="${C.wood}" ${ink(3)}/><circle cx="62" cy="96" r="9" fill="${C.lamp}"/><circle cx="138" cy="96" r="9" fill="${C.lamp}"/><path d="M96 82 q-10 -24 -26 -30 M104 82 q10 -24 26 -30" fill="none" ${ink(3)}/>`,
|
||
'visitor-ladybird': `<ellipse cx="100" cy="110" rx="60" ry="50" fill="${C.strawberry}" ${ink()}/><path d="M100 60 v100" ${ink(3)}/><circle cx="100" cy="64" r="22" fill="${C.ink}"/>`
|
||
+ [[74, 100], [126, 100], [80, 135], [120, 135]].map(([x, y]) => `<circle cx="${x}" cy="${y}" r="9" fill="${C.ink}"/>`).join(''),
|
||
'visitor-owl': `<ellipse cx="100" cy="115" rx="56" ry="66" fill="${C.wood}" ${ink()}/><ellipse cx="100" cy="135" rx="34" ry="38" fill="${C.cream}"/>`
|
||
+ `<path d="M76 84 q8 6 16 0 M108 84 q8 6 16 0" fill="none" ${ink(3)}/><path d="M96 96 l4 8 l4 -8z" fill="${C.amber}"/><path d="M50 60 l14 14 M150 60 l-14 14" ${ink(5)}/>`,
|
||
'memento-feather': `<path d="M40 160 Q 100 30 170 40 Q 130 120 40 160z" fill="#b8b0a8" ${ink()}/><path d="M40 160 Q 110 90 170 40" fill="none" stroke="${C.coral}" stroke-width="3"/>`,
|
||
'memento-pebble': `<ellipse cx="100" cy="110" rx="70" ry="46" fill="#c9c4bc" ${ink()}/><path d="M50 100 q50 20 100 4" fill="none" stroke="${C.paper}" stroke-width="5"/>`,
|
||
'memento-acorn-cup': `<path d="M50 100 q50 70 100 0z" fill="${C.wood}" ${ink()}/><path d="M50 100 h100" ${ink()}/><path d="M100 100 v-30" stroke="${C.foxLeg}" stroke-width="6"/>`,
|
||
'memento-snail-shell': `<circle cx="100" cy="105" r="56" fill="${C.wood}" ${ink()}/><path d="M100 105 m-34 0 a34 34 0 1 1 34 34 a18 18 0 1 1 -18 -18" fill="none" ${ink(3)}/>`,
|
||
'memento-pressed-flower': `<path d="M100 170 V 90" stroke="${C.moss}" stroke-width="5"/><ellipse cx="80" cy="140" rx="18" ry="8" fill="${C.leaf}" ${ink(3)} transform="rotate(-30 80 140)"/>`
|
||
+ Array.from({ length: 5 }, (_, i) => { const a = (i / 5) * Math.PI * 2; return `<circle cx="${(100 + Math.cos(a) * 22).toFixed(1)}" cy="${(70 + Math.sin(a) * 22).toFixed(1)}" r="16" fill="#a9c1e0" ${ink(3)}/>`; }).join('') + `<circle cx="100" cy="70" r="8" fill="${C.amber}"/>`,
|
||
'memento-seed-head': `<path d="M100 190 V 100" stroke="${C.moss}" stroke-width="5"/><circle cx="100" cy="80" r="50" fill="${C.paper}" ${ink(3)} stroke-dasharray="4 6"/>`
|
||
+ Array.from({ length: 10 }, (_, i) => { const a = (i / 10) * Math.PI * 2; return `<path d="M100 80 l${(Math.cos(a) * 46).toFixed(1)} ${(Math.sin(a) * 46).toFixed(1)}" stroke="#d8d4cc" stroke-width="2"/>`; }).join(''),
|
||
'sky-light': `<circle cx="100" cy="100" r="80" fill="${C.lamp}" opacity=".3"/><circle cx="100" cy="100" r="40" fill="${C.lamp}" opacity=".7"/><circle cx="100" cy="100" r="16" fill="${C.paper}"/>`
|
||
};
|
||
|
||
const streetLamp = (lit: boolean): string =>
|
||
(lit ? `<circle cx="100" cy="70" r="56" fill="${C.lamp}" opacity=".45"/>` : '')
|
||
+ `<path d="M100 390 V 110" stroke="${C.foxLeg}" stroke-width="12"/><path d="M80 390 h40" ${ink(8)}/>`
|
||
+ `<path d="M76 110 h48 l-8 -60 h-32z" fill="${lit ? C.lamp : '#e8eef0'}" ${ink(5)}/><path d="M70 50 h60 l-30 -24z" fill="${C.foxLeg}" ${ink(4)}/>`;
|
||
|
||
/** Tall things added with v2, each in a 200 × 400 box. */
|
||
const V2_TALL: Record<string, string> = {
|
||
'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<string, string> = {
|
||
'planet-king': `<rect x="-60" y="-150" width="120" height="150" rx="14" fill="#7a4f6e" ${ink(5)}/><path d="M-30 -60 l10 -24 l20 14 l20 -14 l10 24z" fill="${C.amber}" ${ink(3)}/><path d="M60 0 q120 30 260 120" fill="none" stroke="#7a4f6e" stroke-width="26"/>`,
|
||
'planet-vain': `<rect x="-140" y="-200" width="80" height="200" rx="40" fill="#d9e2e6" stroke="${C.amber}" stroke-width="10"/><ellipse cx="80" cy="-10" rx="90" ry="22" fill="${C.wood}" ${ink(4)}/><path d="M10 -60 v60 M150 -60 v60" stroke="${C.amber}" stroke-width="8"/><path d="M10 -55 q70 30 140 0" fill="none" stroke="#7a4f6e" stroke-width="8"/>`,
|
||
'planet-businessman': `<rect x="-130" y="-80" width="260" height="20" fill="${C.wood}" ${ink(4)}/><path d="M-120 -60 v60 M120 -60 v60" ${ink(8)}/>`
|
||
+ [[-100, 6], [-60, 4], [40, 7]].map(([x, n]) => Array.from({ length: n ?? 0 }, (_, i) => `<rect x="${x}" y="${-96 - i * 14}" width="50" height="12" fill="${C.paper}" ${ink(2)}/>`).join('')).join('') + `<rect x="100" y="-120" width="40" height="40" fill="${C.foxLeg}" ${ink(3)}/>`,
|
||
'planet-lamplighter': `<g transform="translate(-100 -390)">${streetLamp(false)}</g><path d="M60 0 L 120 -260" stroke="${C.wood}" stroke-width="10"/>`,
|
||
'planet-geographer': `<rect x="-150" y="-80" width="300" height="20" fill="${C.wood}" ${ink(4)}/><path d="M-130 -60 v60 M130 -60 v60" ${ink(8)}/><path d="M-90 -80 q50 -20 90 0 q40 -20 90 0 v-50 q-50 -20 -90 0 q-40 -20 -90 0z" fill="${C.paper}" ${ink(3)}/><circle cx="120" cy="-100" r="16" fill="none" ${ink(4)}/>`
|
||
};
|
||
return `<path d="M0 ${H} V ${top + 60} Q ${W * 0.2} ${top} ${W / 2} ${top - 10} T ${W} ${top + 60} V ${H}z" fill="${C.meadow}" ${ink(5)}/>`
|
||
+ `<path d="M0 ${H - 120} H ${W}" stroke="${C.paper}" stroke-width="240" opacity=".5"/>`
|
||
+ `<g transform="translate(${W / 2} ${top - 4}) scale(1.8)">${drawing(things, id)}</g>`;
|
||
}
|
||
|
||
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'
|
||
? `<path d="M52 160 h26 v34 M62 160 h26 v34" stroke="${boy ? cloth : skin}" stroke-width="12" fill="none" stroke-linecap="round"/>`
|
||
: `<path d="M52 196 V 150 M70 196 V 150" stroke="${boy ? cloth : skin}" stroke-width="${boy ? 14 : 10}" stroke-linecap="round"/>`;
|
||
const body = boy
|
||
? `<path d="M44 92 Q 42 130 46 152 H 76 Q 80 130 78 92 Z" fill="${cloth}" ${ink(4)}/>`
|
||
: `<path d="M44 92 Q 36 136 34 156 H 88 Q 86 136 78 92 Z" fill="${cloth}" ${ink(4)}/>`;
|
||
const held = pose === 'pour' ? `<rect x="84" y="128" width="26" height="20" rx="6" fill="${C.leaf}" ${ink(3)} transform="rotate(30 97 138)"/>`
|
||
: pose === 'carry' ? Array.from({ length: 4 }, (_, i) => `<path d="M${80 + i * 8} 150 v -40" stroke="${C.wood}" stroke-width="6" stroke-linecap="round"/>`).join('') : '';
|
||
const braids = boy ? '' : `<path d="M44 58 v 30 M78 58 v 30" stroke="${hair}" stroke-width="7" stroke-linecap="round"/>`;
|
||
return `${legs}<path d="M44 198 h18 M64 198 h18" ${ink(7)} stroke-linecap="round"/>
|
||
<g transform="rotate(${lean} 61 150)">${body}<path d="M50 100 H 72 V 146 Q 61 152 50 146 Z" fill="${apron}" ${ink(3)}/>
|
||
<path d="M44 98 l -8 40" stroke="${skin}" stroke-width="9" stroke-linecap="round"/>
|
||
<g transform="rotate(${arm} 78 98)"><path d="M78 98 l 4 40" stroke="${skin}" stroke-width="9" stroke-linecap="round"/></g>${held}
|
||
${braids}<circle cx="61" cy="66" r="20" fill="${skin}" ${ink(4)}/>
|
||
<path d="M41 62 Q 61 36 81 62 Q 61 52 41 62 Z" fill="${hair}"/>
|
||
<ellipse cx="61" cy="50" rx="34" ry="7" fill="#e6c98a" ${ink(3)}/><path d="M47 50 Q 61 28 75 50 Z" fill="#e6c98a" ${ink(3)}/>
|
||
<circle cx="66" cy="66" r="2.5" fill="${C.ink}"/><circle cx="74" cy="66" r="2.5" fill="${C.ink}"/><path d="M66 76 q 4 3 8 0" fill="none" ${ink(2.5)}/></g>`;
|
||
}
|
||
|
||
const GARDENER_POSES: Record<string, Pose> = {
|
||
'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 `<circle cx="${cx}" cy="${cy}" r="${r}" fill="${meadow}" ${ink(8)}/>
|
||
<ellipse cx="${cx}" cy="${cy - r + 6}" rx="${r * 0.32}" ry="${r * 0.07}" fill="${C.soil}" ${ink(5)}/>
|
||
<path d="M${cx - r * 0.55} ${cy - r * 0.8} Q ${cx} ${cy - r * 1.1} ${cx + r * 0.5} ${cy - r * 0.84}" fill="none" stroke="#a8957f" stroke-width="22" stroke-linecap="round"/>
|
||
<g transform="translate(${cx + r * 0.8} ${cy - r * 0.6}) rotate(55)"><rect x="-26" y="-60" width="52" height="40" rx="5" fill="${C.wood}" ${ink(4)}/><rect x="-30" y="-24" width="60" height="10" fill="${C.petal}" ${ink(4)}/></g>`;
|
||
}
|
||
|
||
/** 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 `<path d="M0 ${H} V ${H * 0.55} Q ${W * 0.06} ${H * 0.7} ${W * 0.1} ${H * 0.75} Q ${W / 2} ${H * 0.7} ${W * 0.9} ${H * 0.75} Q ${W * 0.94} ${H * 0.7} ${W} ${H * 0.55} V ${H}z" fill="#3c4a6a" ${ink(5)}/>`
|
||
+ `<path d="M0 ${H * 0.86} Q ${W / 2} ${H * 0.8} ${W} ${H * 0.86}" stroke="#46557a" stroke-width="60" fill="none"/>`
|
||
+ [[0.2, 0.84], [0.7, 0.82]].map(([x, y]) => `<circle cx="${W * (x ?? 0)}" cy="${H * (y ?? 0)}" r="8" fill="${C.lamp}"/>`).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 `<path d="M0 ${h} Q ${W * 0.3} ${h - 18} ${W * 0.55} ${h - 6} T ${W} ${h + 4} V ${H} H 0z" fill="${tint.far}"/>
|
||
<path d="M0 ${h + 90} Q ${W * 0.5} ${h + 50} ${W} ${h + 110} V ${H} H 0z" fill="${tint.field}"/>
|
||
<path d="M${W * 0.12} ${bedY - 70} Q ${W * 0.5} ${bedY - 150} ${W * 0.88} ${bedY - 70}" fill="none" stroke="${tint.wall}" stroke-width="44" stroke-linecap="round"/>
|
||
<ellipse cx="${W / 2}" cy="${bedY}" rx="${W * 0.3}" ry="${H * 0.05}" fill="${C.soil}" stroke="${C.ink}" stroke-width="5"/>
|
||
<circle cx="${time === 'sunset' ? 80 : W - 80}" cy="${h + 60}" r="26" fill="${tint.light}" opacity=".8"/>
|
||
<path d="M0 ${h} H ${W}" stroke="${C.ink}" stroke-width="3" stroke-dasharray="14 10"/>`;
|
||
}
|
||
|
||
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) => `<g transform="translate(${90 + i * 360} ${y}) scale(${i === 3 ? '-2' : '2'} 2) translate(${i === 3 ? -120 : 0} 0)">${gardener('stand', boy)}</g>`).join('');
|
||
return `<rect width="${W}" height="${H}" fill="${C.paper}"/>${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) => `<g transform="translate(${30 + i * 375} 60) scale(1.15)">${fox(l)}</g>`).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) => `<svg x="${200 + i * 400}" y="620" width="320" height="320" viewBox="90 10 120 120">${fox(l)}</svg>`).join('');
|
||
return `<rect width="${W}" height="${H}" fill="${C.paper}"/>${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) => `<g transform="translate(${60 + i * 360} 40) scale(1.15)">${rose(l)}</g>`).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) => `<svg x="${200 + i * 400}" y="660" width="320" height="320" viewBox="10 40 180 180">${rose(l)}</svg>`).join('');
|
||
return `<rect width="${W}" height="${H}" fill="${C.paper}"/>${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 `<circle cx="${(W / 2 + Math.cos(t) * W * 0.17).toFixed(1)}" cy="${(H / 2 + Math.sin(t) * H * 0.17).toFixed(1)}" r="${W * 0.17}" fill="${C.rose}" ${ink(12)}/>`;
|
||
}).join('');
|
||
return `<rect width="${W}" height="${H}" fill="${C.amber}"/>${petals}<circle cx="${W / 2}" cy="${H / 2}" r="${W * 0.16}" fill="${C.petal}" ${ink(12)}/>`;
|
||
}
|
||
if (a.id === 'app-icon-maskable') {
|
||
return `<rect width="${W}" height="${H}" fill="${C.coral}"/><rect y="${H / 2}" width="${W}" height="${H / 2}" fill="${C.amber}" opacity=".6"/>
|
||
<circle cx="${W / 2}" cy="${H / 2}" r="${W * 0.3}" fill="none" stroke="${C.paper}" stroke-width="4" stroke-dasharray="16 12"/>
|
||
<svg x="${W * 0.25}" y="${H * 0.22}" width="${W * 0.5}" height="${H * 0.56}" viewBox="0 30 200 230">${rose({ stage: 'full', eyes: 'half', mouth: 'smile', blush: true })}</svg>`;
|
||
}
|
||
return `<rect width="${W}" height="${H}" fill="${C.coral}"/><rect y="${H / 2}" width="${W}" height="${H / 2}" fill="${C.amber}" opacity=".6"/>
|
||
<svg x="${W * 0.15}" y="${H * 0.12}" width="${W * 0.7}" height="${H * 0.76}" viewBox="0 30 200 230">${rose({ stage: 'full', eyes: 'half', mouth: 'smile', blush: true })}</svg>`;
|
||
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<string, string>, 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 `<svg x="${b.x0}" y="${b.y0}" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">${cellBody(c.id, w, h)}</svg>`;
|
||
})
|
||
.join('');
|
||
}
|
||
|
||
const wrap = (id: string, W: number, H: number, body: string): string =>
|
||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}">\n` +
|
||
` <!-- Stand-in for ${id} (art/placeholders, CLAUDE.md §2): form and layout only, not art. Built by tools/art-prep. -->\n` +
|
||
` ${body.replace(/\s*\n\s*/g, ' ')}\n</svg>\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<string, string> {
|
||
const out = new Map<string, string>();
|
||
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;
|
||
}
|