[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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user