[art] GardenerLayers: The gardener in layered parts, painted over one guide in register, checked on accept

This commit is contained in:
2026-11-17 21:53:22 +01:00
parent 0b72ae05a2
commit 229cced136
82 changed files with 1026 additions and 83 deletions
+20 -11
View File
@@ -275,7 +275,11 @@
{ type: 'layer', title: 'Scenes', note: 'The garden at four times of day, the planets (drafts until each planet is designed), and the frame for a shared sky. The sky stays transparent: the app draws the real sky, sun and stars behind it.' },
{ type: 'sprite', title: 'Single pictures', note: 'One thing on a transparent background, placed into a scene in the app.' },
{ type: 'icon', title: 'Icons', note: 'The home-screen icon, its version for phones that crop it to a shape, and the tiny mark for browser tabs. Keep the important part in the middle; phones cut the corners.' },
{ type: 'spritesheet', key: 'layers', layers: true, title: 'Gardener layers', note: 'The gardener the player dresses is stacked from these, back to front: body (skin), clothes, apron and boots, hair, hat. Make the guide (gardener-poses-sheet, in Sprite sheets) first and accept it. Then each layer: attach the guide and gardener-sheet, and paint only the part the card names over the guide, whole sheet at once, so the parts line up. The first looks come first: once their seven are in, the girl and the boy can be judged stacked.' },
];
for (const g of GROUPS) if (!g.key) g.key = g.type;
/** A layer belongs to Gardener layers only; every other card to the group of its type. */
const inGroup = (g, a) => a.type === g.type && Boolean(g.layers) === Boolean(a.over);
const FILTERS = [['all', 'All'], ['todo', 'To make'], ['uploaded', 'To review'], ['retry', 'Another try'], ['accepted', 'Accepted']];
const STATUS_TEXT = { todo: 'To make', uploaded: 'To review', retry: 'Another try', accepted: 'Accepted' };
const EMPTY_TEXT = 'Drop, paste or choose your picture';
@@ -362,10 +366,10 @@
function applyFilter() {
for (const g of GROUPS) {
const sec = document.getElementById('group-' + g.type);
const sec = document.getElementById('group-' + g.key);
if (!sec) continue;
let shown = 0;
for (const a of data.assets.filter((x) => x.type === g.type)) {
for (const a of data.assets.filter((x) => inGroup(g, x))) {
const show = filter === 'all' || cardStatus(a) === filter;
cards[a.id].el.hidden = !show;
if (show) shown++;
@@ -407,10 +411,15 @@
refs.mine.append(refs.overlay);
refs.yields = h('ol', { class: 'yields', 'aria-label': `The ${a.cells.filter(Boolean).length} pictures this sheet makes, in reading order` },
a.cells.map((c, i) => (c ? h('li', {}, h('b', { text: String(i + 1) }), c.id) : h('li', {}, h('b', { text: String(i + 1) }), '(empty)'))));
refs.oneSummary = h('summary', { text: 'One at a time' });
refs.one = h('details', { class: 'cells-one' }, refs.oneSummary,
h('p', { class: 'muted', text: 'When the whole sheet will not keep to its grid, make each picture on its own: copy its prompt, attach the same reference picture, and upload what it made into its slot. Each is accepted on its own; the sheet is done when all its pictures are in.' }),
h('div', { class: 'cellgrid' }, a.cells.map((c, i) => (c ? buildCell(a, c, i) : null))));
if (a.over) {
// A layer is painted over its guide, whole: one picture at a time would not line up (STYLE.md §3b).
refs.one = h('p', { class: 'muted', text: `A layer: attach ${a.over} as the guide and paint only this part over it, the whole sheet at once. Its pictures are never made one at a time, or the parts would not line up.` });
} else {
refs.oneSummary = h('summary', { text: 'One at a time' });
refs.one = h('details', { class: 'cells-one' }, refs.oneSummary,
h('p', { class: 'muted', text: 'When the whole sheet will not keep to its grid, make each picture on its own: copy its prompt, attach the same reference picture, and upload what it made into its slot. Each is accepted on its own; the sheet is done when all its pictures are in.' }),
h('div', { class: 'cellgrid' }, a.cells.map((c, i) => (c ? buildCell(a, c, i) : null))));
}
}
refs.auto = h('ul', { class: 'auto', 'aria-label': 'Automatic checks' });
refs.small = h('div', { class: 'small', hidden: true });
@@ -573,7 +582,7 @@
const shown = cardStatus(a);
el.dataset.status = shown;
refs.pill.className = 'pill ' + shown; refs.pill.textContent = STATUS_TEXT[shown];
if (refs.one) {
if (refs.oneSummary) {
for (const c of cellsIn(a)) updateCell(c.id);
const done = picturesDone(a);
const waiting = cellsIn(a).filter((c) => statusOf(c.id) === 'uploaded').length;
@@ -686,10 +695,10 @@
function renderAll() {
const main = $('#groups');
main.replaceChildren(...GROUPS.map((g) => {
const list = data.assets.filter((a) => a.type === g.type);
const list = data.assets.filter((a) => inGroup(g, a));
if (!list.length) return null;
return h('section', { class: 'group', id: 'group-' + g.type, 'aria-labelledby': 'gh-' + g.type },
h('h2', { id: 'gh-' + g.type, text: `${g.title} · ${list.length}` }),
return h('section', { class: 'group', id: 'group-' + g.key, 'aria-labelledby': 'gh-' + g.key },
h('h2', { id: 'gh-' + g.key, text: `${g.title} · ${list.length}` }),
h('p', { class: 'muted', text: g.note }),
h('div', { class: 'grid' }, list.map(buildCard)));
}).filter(Boolean));
@@ -718,7 +727,7 @@
const r = rows[id];
items.push({ id, target, prompt, width: w, height: hgt, background: bg, attach: attach || [], note: statusOf(id) === 'retry' && r && r.note ? r.note : '' });
};
for (const g of GROUPS) for (const a of data.assets.filter((x) => x.type === g.type)) {
for (const g of GROUPS) for (const a of data.assets.filter((x) => inGroup(g, x))) {
if (a.type !== 'spritesheet') { if (want(statusOf(a.id))) item(a.id, a, a.prompt, a.width, a.height, a.background, a.attach); continue; }
if (cardStatus(a) === 'accepted') continue;
const cells = cellsIn(a);
+57 -1
View File
@@ -96,9 +96,53 @@ async function rgba(input: Buffer): Promise<{ px: Buffer; width: number; height:
return { px: data, width: info.width, height: info.height };
}
export async function acceptPicture(input: Buffer, id: string, m: Manifest): Promise<Accepted> {
/** Where a cell's drawing lies, as shares of the cell (0–1), or null when nothing is drawn. */
interface Extent {
readonly x0: number;
readonly y0: number;
readonly x1: number;
readonly y1: number;
}
function extent(px: Buffer, width: number, x0: number, y0: number, x1: number, y1: number): Extent | null {
let lx = Infinity, ly = Infinity, hx = -Infinity, hy = -Infinity;
for (let y = y0; y < y1; y++) {
for (let x = x0; x < x1; x++) {
if ((px[(y * width + x) * 4 + 3] ?? 0) < ALPHA) continue;
lx = Math.min(lx, x); hx = Math.max(hx, x); ly = Math.min(ly, y); hy = Math.max(hy, y);
}
}
if (lx === Infinity) return null;
const w = x1 - x0, h = y1 - y0;
return { x0: (lx - x0) / w, y0: (ly - y0) / h, x1: (hx + 1 - x0) / w, y1: (hy + 1 - y0) / h };
}
/**
* How far a layer may reach past its guide's figure, as a share of the cell: hair and a hat may
* be a little fuller than the guide's braids and straw hat, never somewhere else.
*/
export const REGISTER = 0.08;
/** The guide's cells, as accepted into art/final/: cell id → its WebP. */
export type Guide = ReadonlyMap<string, Buffer>;
async function guideExtent(guide: Guide, cell: string): Promise<Extent | null> {
const file = guide.get(cell);
if (!file) return null;
const { px, width, height } = await rgba(file);
return extent(px, width, 0, 0, width, height);
}
export async function acceptPicture(input: Buffer, id: string, m: Manifest, guide?: Guide): Promise<Accepted> {
const target = findTarget(m, id);
const a = target.asset;
if (a.over && target.cell) {
throw new Refused(`${id}: a layer is painted whole over its guide (${a.over}), never one picture at a time; the parts would not line up. Accept ${a.id} whole.`);
}
const guideCells = a.over && a.grid ? (m.assets.find((g) => g.id === a.over)?.cells ?? []) : [];
if (a.over && guideCells.some((c) => !guide?.has(c.id))) {
throw new Refused(`${id}: its guide ${a.over} is not in art/final/ yet. Accept the guide first: every layer is checked against it.`);
}
const notes: string[] = [];
const { px, width, height } = await rgba(input).catch((e: unknown) => {
throw new Refused(`${id}: the file could not be read as a picture (${String(e)})`);
@@ -137,6 +181,18 @@ export async function acceptPicture(input: Buffer, id: string, m: Manifest): Pro
});
if (empty.length) throw new Refused(`${id}: nothing drawn in ${empty.join(', ')}. The whole sheet is refused.`);
if (painted.length) throw new Refused(`${id}: painted on a background in ${painted.join(', ')}. The whole sheet is refused.`);
if (a.over && guide) {
// In register: each picture's part lies on the guide's figure in the same cell (STYLE.md §3b).
const off: string[] = [];
for (const [i, r] of regions.entries()) {
const mine = extent(px, width, r.left, r.top, r.left + r.width, r.top + r.height);
const under = await guideExtent(guide, guideCells[i]?.id ?? '');
if (!mine || !under) continue;
const out = Math.max(under.x0 - mine.x0, under.y0 - mine.y0, mine.x1 - under.x1, mine.y1 - under.y1);
if (out > REGISTER) off.push(`${r.id} (${Math.round(out * 100)} % of the cell outside the guide's figure)`);
}
if (off.length) throw new Refused(`${id}: not in register with ${a.over} in ${off.join(', ')}. Paint it over the guide again; the whole sheet is refused.`);
}
const files: FinalFile[] = [];
for (const r of regions) {
const out = await encode(fitCell(sharp(input).extract({ left: r.left, top: r.top, width: r.width, height: r.height })), BUDGET.cell, r.id);
+10 -5
View File
@@ -3,7 +3,7 @@
* art/STYLE.md (docs/ART.md §3). `pnpm art:board` writes it next to the board page and
* refreshes art/placeholders/; Claude publishes the folder as the art board artifact.
*/
import { checkManifest, type Asset, type Background, type Manifest } from './manifest.js';
import { checkManifest, expandLayers, type Asset, type Background, type Manifest } from './manifest.js';
import { attachments, cellPromptFor, cellSize, promptFor } from './prompt.js';
import { reviewPoints, stylePrompt } from './style.js';
@@ -31,6 +31,8 @@ export interface BoardAsset {
readonly prompt: string;
readonly grid?: { readonly cols: number; readonly rows: number };
readonly cells?: readonly BoardCell[];
/** A layer: the guide it is painted over. Made whole, never one picture at a time (STYLE.md §3b). */
readonly over?: string;
}
export interface BoardData {
@@ -40,11 +42,12 @@ export interface BoardData {
}
/** The board's data, or the manifest's problems. Nothing half-checked reaches the board. */
export function boardData(m: Manifest, styleMarkdown: string): BoardData {
export function boardData(raw: Manifest, styleMarkdown: string): BoardData {
const style = stylePrompt(styleMarkdown);
const checklist = reviewPoints(styleMarkdown);
const problems = checkManifest(m, checklist.length);
const problems = checkManifest(raw, checklist.length);
if (problems.length > 0) throw new Error(`art/manifest.json:\n ${problems.join('\n ')}`);
const m = expandLayers(raw);
const assets = m.assets.map((a): BoardAsset => {
const base = {
@@ -57,9 +60,11 @@ export function boardData(m: Manifest, styleMarkdown: string): BoardData {
return {
...base,
grid: a.grid,
// A layer's pictures have no prompts of their own: made one at a time, they would not line up.
cells: (a.cells ?? []).map((c) => ({
id: c.id, type: 'pose', width, height, background: a.background, prompt: cellPromptFor(a, c, m, style)
}))
id: c.id, type: 'pose', width, height, background: a.background, prompt: a.over ? '' : cellPromptFor(a, c, m, style)
})),
...(a.over ? { over: a.over } : {})
};
});
return { generatedFrom: 'art/manifest.json, art/STYLE.md §1 and §7', checklist, assets };
+14 -7
View File
@@ -1,13 +1,14 @@
/**
* `pnpm art:accept <id> <file>` — moves a picture Mark accepted on the art board into
* art/final/ as WebP (docs/ART.md §3, step 6). For a sprite sheet, `<id>` is the sheet
* and every cell is written; for one cell made on its own, `<id>` is the cell.
* and every cell is written; for one cell made on its own, `<id>` is the cell. A layer
* (STYLE.md §3b) is checked against its guide's cells, which must already be in art/final/.
*/
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join, relative } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Refused, acceptPicture } from './accept.js';
import type { Manifest } from './manifest.js';
import { Refused, acceptPicture, findTarget } from './accept.js';
import { expandLayers, type Manifest } from './manifest.js';
const root = fileURLToPath(new URL('../../../', import.meta.url));
const [id, file] = process.argv.slice(2);
@@ -16,10 +17,16 @@ if (!id || !file) {
process.exit(2);
}
const manifest = JSON.parse(readFileSync(join(root, 'art/manifest.json'), 'utf8')) as Manifest;
const manifest = expandLayers(JSON.parse(readFileSync(join(root, 'art/manifest.json'), 'utf8')) as Manifest);
const dir = join(root, 'art/final');
try {
const { files, notes } = await acceptPicture(readFileSync(file), id, manifest);
const dir = join(root, 'art/final');
const over = findTarget(manifest, id).asset.over;
const guide = new Map<string, Buffer>();
for (const c of manifest.assets.find((a) => a.id === over)?.cells ?? []) {
const path = join(dir, `${c.id}.webp`);
if (existsSync(path)) guide.set(c.id, readFileSync(path));
}
const { files, notes } = await acceptPicture(readFileSync(file), id, manifest, over ? guide : undefined);
mkdirSync(dir, { recursive: true });
for (const f of files) {
const path = join(dir, `${f.id}.webp`);
+106 -1
View File
@@ -40,6 +40,42 @@ export interface Asset {
readonly allow?: readonly string[];
/** Indices into STYLE.md §7, the review points shown on its card. */
readonly checks: readonly number[];
/**
* A layer of a layered character: the sprite sheet it is painted over, in register (STYLE.md §3b).
* Its grid and cells are the guide's; it is made whole over the guide, never one picture at a time.
*/
readonly over?: string;
/** For a layer: which part it is, and its place in the stack (0 at the back). */
readonly part?: { readonly name: string; readonly stack: number };
}
/** One part of a layered character: one layer sheet for each combination of its axes' values. */
export interface LayerPart {
readonly part: string;
/** The choices (gardener.schema.json fields) this part is painted for, in id order. */
readonly axes: readonly string[];
/** Values that need no picture (no hat). */
readonly skip?: readonly string[];
/** The subject, with {axis} replaced by the words for each value. */
readonly subject: string;
}
/** A character drawn as stacked layers, all painted over one guide (STYLE.md §3b). */
export interface Layered {
readonly character: string;
/** The guide: a sprite sheet of the whole first look in every pose, never shipped. */
readonly over: string;
readonly phase: number;
/** The words each value stands for in a prompt, per axis. */
readonly words: Readonly<Record<string, Readonly<Record<string, string>>>>;
/** The first looks: their layers come first, so a whole first look can be judged early. */
readonly first: readonly Readonly<Record<string, string>>[];
/** Back to front. */
readonly parts: readonly LayerPart[];
readonly include: readonly string[];
readonly avoid: readonly string[];
readonly allow?: readonly string[];
readonly checks: readonly number[];
}
export interface Character {
@@ -52,6 +88,58 @@ export interface Manifest {
/** What no picture may show, appended to every prompt (STYLE.md §4). */
readonly avoid: readonly string[];
readonly assets: readonly Asset[];
/** Characters drawn as layers; expandLayers writes each out as ordinary sprite sheets. */
readonly layers?: readonly Layered[];
}
/** Every combination of the axes' values, in the order the words list them. */
function combinations(l: Layered, part: LayerPart): Record<string, string>[] {
let out: Record<string, string>[] = [{}];
for (const axis of part.axes) {
const values = Object.keys(l.words[axis] ?? {}).filter((v) => !(part.skip ?? []).includes(v));
out = out.flatMap((c) => values.map((v) => ({ ...c, [axis]: v })));
}
return out;
}
/** The id of a layer sheet: the character, the part, then each value (gardener-hair-braids-brown). */
export const layerId = (character: string, part: string, values: readonly string[]): string => [character, part, ...values].join('-');
/**
* The manifest with every layered character written out as ordinary sprite sheets, placed right
* after their guide: the first looks' layers first, then the rest. Expanding twice changes nothing.
*/
export function expandLayers(m: Manifest): Manifest {
if (!m.layers) return m;
const assets = [...m.assets];
for (const l of m.layers) {
const guide = assets.find((a) => a.id === l.over);
if (!guide) continue; // checkManifest names it
const firsts: Asset[] = [], rest: Asset[] = [];
l.parts.forEach((part, stack) => {
for (const values of combinations(l, part)) {
const id = layerId(l.character, part.part, part.axes.map((a) => values[a] ?? ''));
const subject = part.subject.replace(/\{(\w+)\}/g, (whole, axis: string) => l.words[axis]?.[values[axis] ?? ''] ?? whole);
const isFirst = l.first.some((f) => part.axes.every((a) => f[a] === values[a]));
const pose = (cell: string): string => cell.replace(`${l.character}-`, '');
const asset: Asset = {
id, type: 'spritesheet', phase: l.phase, width: guide.width, height: guide.height, background: 'transparent',
shipped: true, smallest: guide.smallest, character: l.character,
usedBy: [`The ${l.character}'s ${part.part}, layer ${stack + 1} of ${l.parts.length} from the back, stacked with the others in the scene (STYLE.md §3b).`],
purpose: `One layer of the ${l.character} (${part.part}${part.axes.length ? `: ${part.axes.map((a) => values[a]).join(', ')}` : ''}), in every pose of ${l.over}.`,
subject, angle: guide.angle ?? '', grid: guide.grid ?? { cols: 1, rows: 1 },
cells: (guide.cells ?? []).map((c) => ({ id: `${id}-${pose(c.id)}`, does: c.does })),
include: l.include, avoid: l.avoid, checks: l.checks, over: l.over,
part: { name: part.part, stack },
...(l.allow ? { allow: l.allow } : {})
};
(isFirst ? firsts : rest).push(asset);
}
});
assets.splice(assets.indexOf(guide) + 1, 0, ...firsts, ...rest);
}
const { layers: _expanded, ...plain } = m;
return { ...plain, assets };
}
/** The canvases image generators offer (STYLE.md §5). Anything else gets resized by the tool, unasked. */
@@ -77,8 +165,25 @@ function textsOf(a: Asset): string[] {
* Problems with the manifest, each naming the asset. An empty list is a pass.
* `checklistLength` is the number of review points in STYLE.md §7.
*/
export function checkManifest(m: Manifest, checklistLength: number): string[] {
export function checkManifest(raw: Manifest, checklistLength: number): string[] {
const problems: string[] = [];
for (const l of raw.layers ?? []) {
const where = `layers of ${l.character}`;
const guide = raw.assets.find((a) => a.id === l.over);
if (!guide) problems.push(`${where}: the guide "${l.over}" is not in the manifest`);
else if (guide.type !== 'spritesheet') problems.push(`${where}: the guide "${l.over}" is a ${guide.type}, not a sprite sheet`);
else if (guide.shipped) problems.push(`${where}: the guide "${l.over}" is shipped; the app stacks the layers, so the guide never appears`);
for (const part of l.parts) {
for (const axis of part.axes) if (!l.words[axis]) problems.push(`${where}: part ${part.part} needs words for "${axis}"`);
for (const [, axis = ''] of part.subject.matchAll(/\{(\w+)\}/g)) {
if (!part.axes.includes(axis)) problems.push(`${where}: part ${part.part} says {${axis}} but is not painted per ${axis}`);
}
}
for (const text of [...Object.values(l.words).flatMap((w) => Object.values(w)), ...l.parts.map((p) => p.subject)]) {
for (const hit of findForbidden(text)) problems.push(`${where}: "${hit.term}" (${hit.category}) may not appear in a prompt`);
}
}
const m = expandLayers(raw);
const seen = new Set<string>();
const claim = (id: string, where: string): void => {
if (!ID.test(id)) problems.push(`${where}: id "${id}" must be lower-case words joined by hyphens`);
+105 -23
View File
@@ -3,7 +3,7 @@
* 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 { expandLayers, type Asset, type Manifest } from './manifest.js';
import { cellBoxes, cellSize } from './prompt.js';
const C = {
@@ -334,28 +334,103 @@ function planet(W: number, H: number, id: string): string {
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';
/** A gardener's look for a stand-in: the player's choices (gardener.schema.json), as colours and shapes. */
interface StandLook {
readonly boy: boolean;
readonly skin: string;
readonly hair: string;
readonly hairColour: string;
readonly clothes: string;
readonly hat: string;
}
/** The first look, the girl (STYLE.md §3b), in the colours the app's code drawing uses. */
const FIRST: StandLook = { boy: false, skin: '#cf9a72', hair: 'braids', hairColour: '#7a4b2e', clothes: C.leaf, hat: 'straw-hat' };
const APRON = '#efe4d2';
/** The boy's first look: short hair, the same colours. */
const BOY: StandLook = { ...FIRST, boy: true, hair: 'short' };
/** The parts a layered gardener is stacked from, back to front (STYLE.md §3b). */
type Part = 'body' | 'clothes' | 'apron' | 'hair' | 'hat';
/** Hair in each style, in one colour; drawn round a head at (61, 66), r 20. */
function hairOf(style: string, c: string): string {
const cap = `<path d="M41 62 Q 61 36 81 62 Q 61 52 41 62 Z" fill="${c}" ${ink(2)}/>`;
const strand = (d: string, w = 7): string => `<path d="${d}" stroke="${c}" stroke-width="${w}" fill="none" stroke-linecap="round"/>`;
switch (style) {
case 'curly': return [44, 52, 61, 70, 78].map((x, i) => `<circle cx="${x}" cy="${i % 2 ? 46 : 50}" r="9" fill="${c}" ${ink(2)}/>`).join('');
case 'ponytail': return `${cap}${strand('M42 58 q -14 8 -10 30', 9)}`;
case 'braids': return `${cap}${strand('M44 58 v 30')}${strand('M78 58 v 30')}`;
case 'bob': return `${cap}${strand('M42 56 v 22', 9)}${strand('M80 56 v 22', 9)}`;
case 'bun': return `${cap}<circle cx="38" cy="56" r="10" fill="${c}" ${ink(2)}/>`;
default: return cap;
}
}
/**
* The gardener's stand-in in a 120 × 200 box, feet on the bottom edge, facing right (STYLE.md §3b).
* With `only`, just that part, in the same place, so the parts' stand-ins stack into the whole figure.
*/
function gardener(pose: Pose, look: StandLook = FIRST, only?: Part): string {
const draw = (part: Part, svg: string): string => (only === undefined || only === part ? svg : '');
const { skin, clothes: cloth, boy } = look;
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
const legs = (colour: string, width: number): string => pose === 'sit'
? `<path d="M52 160 h26 v34 M62 160 h26 v34" stroke="${colour}" stroke-width="${width + 2}" fill="none" stroke-linecap="round"/>`
: `<path d="M52 196 V 150 M70 196 V 150" stroke="${colour}" stroke-width="${width}" stroke-linecap="round"/>`;
const shirt = 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 hat = look.hat === 'cap'
? `<path d="M43 56 Q 61 30 79 56 Z" fill="${APRON}" ${ink(3)}/><path d="M76 54 h 18" ${ink(5)} stroke-linecap="round"/>`
: look.hat === 'straw-hat' ? `<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)}/>` : '';
return draw('body', legs(skin, 10)) + draw('clothes', boy ? legs(cloth, 14) : '') +
draw('apron', `<path d="M44 198 h18 M64 198 h18" ${ink(7)} stroke-linecap="round"/>`) +
`<g transform="rotate(${lean} 61 150)">` +
draw('body', `<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>
<circle cx="61" cy="66" r="20" fill="${skin}" ${ink(4)}/>
<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)}/>`) +
draw('clothes', shirt) +
draw('apron', `<path d="M50 100 H 72 V 146 Q 61 152 50 146 Z" fill="${APRON}" ${ink(3)}/>`) +
draw('hair', hairOf(look.hair, look.hairColour)) +
draw('hat', hat) +
'</g>';
}
/** The first colour code in a prompt's words (the manifest names each colour once, for prompts and stand-ins). */
const hexIn = (words: string | undefined, fallback: string): string => /#[0-9A-Fa-f]{6}/.exec(words ?? '')?.[0].toLowerCase() ?? fallback;
/** A layer sheet's stand-in look: the first look, changed by the values in its id. */
function layerLook(a: Asset, m: Manifest): StandLook {
const l = m.layers?.find((x) => x.over === a.over);
const words = l?.words ?? {};
const has = (axis: string): string | undefined => Object.keys(words[axis] ?? {}).find((v) => a.id.includes(`-${v}`));
const presentation = has('presentation');
const hair = ['curly', 'ponytail', 'braids', 'bob', 'bun', 'short'].find((s) => a.id.startsWith(`${a.character ?? ''}-hair-${s}-`));
return {
boy: presentation === 'boy',
skin: hexIn(words['skin']?.[has('skin') ?? ''], FIRST.skin),
hair: hair ?? FIRST.hair,
hairColour: hexIn(words['hairColour']?.[a.id.slice(`${a.character ?? ''}-hair-${hair ?? ''}-`.length)], FIRST.hairColour),
clothes: hexIn(words['clothes']?.[has('clothes') ?? ''], FIRST.clothes),
hat: a.id.endsWith('-cap') ? 'cap' : 'straw-hat'
};
}
/** A layer sheet's stand-in: only its part, in every pose of the guide, where the guide has it. */
function layerSheet(a: Asset, m: Manifest): string {
const g = a.grid ?? { cols: 1, rows: 1 };
const look = layerLook(a, m);
const part = (a.part?.name ?? 'body') as Part;
return cellBoxes(a.width, a.height, g.cols, g.rows)
.map((b, i) => {
const pose = (a.cells?.[i]?.id ?? '').split('-').at(-1) as Pose;
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}">${fit(gardener(pose, look, part), 120, 200, w, h)}</svg>`;
})
.join('');
}
const GARDENER_POSES: Record<string, Pose> = {
@@ -404,7 +479,7 @@ function single(a: Asset): string {
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('');
[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 ? BOY : FIRST)}</g>`).join('');
return `<rect width="${W}" height="${H}" fill="${C.paper}"/>${row(false, 40)}${row(true, 560)}`;
}
if (a.character === 'fox') {
@@ -497,10 +572,17 @@ const wrap = (id: string, W: number, H: number, body: string): string =>
` <!-- 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> {
/**
* Every stand-in the board and the app may show: one per asset and one per sprite-sheet cell. A
* layer (STYLE.md §3b) has one for its sheet only: its pictures are never made or shown alone.
*/
export function placeholders(raw: Manifest): Map<string, string> {
const out = new Map<string, string>();
for (const a of m.assets) {
for (const a of expandLayers(raw).assets) {
if (a.over) {
out.set(a.id, wrap(a.id, a.width, a.height, layerSheet(a, raw)));
continue;
}
out.set(a.id, wrap(a.id, a.width, a.height, single(a)));
if (a.type === 'spritesheet') {
const { width, height } = cellSize(a);
+29 -1
View File
@@ -87,7 +87,8 @@ function characterOf(a: Asset, m: Manifest): { name: string; sheet: string; desc
/** The reference pictures to attach when making `a`. */
export function attachments(a: Asset, m: Manifest): string[] {
const c = characterOf(a, m);
return c && c.sheet !== a.id ? [c.sheet] : [];
const sheet = c && c.sheet !== a.id ? [c.sheet] : [];
return a.over ? [...sheet, a.over] : sheet;
}
/** "Reference: …", for a picture of a character made after its sheet. */
@@ -125,7 +126,34 @@ export function promptFor(a: Asset, m: Manifest, style: string): string {
return lines.join('\n');
}
/**
* One layer of a layered character (STYLE.md §3b): only its part, painted over the guide in
* register, so the app can stack the layers into any look the player chose.
*/
function layerPrompt(a: Asset, m: Manifest, style: string): string {
const g = a.grid ?? { cols: 1, rows: 1 };
const cells = a.cells ?? [];
const c = characterOf(a, m);
return [
style,
'',
`Make: one layer of a layered sprite sheet: only one part of the ${c?.name ?? 'figure'}, in ${cells.length} poses, painted over a guide in exact register so the parts can be stacked into one figure.`,
...referenceLines(a, m),
`Guide: attach the image ${a.over ?? ''} and paint over it. Keep its canvas and its grid. In every picture, paint only the part named below, exactly where it sits on the guide's figure, at exactly the same size, pose and position; then leave out the guide itself, so that everything except this part is fully transparent.`,
`Part: ${a.subject ?? ''}`,
`Drawn alike: ${a.angle ?? ''}`,
`Layout: the guide's ${g.cols} × ${g.rows} cells, read left to right, top row first; nothing moved, nothing scaled.`,
`Canvas: ${a.width} × ${a.height} px, transparent everywhere except the part; no ground and no cast shadows.`,
'The poses under the part, as in the guide:',
...cells.map((cell, i) => `${i + 1}. ${cell.does}`),
`Include: ${list(a.include)}`,
`Avoid: ${list([...a.avoid, ...SHEET_AVOID, ...shared(a, m)])}`,
board(a.id)
].join('\n');
}
function sheetPrompt(a: Asset, m: Manifest, style: string): string {
if (a.over) return layerPrompt(a, m, style);
const g = a.grid ?? { cols: 1, rows: 1 };
const cells = a.cells ?? [];
const many = (n: number, word: string): string => `${n} ${word}${n === 1 ? '' : 's'}`;
+7 -4
View File
@@ -1,6 +1,7 @@
import { readFileSync, readdirSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
import { boardData } from '../src/board.js';
import { expandLayers } from '../src/manifest.js';
import { placeholders } from '../src/placeholders.js';
import { clone, readManifest, readStyle, root } from './fixtures.js';
@@ -19,7 +20,7 @@ describe('the board data', () => {
for (const c of a.cells ?? []) expect(c).toMatchObject({ id: expect.any(String), width: expect.any(Number), height: expect.any(Number), prompt: expect.any(String) });
}
}
expect(data.checklist).toHaveLength(12);
expect(data.checklist).toHaveLength(13);
expect(data.assets.every((a) => Number.isInteger(a.phase))).toBe(true);
});
@@ -44,10 +45,12 @@ describe('the board data', () => {
});
describe('the stand-ins', () => {
it('one for every picture and every cell, at its own size', () => {
const ids = manifest.assets.flatMap((a) => [a.id, ...(a.cells ?? []).map((c) => c.id)]);
it('one for every picture and every cell, at its own size; a layer has one for its sheet only', () => {
const all = expandLayers(manifest).assets;
const ids = all.flatMap((a) => (a.over ? [a.id] : [a.id, ...(a.cells ?? []).map((c) => c.id)]));
expect([...stand.keys()].sort()).toEqual([...ids].sort());
for (const a of manifest.assets) expect(stand.get(a.id)).toContain(`viewBox="0 0 ${a.width} ${a.height}"`);
expect(stand.has('gardener-hair-braids-brown-pour')).toBe(false);
for (const a of all) expect(stand.get(a.id)).toContain(`viewBox="0 0 ${a.width} ${a.height}"`);
expect(stand.get('rose-bud')).toContain('viewBox="0 0 384 1024"');
expect(stand.get('watering-can')).toContain('viewBox="0 0 512 512"');
});
+175
View File
@@ -0,0 +1,175 @@
import { readFileSync } from 'node:fs';
import { GARDENER_OPTIONS } from '@rosea/schema';
import sharp from 'sharp';
import { describe, expect, it } from 'vitest';
import { Refused, acceptPicture, type Guide } from '../src/accept.js';
import { boardData } from '../src/board.js';
import { checkManifest, expandLayers, layerId, type Layered, type Manifest } from '../src/manifest.js';
import { placeholders } from '../src/placeholders.js';
import { reviewPoints } from '../src/style.js';
import { clone, readManifest, readStyle, root } from './fixtures.js';
const raw = readManifest();
const m = expandLayers(raw);
const POINTS = reviewPoints(readStyle()).length;
const layers = m.assets.filter((a) => a.over === 'gardener-poses-sheet');
const ids = new Set(layers.map((a) => a.id));
describe('the gardener in layered parts (STYLE.md §3b, decided by Mark 2026-11-17)', () => {
it('every look the player can choose can be stacked: a layer for every value of every choice', () => {
for (const skin of GARDENER_OPTIONS.skin) expect(ids.has(layerId('gardener', 'body', [skin])), skin).toBe(true);
for (const p of GARDENER_OPTIONS.presentation) {
for (const c of GARDENER_OPTIONS.clothes) expect(ids.has(layerId('gardener', 'clothes', [p, c])), `${p} ${c}`).toBe(true);
}
expect(ids.has('gardener-apron')).toBe(true);
for (const h of GARDENER_OPTIONS.hair) {
for (const c of GARDENER_OPTIONS.hairColour) expect(ids.has(layerId('gardener', 'hair', [h, c])), `${h} ${c}`).toBe(true);
}
for (const hat of GARDENER_OPTIONS.hat) expect(ids.has(layerId('gardener', 'hat', [hat]))).toBe(hat !== 'none');
expect(layers).toHaveLength(6 + 10 + 1 + 36 + 2);
});
it("the words name no value the app does not offer, so no layer is painted for nothing", () => {
const words = raw.layers?.[0]?.words ?? {};
for (const [axis, values] of Object.entries(words)) {
expect(Object.keys(values).sort(), axis).toEqual([...(GARDENER_OPTIONS[axis as keyof typeof GARDENER_OPTIONS] ?? [])].sort());
}
});
it("the colours in the prompts are the app's own (Gardener.svelte), so a painted look matches the one chosen", () => {
const svelte = readFileSync(`${root}packages/ui/src/scene/Gardener.svelte`, 'utf8');
const words = raw.layers?.[0]?.words ?? {};
for (const axis of ['skin', 'hairColour', 'clothes']) {
for (const [value, text] of Object.entries(words[axis] ?? {})) {
const hex = /#[0-9A-F]{6}/i.exec(text)?.[0].toLowerCase();
expect(svelte, `${axis} ${value}`).toMatch(new RegExp(`'?${value}'?: '${hex}'`));
}
}
});
it('come right after the guide, the seven of the two first looks first, then back to front', () => {
const at = m.assets.findIndex((a) => a.id === 'gardener-poses-sheet');
expect(m.assets.slice(at + 1, at + 8).map((a) => a.id)).toEqual([
'gardener-body-skin-3', 'gardener-clothes-girl-sage', 'gardener-clothes-boy-sage', 'gardener-apron',
'gardener-hair-short-brown', 'gardener-hair-braids-brown', 'gardener-hat-straw-hat'
]);
const back = (from: number): number[] => layers.slice(from).map((a) => a.part?.stack ?? -1);
for (const run of [back(0).slice(0, 7), back(7)]) expect(run).toEqual([...run].sort((x, y) => x - y));
expect(layers.find((a) => a.id === 'gardener-hat-cap')?.part).toEqual({ name: 'hat', stack: 4 });
});
it("have the guide's grid and poses, each picture named after its pose; the guide is never shipped", () => {
const guide = m.assets.find((a) => a.id === 'gardener-poses-sheet');
expect(guide?.shipped).toBe(false);
const hair = m.assets.find((a) => a.id === 'gardener-hair-curly-red');
expect(hair?.grid).toEqual(guide?.grid);
expect(hair?.cells?.map((c) => c.id)).toEqual((guide?.cells ?? []).map((c) => c.id.replace('gardener-', 'gardener-hair-curly-red-')));
expect(hair?.cells?.map((c) => c.does)).toEqual(guide?.cells?.map((c) => c.does));
});
it('expanding twice changes nothing', () => {
expect(expandLayers(m)).toEqual(m);
});
it("a layer's prompt attaches the character sheet and the guide, names only its part, and has no one-at-a-time prompts", () => {
const board = boardData(raw, readStyle());
const hair = board.assets.find((a) => a.id === 'gardener-hair-bun-auburn');
expect(hair?.attach).toEqual(['gardener-sheet', 'gardener-poses-sheet']);
expect(hair?.over).toBe('gardener-poses-sheet');
expect(hair?.prompt).toContain('Guide: attach the image gardener-poses-sheet and paint over it.');
expect(hair?.prompt).toContain("Part: only the gardener's hair: hair in a small round bun at the back of the head, auburn (#9A4A2A)");
expect(hair?.prompt).toContain('Avoid: any part of the gardener other than the one named');
// The character's whole first look would contradict a part: it is not in a layer's prompt.
expect(hair?.prompt).not.toContain('two braids, a wide straw hat');
expect(hair?.cells?.every((c) => c.prompt === '')).toBe(true);
expect(board.assets.find((a) => a.id === 'gardener-poses-sheet')?.cells?.every((c) => c.prompt !== '')).toBe(true);
});
it("each layer's stand-in draws its part only, in its own colour", () => {
const stand = placeholders(raw);
expect(stand.get('gardener-body-skin-6')).toContain('#553422');
expect(stand.get('gardener-body-skin-6')).not.toContain('#e6c98a'); // no straw hat in the body
expect(stand.get('gardener-hair-short-fair')).toContain('#d9b26a');
expect(stand.get('gardener-hair-short-fair')).not.toContain('#cf9a72'); // no skin in the hair
expect(stand.get('gardener-clothes-boy-dusk')).toContain('#5b6fa6');
expect(stand.get('gardener-hat-straw-hat')).toContain('#e6c98a');
});
});
describe('checkManifest refuses layers that cannot work', () => {
const broken = (change: (l: { -readonly [K in keyof Layered]: Layered[K] }, m: Manifest) => void): string => {
const copy = clone(raw);
change((copy.layers as Layered[])[0] as never, copy);
return checkManifest(copy, POINTS).join('\n');
};
it('a shipped guide: the app stacks the layers, so the guide must never appear', () => {
expect(broken((_, c) => { (c.assets.find((a) => a.id === 'gardener-poses-sheet') as { shipped: boolean }).shipped = true; })).toMatch(/guide "gardener-poses-sheet" is shipped/);
});
it('a guide that is missing or not a sprite sheet', () => {
expect(broken((l) => { l.over = 'nowhere'; })).toMatch(/guide "nowhere" is not in the manifest/);
expect(broken((l) => { l.over = 'gardener-sheet'; })).toMatch(/guide "gardener-sheet" is a sheet, not a sprite sheet/);
});
it('a part that names a choice it is not painted for, or a choice with no words', () => {
expect(broken((l) => { (l.parts[2] as { subject: string }).subject = 'only the apron, in {clothes}'; })).toMatch(/part apron says \{clothes\} but is not painted per clothes/);
expect(broken((l) => { delete (l.words as Record<string, unknown>)['hat']; })).toMatch(/part hat needs words for "hat"/);
});
it("a forbidden word in a layer's words", () => {
expect(broken((l) => { ((l.words as Record<string, Record<string, string>>)['hat'] ?? {})['cap'] = 'a cap to heal the heart'; })).toMatch(/"heal" \(medical\)/);
});
});
describe('art:accept and a layer (in register with the guide)', () => {
const W = 1536, H = 1024, COLS = 4, ROWS = 2;
const cw = W / COLS, ch = H / ROWS;
/** One rectangle per cell, at the given share of the cell: a figure, or a part of one. */
async function sheet(box: { x: number; y: number; w: number; h: number }): Promise<Buffer> {
const rects = Array.from({ length: COLS * ROWS }, (_, i) =>
`<rect x="${(i % COLS) * cw + box.x * cw}" y="${Math.floor(i / COLS) * ch + box.y * ch}" width="${box.w * cw}" height="${box.h * ch}" fill="#7fa07a"/>`).join('');
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H}">${rects}</svg>`;
return sharp({ create: { width: W, height: H, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } } }).composite([{ input: Buffer.from(svg) }]).png().toBuffer();
}
const FIGURE = { x: 0.3, y: 0.15, w: 0.4, h: 0.7 };
let guide: Guide | undefined;
async function theGuide(): Promise<Guide> {
if (!guide) {
const { files } = await acceptPicture(await sheet(FIGURE), 'gardener-poses-sheet', m);
guide = new Map(files.map((f) => [f.id, f.data]));
}
return guide;
}
const refusal = async (p: Promise<unknown>): Promise<string> => {
try {
await p;
} catch (e) {
if (e instanceof Refused) return e.message;
throw e;
}
throw new Error('expected a refusal');
};
it('a part lying on the guide\'s figure is accepted and cut into its eight pictures', async () => {
const { files } = await acceptPicture(await sheet({ x: 0.33, y: 0.15, w: 0.34, h: 0.2 }), 'gardener-hair-braids-brown', m, await theGuide());
expect(files.map((f) => f.id)).toEqual((m.assets.find((a) => a.id === 'gardener-hair-braids-brown')?.cells ?? []).map((c) => c.id));
});
it('a part a little fuller than the guide (a wide hat) is still in register', async () => {
await acceptPicture(await sheet({ x: 0.25, y: 0.12, w: 0.5, h: 0.12 }), 'gardener-hat-straw-hat', m, await theGuide());
});
it('a part painted somewhere else is refused, naming the pictures', async () => {
const message = await refusal(acceptPicture(await sheet({ x: 0.75, y: 0.15, w: 0.2, h: 0.2 }), 'gardener-hair-braids-brown', m, await theGuide()));
expect(message).toMatch(/not in register with gardener-poses-sheet in gardener-hair-braids-brown-stand \(\d+ % of the cell/);
});
it('before the guide is accepted, a layer is refused', async () => {
expect(await refusal(acceptPicture(await sheet(FIGURE), 'gardener-apron', m))).toMatch(/guide gardener-poses-sheet is not in art\/final\/ yet/);
});
it('one picture of a layer, made on its own, is refused: it would not line up', async () => {
expect(await refusal(acceptPicture(await sheet(FIGURE), 'gardener-apron-pour', m, await theGuide()))).toMatch(/never one picture at a time/);
});
});
+11 -7
View File
@@ -1,13 +1,15 @@
import { describe, expect, it } from 'vitest';
import { findForbidden } from '@rosea/content';
import { boardData } from '../src/board.js';
import { expandLayers } from '../src/manifest.js';
import { cellBoxes, cutLines, soloCanvas } from '../src/prompt.js';
import { reviewPoints, stylePrompt } from '../src/style.js';
import { clone, readManifest, readStyle } from './fixtures.js';
const style = stylePrompt(readStyle());
const data = boardData(readManifest(), readStyle());
const allPrompts = data.assets.flatMap((a) => [a.prompt, ...(a.cells ?? []).map((c) => c.prompt)]);
// A layer's pictures have no prompts of their own (STYLE.md §3b): their prompt is ''.
const allPrompts = data.assets.flatMap((a) => [a.prompt, ...(a.cells ?? []).map((c) => c.prompt)]).filter((p) => p !== '');
describe('STYLE.md', () => {
it('§1 is the quoted system prompt, line breaks kept and the markers gone', () => {
@@ -23,9 +25,10 @@ describe('STYLE.md', () => {
}
});
it('§7 has the twelve review points, a point split over two lines read as one', () => {
it('§7 has the thirteen review points, a point split over two lines read as one', () => {
const points = reviewPoints(readStyle());
expect(points).toHaveLength(12);
expect(points).toHaveLength(13);
expect(points[12]).toBe('A gardener layer holds only its part, in register with the guide: stacked with the other layers of a look, it makes one child, with nothing doubled, missing or shifted.');
expect(points[8]).toBe("It reads as one young red-orange fox with a cream mask and a ringed tail, shy and gentle, and nothing like the book's sandy, long-eared fox.");
expect(points[3]).toBe('Nothing from the book: no glass dome, screen, tiny planet, desert, child or scarf, and no look of its drawings.');
});
@@ -37,18 +40,19 @@ describe('STYLE.md', () => {
});
describe('the prompts', () => {
it('every one starts with STYLE.md §1 word for word, then says what to make: 40 cards and 74 one-at-a-time prompts', () => {
expect(allPrompts).toHaveLength(40 + 74);
it('every one starts with STYLE.md §1 word for word, then says what to make: 95 cards (55 of them gardener layers) and 74 one-at-a-time prompts', () => {
expect(data.assets.filter((a) => a.over)).toHaveLength(55);
expect(allPrompts).toHaveLength(95 + 74);
for (const p of allPrompts) expect(p.startsWith(style + '\n\nMake: ')).toBe(true);
});
it('every one ends with the shared avoid list and its board id', () => {
const m = readManifest();
const m = expandLayers(readManifest());
for (const a of data.assets) {
const allowed = m.assets.find((x) => x.id === a.id)?.allow ?? [];
expect(a.prompt).toContain(m.avoid.filter((l) => !allowed.includes(l)).join('; '));
expect(a.prompt.endsWith(`\nBoard id: ${a.id}`)).toBe(true);
for (const c of a.cells ?? []) expect(c.prompt.endsWith(`\nBoard id: ${c.id} (one picture of ${a.id})`)).toBe(true);
for (const c of (a.cells ?? []).filter((x) => x.prompt !== '')) expect(c.prompt.endsWith(`\nBoard id: ${c.id} (one picture of ${a.id})`)).toBe(true);
}
});