BlueGit

timfa questward

Files

questward / client / scripts / write-arrow-projectile-template.mjs

write-arrow-projectile-template.mjs

write-arrow-projectile-template.mjs 1.6 KiB Download Raw
1#!/usr/bin/env node
2/**
3 * Dual-channel arrow projectile template for client/assets/fx/projectile/arrow.png
4 *
5 * Channel convention (same as items/arrow/full-arrow.png):
6 * - Dominant RED → shaft mask (lightness = R); tinted with wood tier at runtime
7 * - Dominant BLUE → tip mask (lightness = B); tinted with metal tier at runtime
8 * - Neutral WHITE → fletching / bindings; left unchanged
9 *
10 * Regenerate after hand-editing the layout:
11 * node client/scripts/write-arrow-projectile-template.mjs
12 *
13 * Runtime: WorldView.spawnPhysicalProjectileFx uses DUAL_TINT_LIT_SPRITE shader when
14 * combat-projectile carries shaftTint + tipTint from the server.
15 */
16import { join, dirname } from "node:path";
17import { fileURLToPath } from "node:url";
18import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js";
19
20const W = 24;
21const H = 8;
22const out = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile", "arrow.png");
23
24const image = makeRgba(W, H, [0, 0, 0, 0]);
25
26// Shaft — pure red channel (wood tint applied in shader)
27for (let x = 4; x < 16; x++)
28{ fillRect(image, x, 3, 1, 2, [220, 0, 0, 255]); }
29
30// Tip — pure blue channel (metal tint applied in shader)
31fillRect(image, 16, 2, 4, 4, [0, 0, 220, 255]);
32fillRect(image, 20, 3, 2, 2, [0, 0, 255, 255]);
33
34// Fletching — white, untouched by dual tint
35fillRect(image, 0, 2, 3, 4, [245, 245, 245, 255]);
36fillRect(image, 1, 1, 2, 1, [255, 255, 255, 255]);
37fillRect(image, 1, 6, 2, 1, [255, 255, 255, 255]);
38
39writeRgbaPng(out, W, H, image.pixels);
40console.log(`Wrote dual-channel projectile template: ${out} (${W}×${H})`);