#!/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, readdirSync } 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, spellProjectileStem } 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 keep = new Set(["arrow.png", "arrow-tipped.png"]); const wanted = new Set(); let wrote = 0; for (const def of Object.values(SPELL_DEFINITIONS)) { const stem = spellProjectileStem(def.element, def.tier, def.spellId); wanted.add(`${stem}.png`); const file = join(OUT_DIR, `${stem}.png`); const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]); 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); fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI); writeRgbaPng(file, SIZE, SIZE, image.pixels); wrote += 1; } for (const name of readdirSync(OUT_DIR)) { if (!name.startsWith("spell-") || !name.endsWith(".png")) { continue; } if (wanted.has(name) || keep.has(name)) { continue; } unlinkSync(join(OUT_DIR, name)); console.log(`Removed obsolete ${name}`); } console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`);