PIXI.filters.ColorReplaceFilter
class ColorReplaceFilter extends PIXI.Filter
ColorReplaceFilter, originally by mishaa, updated by timetocode
http://www.html5gamedevs.com/topic/10640-outline-a-sprite-change-certain-colors/?p=69966
// 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)];
Constructor
new PIXI.filters.ColorReplaceFilter(originalColor: number | number<Array> | Float32Array, newColor: number | number<Array> | Float32Array, epsilon: number) → {}
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. |
newColor | number | number<Array> | Float32Array |
<optional> |
0x000000 |
The resulting color, as a 3 component
RGB e.g. |
epsilon | number |
<optional> |
0.4 |
Tolerance/sensitivity of the floating-point comparison between colors (lower = more exact, higher = more inclusive) |
Summary
Properties from ColorReplaceFilter
number |
|
number | number<Array> | Float32Array |
|
number | number<Array> | Float32Array |
|
Properties inherited from Filter
boolean |
|
PIXI.BLEND_MODES |
|
boolean |
If enabled is true the filter is applied, if false it will not. |
boolean |
|
PIXI.MSAA_QUALITY |
The samples of the filter. |
number |
|
number |
|
PIXI.State |
The WebGL state the filter requires to render. |
Properties inherited from Shader
PIXI.Program |
Program that the shader uses. |
Dict<any> |
|
Methods inherited from Filter
void |
|
Public Properties
epsilon: number = 0.4
Tolerance/sensitivity of the floating-point comparison between colors (lower = more exact, higher = more inclusive)
newColor: number | number<Array> | Float32Array = 0x000000
The resulting color, as a 3 component RGB e.g. [1.0, 0.5, 1.0]
originalColor: number | number<Array> | Float32Array = 0xFF0000
The color that will be changed, as a 3 component RGB e.g. [1.0, 1.0, 1.0]