Class: ColorReplaceFilter

ColorReplaceFilter

ColorReplaceFilter, originally by mishaa, updated by timetocode http://www.html5gamedevs.com/topic/10640-outline-a-sprite-change-certain-colors/?p=69966
originalfilter

new ColorReplaceFilter (options)

Name Type Attributes Description
options ColorReplaceFilterOptions <optional>

Options for the ColorReplaceFilter constructor.

Example

// replaces true red with true blue
someSprite.filters = [new ColorReplaceFilter({
 originalColor: [1, 0, 0],
 targetColor: [0, 0, 1],
 tolerance: 0.001
 })];
// replaces the RGB color 220, 220, 220 with the RGB color 225, 200, 215
someOtherSprite.filters = [new ColorReplaceFilter({
 originalColor: [220/255.0, 220/255.0, 220/255.0],
 targetColor: [225/255.0, 200/255.0, 215/255.0],
 tolerance: 0.001
 })];
// replaces the RGB color 220, 220, 220 with the RGB color 225, 200, 215
someOtherSprite.filters = [new ColorReplaceFilter({ originalColor: 0xdcdcdc, targetColor: 0xe1c8d7, tolerance: 0.001 })];

Extends

  • Filter

Members

DEFAULT_OPTIONS ColorReplaceFilterOptions staticreadonly

Default values for options.

epsilon number Deprecated : since 6.0.0

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

Default Value:
  • 0.4
See:

newColor number | number<Array> | Float32Array Deprecated : since 6.0.0

The resulting color, as a 3 component RGB e.g. [1.0, 0.5, 1.0]

Default Value:
  • 0x000000
See:

originalColor ColorSource

The color that will be changed.

Default Value:
  • 0xff0000
Example
[1.0, 1.0, 1.0] = 0xffffff

targetColor ColorSource

The resulting color.

Default Value:
  • 0x000000
Example
[1.0, 1.0, 1.0] = 0xffffff

tolerance number

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

Default Value:
  • 0.4