[art] BoardV2: Prompts lead with the look, say the grid in words, and stop naming the book's motifs
This commit is contained in:
@@ -58,62 +58,66 @@ export function soloCanvas(a: Asset): { width: number; height: number } {
|
||||
return { width: 1024, height: 1024 };
|
||||
}
|
||||
|
||||
const KIND: Record<Asset['type'], string> = {
|
||||
sheet: 'character sheet',
|
||||
spritesheet: 'sprite sheet',
|
||||
sprite: 'single picture',
|
||||
layer: 'garden layer',
|
||||
icon: 'app icon'
|
||||
/**
|
||||
* The first line after the style: what kind of image this is, in words a generator
|
||||
* understands (STYLE.md §6). Generators follow the first lines best.
|
||||
*/
|
||||
const MAKE: Record<Exclude<Asset['type'], 'spritesheet'>, string> = {
|
||||
sheet: 'a character reference sheet: the same character painted several times on plain paper, so that every later picture can match it.',
|
||||
sprite: 'one small painted picture of a single thing, on a transparent background, to be placed into a game scene.',
|
||||
layer: 'a tall painted scene for a phone screen, with transparent areas exactly where the setting says, because the sky is painted separately behind it.',
|
||||
icon: 'an app icon: one bold, simple painted image filling a square, readable even when very small.'
|
||||
};
|
||||
|
||||
const bg = (b: Asset['background']): string => (b === 'transparent' ? 'transparent background' : 'full background');
|
||||
const list = (items: readonly string[]): string => items.join('; ');
|
||||
|
||||
/** Extra things a sprite sheet must never have, so it can be cut cleanly. */
|
||||
const SHEET_AVOID = [
|
||||
'grid lines, cell borders or frames',
|
||||
'a background colour or paper behind the drawings',
|
||||
'ground or cast shadows',
|
||||
'drawings touching or overlapping',
|
||||
'cropped petals, leaves or stems'
|
||||
];
|
||||
/** A sheet is cut apart, so its pictures must not touch. Everything else is said positively in the layout. */
|
||||
const SHEET_AVOID = ['pictures touching or overlapping', 'grid lines, frames or labels'];
|
||||
|
||||
/** The character the picture shows, with the sheet to attach, or the sheet's own description. */
|
||||
function subjectLine(a: Asset, m: Manifest, subject: string): string {
|
||||
const c = a.character === undefined ? undefined : m.characters[a.character];
|
||||
if (!c) return subject;
|
||||
if (c.sheet === a.id) return `${subject} ${c.description}`;
|
||||
return `${subject} Attach the character sheet ${c.sheet} as the reference picture and match it exactly. ${c.description}`.trim();
|
||||
/** The character the picture shows, if any, and its name. */
|
||||
function characterOf(a: Asset, m: Manifest): { name: string; sheet: string; description: string } | null {
|
||||
if (a.character === undefined) return null;
|
||||
const c = m.characters[a.character];
|
||||
return c ? { name: a.character, ...c } : null;
|
||||
}
|
||||
|
||||
/** The reference pictures to attach when making `a`. */
|
||||
export function attachments(a: Asset, m: Manifest): string[] {
|
||||
const c = a.character === undefined ? undefined : m.characters[a.character];
|
||||
const c = characterOf(a, m);
|
||||
return c && c.sheet !== a.id ? [c.sheet] : [];
|
||||
}
|
||||
|
||||
function canvasLine(width: number, height: number): string {
|
||||
const mx = Math.round(width * 0.15), my = Math.round(height * 0.15);
|
||||
return `Canvas: ${width} × ${height} px, fully transparent background. One subject, centred on (${width / 2}, ${height / 2}), whole and uncropped, filling about 70 % of the canvas: everything inside x ${mx}–${width - mx}, y ${my}–${height - my}, nothing touching an edge. No background colour or paper behind it, no ground, no cast shadow.`;
|
||||
/** "Reference: …", for a picture of a character made after its sheet. */
|
||||
function referenceLines(a: Asset, m: Manifest): string[] {
|
||||
const c = characterOf(a, m);
|
||||
if (!c || c.sheet === a.id) return [];
|
||||
return [`Reference: attach the image ${c.sheet}, the ${c.name}'s character sheet, and match it exactly: the same shapes, colours, proportions and face.`];
|
||||
}
|
||||
|
||||
/** The subject, followed by the character's description when the picture shows one. */
|
||||
function subjectLine(a: Asset, m: Manifest, subject: string): string {
|
||||
const c = characterOf(a, m);
|
||||
return c ? `${subject} ${c.description}`.trim() : subject;
|
||||
}
|
||||
|
||||
function canvasLine(width: number, height: number, background: Asset['background'], single: boolean): string {
|
||||
if (!single) return `Canvas: ${width} × ${height} px, ${background === 'transparent' ? 'transparent background' : 'painted to every edge'}.`;
|
||||
return `Canvas: ${width} × ${height} px, transparent background. One subject, whole and centred, filling about 70 % of the canvas with clear space all round; no ground and no cast shadow.`;
|
||||
}
|
||||
|
||||
const board = (id: string): string => `Board id: ${id}`;
|
||||
|
||||
/** The prompt for one picture, or for a whole sprite sheet. */
|
||||
export function promptFor(a: Asset, m: Manifest, style: string): string {
|
||||
if (a.type === 'spritesheet') return sheetPrompt(a, m, style);
|
||||
const lines = [
|
||||
style,
|
||||
'',
|
||||
`Asset: ${a.id}`,
|
||||
`Purpose: ${a.purpose}`,
|
||||
`Subject: ${subjectLine(a, m, a.subject ?? '')}`
|
||||
];
|
||||
const lines = [style, '', `Make: ${MAKE[a.type]}`, ...referenceLines(a, m), `Subject: ${subjectLine(a, m, a.subject ?? '')}`];
|
||||
if (a.setting) lines.push(`Setting: ${a.setting}`);
|
||||
if (a.type === 'sprite') lines.push(canvasLine(a.width, a.height));
|
||||
if (a.composition) lines.push(`Composition: ${a.composition}`);
|
||||
lines.push(
|
||||
`Size: ${a.width} × ${a.height} px, ${bg(a.background)} (STYLE.md §5, ${KIND[a.type]})`,
|
||||
`Must include: ${list(a.include)}`,
|
||||
`Must avoid: ${list([...a.avoid, ...m.avoid])}`
|
||||
canvasLine(a.width, a.height, a.background, a.type === 'sprite'),
|
||||
`Include: ${list(a.include)}`,
|
||||
`Avoid: ${list([...a.avoid, ...m.avoid])}`,
|
||||
board(a.id)
|
||||
);
|
||||
return lines.join('\n');
|
||||
}
|
||||
@@ -121,44 +125,21 @@ export function promptFor(a: Asset, m: Manifest, style: string): string {
|
||||
function sheetPrompt(a: Asset, m: Manifest, style: string): string {
|
||||
const g = a.grid ?? { cols: 1, rows: 1 };
|
||||
const cells = a.cells ?? [];
|
||||
const { width: cw, height: ch } = cellSize(a);
|
||||
const boxes = cellBoxes(a.width, a.height, g.cols, g.rows);
|
||||
const margin = Math.round(SAFE_MARGIN * Math.min(cw, ch));
|
||||
const xs = cutLines(a.width, g.cols).slice(1, -1);
|
||||
const ys = cutLines(a.height, g.rows).slice(1, -1);
|
||||
const cuts = [
|
||||
xs.length ? `Cut lines down the image at x = ${xs.join(', ')}.` : '',
|
||||
ys.length ? `Cut lines across the image at y = ${ys.join(', ')}.` : ''
|
||||
].filter(Boolean).join(' ');
|
||||
|
||||
const many = (n: number, word: string): string => `${n} ${word}${n === 1 ? '' : 's'}`;
|
||||
return [
|
||||
style,
|
||||
'',
|
||||
`Asset: ${a.id}`,
|
||||
`Kind: a sprite sheet. One image holding ${cells.length} separate pictures on a clean grid; it is cut apart along the grid and each cell becomes its own picture in the app. The sheet itself is never shown.`,
|
||||
`Purpose: ${a.purpose}`,
|
||||
`Subject: ${subjectLine(a, m, '') || 'Each cell holds its own thing, described in the cell list below.'}`,
|
||||
`Angle and scale: ${a.angle ?? ''}`,
|
||||
`Canvas: ${a.width} × ${a.height} px, transparent background: a size image generators offer, and the size the grid below is measured on. The app divides the image into ${g.cols} × ${g.rows} equal cells whatever its size.`,
|
||||
`Layout: a clean grid of ${g.cols} column${g.cols === 1 ? '' : 's'} × ${g.rows} row${g.rows === 1 ? '' : 's'} of equal, invisible cells, each ${cw} × ${ch} px, read like a book (left to right, top row first). One subject per cell, centred in its cell, whole and uncropped, with generous empty gutters, so nothing touches the edge of its cell or reaches into a neighbour. No grid lines, borders, frames, numbers, labels or captions anywhere. Fully transparent background between and around the subjects: no paper colour, no ground, no cast shadows. The same light from the left, the same outline weight and the same gouache texture in every cell.`,
|
||||
`Cells (${cells.length}, in reading order):`,
|
||||
...cells.map((c, i) => {
|
||||
const b = boxes[i];
|
||||
return `${i + 1}. ${c.id} (row ${(b?.row ?? 0) + 1}, column ${(b?.col ?? 0) + 1}): ${c.does}`;
|
||||
}),
|
||||
`Grid in pixels:`,
|
||||
`- ${cuts} The lines are never drawn: they are where the scissors go.`,
|
||||
`- Each drawing stays whole inside its own safe box, at least ${margin} px clear of every edge of its cell, so a band of at least ${margin * 2} px of empty transparency runs along every cut line and round the outside. Nothing crosses a cut line: no petal, leaf, stem, shadow or sparkle.`,
|
||||
...cells.map((c, i) => {
|
||||
const b = boxes[i];
|
||||
if (!b) return '';
|
||||
return `- Cell ${i + 1}, ${c.id}: starts at (${b.x0}, ${b.y0}), ends at (${b.x1}, ${b.y1}); centre the drawing on (${b.cx}, ${b.cy}); safe box x ${b.safe.x0}–${b.safe.x1}, y ${b.safe.y0}–${b.safe.y1}.`;
|
||||
}).filter(Boolean),
|
||||
`- One scale for the whole sheet: the largest drawing fills its safe box and every other cell is drawn at that same scale, centred on its cell's centre.`,
|
||||
`- If the tool makes the image another size, keep the same ${g.cols} × ${g.rows} division into equal cells and scale every number above by the same factor.`,
|
||||
`Size: generate at ${a.width} × ${a.height} px (see Canvas); each cell ships at up to ${cw} × ${ch} px, transparent (STYLE.md §5 and §9).`,
|
||||
`Must include: ${list(a.include)}`,
|
||||
`Must avoid: ${list([...a.avoid, ...SHEET_AVOID, ...m.avoid])}`
|
||||
`Make: a sprite sheet: ${cells.length} separate painted pictures on one image, which will be cut apart so that each becomes its own picture in the game.`,
|
||||
...referenceLines(a, m),
|
||||
`Subject: ${subjectLine(a, m, '') || 'each picture is its own thing, described in the list below.'}`,
|
||||
`Drawn alike: ${a.angle ?? ''}`,
|
||||
`Layout: ${many(g.cols, 'column')} × ${many(g.rows, 'row')} of equal, invisible cells, read left to right, top row first. One picture in the middle of each cell, all at one scale, each whole and uncropped, with wide empty gaps between them and round the edge, so they can be cut apart cleanly. The same light from the left and the same brush line in every picture.`,
|
||||
`Canvas: ${a.width} × ${a.height} px, transparent between and round the pictures; no ground and no cast shadows.`,
|
||||
'Pictures:',
|
||||
...cells.map((c, i) => `${i + 1}. ${c.does}`),
|
||||
`Include: ${list(a.include)}`,
|
||||
`Avoid: ${list([...a.avoid, ...SHEET_AVOID, ...m.avoid])}`,
|
||||
board(a.id)
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
@@ -168,14 +149,13 @@ export function cellPromptFor(a: Asset, cell: Cell, m: Manifest, style: string):
|
||||
return [
|
||||
style,
|
||||
'',
|
||||
`Asset: ${cell.id} (one picture of ${a.id}, made on its own)`,
|
||||
'Kind: a single picture on a transparent background; it becomes one picture in the app.',
|
||||
`Purpose: ${a.purpose}`,
|
||||
`Subject: ${subjectLine(a, m, '') || 'Each cell holds its own thing, described in the cell list below.'}`,
|
||||
`Angle and scale: ${a.angle ?? ''}`,
|
||||
`This picture: ${cell.does}`,
|
||||
canvasLine(width, height),
|
||||
`Must include: ${list(a.include)}`,
|
||||
`Must avoid: ${list([...a.avoid, ...m.avoid])}`
|
||||
`Make: ${MAKE.sprite}`,
|
||||
...referenceLines(a, m),
|
||||
`Subject: ${subjectLine(a, m, cell.does)}`,
|
||||
`Drawn alike: ${a.angle ?? ''}`,
|
||||
canvasLine(width, height, 'transparent', true),
|
||||
`Include: ${list(a.include)}`,
|
||||
`Avoid: ${list([...a.avoid, ...m.avoid])}`,
|
||||
board(`${cell.id} (one picture of ${a.id})`)
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
@@ -11,10 +11,16 @@ const allPrompts = data.assets.flatMap((a) => [a.prompt, ...(a.cells ?? []).map(
|
||||
|
||||
describe('STYLE.md', () => {
|
||||
it('§1 is the quoted system prompt, line breaks kept and the markers gone', () => {
|
||||
expect(style.startsWith('Soft, hand-made 2D storybook illustration painted in matte gouache')).toBe(true);
|
||||
expect(style.startsWith('A hand-painted picture in opaque, matte gouache on warm off-white paper')).toBe(true);
|
||||
expect(style).toContain('\n');
|
||||
expect(style).not.toMatch(/^>/m);
|
||||
expect(style.endsWith('book, illustrator or film.')).toBe(true);
|
||||
expect(style.endsWith('in the manner of no existing artist, book or film.')).toBe(true);
|
||||
});
|
||||
|
||||
it('§1 says the look positively and asks for grown-ups, not a sticker (the 2026-11-07 rewrite)', () => {
|
||||
for (const words of ['dry-brush', 'paper showing through', 'plum-brown', 'from the left', 'for grown-ups', 'never a children\'s sticker', 'painted directly on them', 'Not watercolour']) {
|
||||
expect(style.replace(/\n/g, ' ')).toContain(words);
|
||||
}
|
||||
});
|
||||
|
||||
it('§7 has the ten review points, a point split over two lines read as one', () => {
|
||||
@@ -31,13 +37,28 @@ describe('STYLE.md', () => {
|
||||
});
|
||||
|
||||
describe('the prompts', () => {
|
||||
it('every one starts with STYLE.md §1 word for word: 18 cards and 45 one-at-a-time prompts', () => {
|
||||
expect(allPrompts).toHaveLength(18 + 45);
|
||||
for (const p of allPrompts) expect(p.startsWith(style + '\n\nAsset: ')).toBe(true);
|
||||
it('every one starts with STYLE.md §1 word for word, then says what to make: 35 cards and 66 one-at-a-time prompts', () => {
|
||||
expect(allPrompts).toHaveLength(35 + 66);
|
||||
for (const p of allPrompts) expect(p.startsWith(style + '\n\nMake: ')).toBe(true);
|
||||
});
|
||||
|
||||
it('every one carries the shared avoid list, so the likeness guard is never left out', () => {
|
||||
for (const p of allPrompts) expect(p).toMatch(/Must avoid: .*a glass dome or bell jar; a folding screen; a tiny round planet/);
|
||||
it('every one ends with the shared avoid list and its board id', () => {
|
||||
const shared = readManifest().avoid.join('; ');
|
||||
for (const a of data.assets) {
|
||||
expect(a.prompt).toContain(shared);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
it("never names the book's motifs, even to forbid them: naming one invites it; review checks them instead", () => {
|
||||
const motifs = /glass dome|bell jar|folding screen|tiny round planet|scarf|desert|golden hair|wheat/i;
|
||||
for (const p of allPrompts) expect(p).not.toMatch(motifs);
|
||||
expect(data.checklist[3]).toMatch(/glass dome, screen, tiny planet, desert, child or scarf/);
|
||||
});
|
||||
|
||||
it('carries no pixel coordinates a generator cannot use; the grid is said in words', () => {
|
||||
for (const p of allPrompts) expect(p).not.toMatch(/starts at \(|safe box|Cut lines|centre the drawing on/);
|
||||
});
|
||||
|
||||
it('none names the book, Tolkien, or a medical or unnamed word', () => {
|
||||
@@ -47,26 +68,35 @@ describe('the prompts', () => {
|
||||
it('a rose picture asks for the rose sheet as its reference; the sheet itself does not', () => {
|
||||
const by = new Map(data.assets.map((a) => [a.id, a]));
|
||||
expect(by.get('rose-sheet')?.attach).toEqual([]);
|
||||
expect(by.get('rose-sheet')?.prompt).not.toContain('Attach the character sheet');
|
||||
for (const id of ['rose-stages-sheet', 'rose-care-sheet', 'rose-moments-sheet', 'app-icon']) {
|
||||
expect(by.get('rose-sheet')?.prompt).not.toContain('Reference:');
|
||||
for (const id of ['rose-stages-sheet', 'rose-care-sheet', 'rose-moments-sheet', 'rose-touch-sheet', 'app-icon', 'app-icon-maskable']) {
|
||||
expect(by.get(id)?.attach).toEqual(['rose-sheet']);
|
||||
expect(by.get(id)?.prompt).toContain('Attach the character sheet rose-sheet as the reference picture');
|
||||
expect(by.get(id)?.prompt).toContain('Reference: attach the image rose-sheet');
|
||||
}
|
||||
for (const id of ['care-props-sheet', 'favicon-mark', 'letter-header']) expect(by.get(id)?.attach).toEqual([]);
|
||||
});
|
||||
|
||||
it('every rose prompt puts her face on the petals, never on a round head', () => {
|
||||
for (const a of data.assets.filter((x) => x.attach.includes('rose-sheet') || x.id === 'rose-sheet')) {
|
||||
for (const p of [a.prompt, ...(a.cells ?? []).map((c) => c.prompt)]) {
|
||||
expect(p).toContain('Her face is painted directly on the inner petals');
|
||||
expect(p).toContain('There is no round face, ball or bare patch inside the petals');
|
||||
}
|
||||
}
|
||||
expect(by.get('care-props-sheet')?.attach).toEqual([]);
|
||||
});
|
||||
|
||||
it('a fox picture asks for the fox sheet, never the rose sheet, and every one-at-a-time fox prompt does too', () => {
|
||||
const by = new Map(data.assets.map((a) => [a.id, a]));
|
||||
expect(by.get('fox-sheet')?.attach).toEqual([]);
|
||||
for (const id of ['fox-trust-sheet', 'fox-moments-sheet']) {
|
||||
for (const id of ['fox-trust-sheet', 'fox-moments-sheet', 'foxes-meeting']) {
|
||||
const a = by.get(id);
|
||||
expect(a?.attach).toEqual(['fox-sheet']);
|
||||
for (const p of [a?.prompt ?? '', ...(a?.cells ?? []).map((c) => c.prompt)]) {
|
||||
expect(p).toContain('Attach the character sheet fox-sheet as the reference picture');
|
||||
expect(p).toContain('Reference: attach the image fox-sheet');
|
||||
expect(p).not.toContain('rose-sheet');
|
||||
}
|
||||
}
|
||||
for (const id of ['berries-sheet', 'berry-bush-sheet', 'paths-sheet', 'lanterns-sheet']) expect(by.get(id)?.attach).toEqual([]);
|
||||
for (const id of ['berries-sheet', 'berry-bush-sheet', 'paths-sheet', 'lanterns-sheet', 'visitors-sheet', 'planet-king']) expect(by.get(id)?.attach).toEqual([]);
|
||||
});
|
||||
|
||||
it('a manifest with a forbidden name never reaches the board', () => {
|
||||
@@ -91,13 +121,12 @@ describe('the grid', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("a sheet's prompt gives each cell the numbers cellBoxes computes", () => {
|
||||
it("a sheet's prompt says its grid in words and lists its pictures in reading order", () => {
|
||||
const props = data.assets.find((a) => a.id === 'care-props-sheet');
|
||||
expect(props?.prompt).toContain('Cut lines down the image at x = 512, 1024. Cut lines across the image at y = 512.');
|
||||
expect(props?.prompt).toContain('- Cell 5, petal-folded: starts at (512, 512), ends at (1024, 1024); centre the drawing on (768, 768); safe box x 573–963, y 573–963.');
|
||||
expect(props?.prompt).toContain('Layout: 3 columns × 2 rows of equal, invisible cells, read left to right, top row first.');
|
||||
expect(props?.prompt).toContain('\n5. one large rose petal folded over itself');
|
||||
const stages = data.assets.find((a) => a.id === 'rose-stages-sheet');
|
||||
expect(stages?.prompt).toContain('each 384 × 1024 px');
|
||||
expect(stages?.prompt).not.toContain('Cut lines across');
|
||||
expect(stages?.prompt).toContain('Layout: 4 columns × 1 row of equal');
|
||||
});
|
||||
|
||||
it('a tall cell made on its own is made on the tall canvas, a square one on the square', () => {
|
||||
@@ -105,7 +134,7 @@ describe('the grid', () => {
|
||||
expect(soloCanvas(m.assets.find((a) => a.id === 'rose-stages-sheet')!)).toEqual({ width: 1024, height: 1536 });
|
||||
expect(soloCanvas(m.assets.find((a) => a.id === 'care-props-sheet')!)).toEqual({ width: 1024, height: 1024 });
|
||||
const bud = data.assets.find((a) => a.id === 'rose-stages-sheet')?.cells?.[0];
|
||||
expect(bud?.prompt).toContain('Canvas: 1024 × 1536 px, fully transparent background. One subject, centred on (512, 768)');
|
||||
expect(bud?.prompt).toContain('This picture: a tight bud');
|
||||
expect(bud?.prompt).toContain('Canvas: 1024 × 1536 px, transparent background. One subject, whole and centred');
|
||||
expect(bud?.prompt).toContain('Subject: a tight bud');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user