mwg API
    Preparing search index...

    Function applyTextureModifiers

    • Applies the modifiers that need real pixel access or a sibling texture rather than a sprite property or a Pixi filter: ~RC (exact palette swap, src>dst hex or named-colour pairs - see resolveColor/parseColorPairs), ~PAL (the same swap from two comma-separated colour lists either side of one > - see parsePaletteLists), ~BLIT (composite another image on top at an offset), ~MASK (take alpha from another image at an offset, keeping this image's own colour), ~BLEND (an exact per-pixel lerp towards a colour, via blendPixels) and ~ROTATE (rotates the source pixels themselves and expands the surface, via rotatePixels - this is why ~ROTATE lives here rather than as a sprite transform: it has to be right for terrain and anything else that must keep tiling after the rotation). ~ROTATE(degrees) samples nearest-neighbour, which is exact at multiples of a quarter turn; ~ROTATE(degrees,linear) interpolates instead, for the angles that are not, at four reads a pixel, and both are bake-time work rather than per-frame - see rotatePixels. ~BLIT/~MASK need probe.resolveTexture to find the sibling image; without it they are skipped rather than treated as an error, since a caller that only wants ~RC/~PAL has no sibling image to resolve. resolveTexture receives the argument exactly as written, nested modifiers included (~BLIT(claws.png~FL(horiz),4,4) calls it with 'claws.png~FL(horiz)', not 'claws.png') - parsing and applying those recursively is the caller's own job, this function composites whatever texture it is handed back.

      Parameters

      Returns Texture

      import { Texture } from 'pixi.js';
      import { applyTextureModifiers, parseImagePath } from '@datamoc/mw_games/two-d/render';
      const recolored = applyTextureModifiers(Texture.EMPTY, parseImagePath('unit.png~RC(ff00ff>ff0000)'));