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 (originalColor, newColor, epsilon)

Name Type Attributes Default Description
originalColor number | number<Array> | Float32Array <optional>
0xFF0000

The color that will be changed, as a 3 component RGB e.g. [1.0, 1.0, 1.0]

newColor number | number<Array> | Float32Array <optional>
0x000000

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

epsilon number <optional>
0.4

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

See:

Example


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

Extends

  • PIXI.Filter

Members

epsilon number

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

Default Value:
  • 0.4

newColor number | number<Array> | Float32Array

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

Default Value:
  • 0x000000

originalColor number | number<Array> | Float32Array

The color that will be changed, as a 3 component RGB e.g. [1.0, 1.0, 1.0]

Default Value:
  • 0xFF0000