import { paletteRangeMapping, recolorTexture } from '@datamoc/mw_games/two-d/render';
import type { Texture2D } from '@datamoc/mw_games/two-d/render';
declare const texture: Texture2D;
const mapping = paletteRangeMapping([0xffffff, 0x808080, 0x000000], { min: 0xffe0e0, mid: 0xc00000, max: 0x400000 });
const redTeam = recolorTexture(texture, mapping, {}, 'nearest');
Recolours a texture by palette remap: draws it to a canvas, runs
remapPixelsover the raw pixel data, and returns a newTexturewrapping the result. The source texture is never mutated, so the same base art recolours per team without extra copies kept around by the caller. Needs a real 2D canvas context (unlikeremapPixelsitself), so passprobein a test or host integration with no DOM; omitting it usesdocument.createElement('canvas').modedefaults to'exact', correct for a discrete swap (~RC/~PAL's short, specificfromlist); apaletteRangeMappinggradient, meant to cover the whole reference palette a team's art is drawn against, wants'nearest'instead - seePaletteRemapMode's own doc for why the wrong choice silently recolours far more of the image than intended.