| 1 | #!/usr/bin/env node |
| 2 | /** |
| 3 | * Magenta placeholder projectile art: one PNG per spell under |
| 4 | * client/assets/fx/projectile/spell-<spellId>.png |
| 5 | * |
| 6 | * Canvas is 16×16. Facing: the RIGHT side (+X) is the front/tip — the same |
| 7 | * convention as arrow.png. Runtime rotates with atan2(dy, dx) so 0° = flying east. |
| 8 | * |
| 9 | * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element). |
| 10 | * Replace any file with hand-drawn art; keep magenta for tintable regions. |
| 11 | * |
| 12 | * node client/scripts/write-spell-projectile-template.mjs |
| 13 | */ |
| 14 | import { unlinkSync, existsSync } from "node:fs"; |
| 15 | import { join, dirname } from "node:path"; |
| 16 | import { fileURLToPath } from "node:url"; |
| 17 | import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js"; |
| 18 | import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js"; |
| 19 | |
| 20 | const SIZE = 16; |
| 21 | /** Offset so the original 8×8 diamond sits centred on the 16×16 canvas. */ |
| 22 | const OX = 4; |
| 23 | const OY = 4; |
| 24 | const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile"); |
| 25 | |
| 26 | /** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */ |
| 27 | const MAGENTA = [220, 0, 220, 255]; |
| 28 | const MAGENTA_HI = [255, 120, 255, 255]; |
| 29 | |
| 30 | const legacy = [ |
| 31 | "spell-light-0.png", |
| 32 | "spell-light-1.png", |
| 33 | "spell-light-2.png", |
| 34 | "spell-spark-0.png", |
| 35 | "spell-spark-1.png", |
| 36 | "spell-spark-2.png" |
| 37 | ]; |
| 38 | for (const name of legacy) |
| 39 | { |
| 40 | const path = join(OUT_DIR, name); |
| 41 | if (existsSync(path)) |
| 42 | { |
| 43 | unlinkSync(path); |
| 44 | console.log(`Removed legacy ${name}`); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | let wrote = 0; |
| 49 | for (const def of Object.values(SPELL_DEFINITIONS)) |
| 50 | { |
| 51 | const file = join(OUT_DIR, `spell-${def.spellId}.png`); |
| 52 | const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]); |
| 53 | // Diamond body (same pixels as the old 8×8 art, centred) |
| 54 | fillRect(image, OX + 3, OY + 1, 2, 1, MAGENTA); |
| 55 | fillRect(image, OX + 2, OY + 2, 4, 1, MAGENTA); |
| 56 | fillRect(image, OX + 1, OY + 3, 6, 2, MAGENTA); |
| 57 | fillRect(image, OX + 2, OY + 5, 4, 1, MAGENTA); |
| 58 | fillRect(image, OX + 3, OY + 6, 2, 1, MAGENTA); |
| 59 | // Center highlight |
| 60 | fillRect(image, OX + 3, OY + 3, 2, 2, MAGENTA_HI); |
| 61 | writeRgbaPng(file, SIZE, SIZE, image.pixels); |
| 62 | wrote += 1; |
| 63 | } |
| 64 | |
| 65 | console.log(`Wrote ${wrote} magenta spell projectile placeholders (${SIZE}×${SIZE}) in ${OUT_DIR}`); |