Class: MultiColorReplaceFilter

MultiColorReplaceFilter

Filter for replacing a color with another color. Similar to ColorReplaceFilter, but support multiple colors.
originalfilter

new MultiColorReplaceFilter (replacements, epsilon, maxColors)

Name Type Attributes Default Description
replacements Array<Array>

The collection of replacement items. Each item is color-pair (an array length is 2). In the pair, the first value is original color , the second value is target color.

epsilon number <optional>
0.05

Tolerance of the floating-point comparison between colors (lower = more exact, higher = more inclusive)

maxColors number <optional>

The maximum number of replacements filter is able to use. Because the fragment is only compiled once, this cannot be changed after construction. If omitted, the default value is the length of replacements.

See:

Example


  // replaces pure red with pure blue, and replaces pure green with pure white
  someSprite.filters = [new MultiColorReplaceFilter(
    [
      [0xFF0000, 0x0000FF],
      [0x00FF00, 0xFFFFFF]
    ],
    0.001
  )];

  You also could use [R, G, B] as the color
  someOtherSprite.filters = [new MultiColorReplaceFilter(
    [
      [ [1,0,0], [0,0,1] ],
      [ [0,1,0], [1,1,1] ]
    ],
    0.001
  )];

Extends

  • PIXI.Filter

Members

epsilon number

Tolerance of the floating-point comparison between colors (lower = more exact, higher = more inclusive)

Default Value:
  • 0.05

maxColors number readonly

The maximum number of color replacements supported by this filter. Can be changed only during construction.

replacements Array<Array>

The source and target colors for replacement. See constructor for information on the format.

Methods

Should be called after changing any of the contents of the replacements. This is a convenience method for resetting the replacements.