Class: MultiColorReplaceFilter

MultiColorReplaceFilter

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

new MultiColorReplaceFilter (options)

Name Type Attributes Description
options MultiColorReplaceFilterOptions <optional>

Options for the MultiColorReplaceFilter constructor.

Example

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

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

Extends

  • Filter

Members

DEFAULT_OPTIONS MultiColorReplaceFilterOptions staticreadonly

Default values for options.

epsilon number Deprecated : since 6.0.0

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<[ColorSource, ColorSource]>

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

tolerance number

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

Default Value:
  • 0.05

Methods

refresh () void

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

TODO
  • implement nested proxy to remove the need for this function