// Run from the repository root: node design/examples/render-design.mjs paper lagoon 7 // This engine-independent example records geometry; it does not validate PNG pixels or UI. import { pathToFileURL } from 'node:url'; import { ART_DIRECTIONS, directionTheme } from '../../src/art-directions.js'; import { drawScene } from '../../src/renderer.js'; import { layout } from '../../src/geometry.js'; import { createStudyLevel } from '../../src/study-levels.js'; const level = createStudyLevel(3); export function recordDesign(designId = 'paper', themeId = 'lagoon', colorCount = 7) { const direction = ART_DIRECTIONS.find(d => d.id === designId); if (!direction) throw new Error(`Unknown design: ${designId}`); if (!direction.themes.some(t => t.id === themeId)) throw new Error(`Unknown theme: ${themeId}`); if (![4, 7, 9, 12].includes(colorCount)) throw new Error(`Unsupported color count: ${colorCount}`); const theme = directionTheme(direction, themeId, colorCount), commands = []; const painter = { polygon: (points, fill) => commands.push({ type: 'polygon', points, fill }), line: (points, color, width) => commands.push({ type: 'line', points, color, width }), circle: (x, y, radius, fill) => commands.push({ type: 'circle', x, y, radius, fill }), }; drawScene(painter, level, level.tiles, layout(level.cells, 600, 600), { theme }); return { designId, themeId, colorCount, background: theme.background, palette: theme.palette, cellCount: level.cells.length, commands }; } if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { const [designId = 'paper', themeId = 'lagoon', count = '7'] = process.argv.slice(2); const { commands, ...summary } = recordDesign(designId, themeId, Number(count)); console.log(JSON.stringify({ ...summary, commandCount: commands.length }, null, 2)); }