#!/usr/bin/env node /** * Magenta placeholder projectile art: one PNG per spell under * client/assets/fx/projectile/spell-.png * * Canvas is 16×16. Facing: the RIGHT side (+X) is the front/tip — the same * convention as arrow.png. Runtime rotates with atan2(dy, dx) so 0° = flying east. * * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element). * Replace any file with hand-drawn art; keep magenta for tintable regions. * * node client/scripts/write-spell-projectile-template.mjs */ import { unlinkSync, existsSync } from "node:fs"; import { join, dirname } from "node:path"; import { fileURLToPath } from "node:url"; import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js"; import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js"; const SIZE = 16; /** Offset so the original 8×8 diamond sits centred on the 16×16 canvas. */ const OX = 4; const OY = 4; const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile"); /** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */ const MAGENTA = [220, 0, 220, 255]; const MAGENTA_HI = [255, 120, 255, 255]; const legacy = [ "spell-light-0.png", "spell-light-1.png", "spell-light-2.png", "spell-spark-0.png", "spell-spark-1.png", "spell-spark-2.png" ]; for (const name of legacy) { const path = join(OUT_DIR, name); if (existsSync(path)) { unlinkSync(path); console.log(`Removed legacy ${name}`); } } let wrote = 0; for (const def of Object.values(SPELL_DEFINITIONS)) { const file = join(OUT_DIR, `spell-${def.spellId}.png`); const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]); // Diamond body (same pixels as the old 8×8 art, centred) fillRect(image, OX + 3, OY + 1, 2, 1, MAGENTA); fillRect(image, OX + 2, OY + 2, 4, 1, MAGENTA); fillRect(image, OX + 1, OY + 3, 6, 2, MAGENTA); fillRect(image, OX + 2, OY + 5, 4, 1, MAGENTA); fillRect(image, OX + 3, OY + 6, 2, 1, MAGENTA); // Center highlight fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI); writeRgbaPng(file, SIZE, SIZE, image.pixels); wrote += 1; } console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`);