20 lines
795 B
JavaScript
20 lines
795 B
JavaScript
// About me: Writes assets/gameart.png from the generated artwork in src/gameart.ts.
|
|
// Kept as a separate step from the build so the committed image only changes when
|
|
// someone deliberately regenerates it.
|
|
//
|
|
// Usage: node scripts/make-gameart.mjs [outputPath]
|
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
import { dirname, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { encodePng, renderGameArt } from '../src/gameart.ts';
|
|
|
|
const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const output = resolve(projectRoot, process.argv[2] ?? 'assets/gameart.png');
|
|
|
|
mkdirSync(dirname(output), { recursive: true });
|
|
const png = encodePng(renderGameArt());
|
|
writeFileSync(output, png);
|
|
|
|
console.log(`wrote ${output} (${png.length} bytes)`);
|