mwg API
    Preparing search index...

    Function parseColorPairs

    • ~RC(src>dst,src>dst,...)'s pairs, each side hex (#c0ffee, c0ffee) or, when resolve is given, a named colour (~RC(magenta>red)) it resolves. A pair whose either side is neither hex nor resolvable is dropped rather than aborting the whole list.

      Parameters

      • args: readonly string[]
      • Optionalresolve: (name: string) => number | undefined

      Returns PaletteMapping

      import { parseColorPairs, parseImagePath, imageModifier } from '@datamoc/mw_games/two-d/render';

      const rc = imageModifier(parseImagePath('unit.png~RC(magenta>ff0000)'), 'RC')!;
      const mapping = parseColorPairs(rc.args, (name) => (name === 'magenta' ? 0xff00ff : undefined));
      console.log(mapping); // { from: [0xff00ff], to: [0xff0000] }