Added QFT
This commit is contained in:
32
tools/render-qft-svg.mjs
Normal file
32
tools/render-qft-svg.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Render one QFT plate to SVG from the CLI.
|
||||
Usage:
|
||||
node tools/render-qft-svg.mjs --seed SEED [out.svg] [size] [k=v ...]
|
||||
Modular sibling of tools/render-svg.mjs and render-milkweed-svg.mjs.
|
||||
*/
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { generateQFTScene } from '../src/qft/scene.js';
|
||||
import { paramsFromSeed } from '../src/qft/params.js';
|
||||
import { renderQFTSVG } from '../src/qft/renderer.js';
|
||||
|
||||
const argv = process.argv.slice(2);
|
||||
if (argv[0] !== '--seed') {
|
||||
console.error('usage: node tools/render-qft-svg.mjs --seed SEED [out.svg] [size] [k=v ...]');
|
||||
process.exit(1);
|
||||
}
|
||||
const seed = argv[1] || 'QFT-001';
|
||||
const out = argv[2] || `/tmp/qft-${seed}.svg`;
|
||||
let size = 4800;
|
||||
if (argv[3] && !argv[3].includes('=')) size = +argv[3];
|
||||
|
||||
const params = paramsFromSeed(seed);
|
||||
for (const a of argv) {
|
||||
if (!a.includes('=')) continue;
|
||||
const [k, ...rest] = a.split('=');
|
||||
const v = rest.join('=');
|
||||
params[k] = v === 'true' ? true : v === 'false' ? false
|
||||
: (v.trim() !== '' && !isNaN(+v) ? +v : v);
|
||||
}
|
||||
|
||||
const svg = renderQFTSVG(generateQFTScene(params), params, size);
|
||||
writeFileSync(out, svg);
|
||||
console.log(`QFT SVG -> ${out} (${(svg.length / 1024).toFixed(0)} KB, archetype=${params.archetype})`);
|
||||
Reference in New Issue
Block a user