PIXI.filters.MultiColorReplaceFilter
class MultiColorReplaceFilter extends PIXI.Filter
Filter for replacing a color with another color. Similar to ColorReplaceFilter, but support multiple
colors.
// 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
)];
Constructor
new PIXI.filters.MultiColorReplaceFilter(replacements: Array<Array>, epsilon: number, maxColors: number) → {}
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 |
Summary
Properties from MultiColorReplaceFilter
number |
|
number |
|
Array<Array> |
The source and target colors for replacement. See constructor for information on the format. |
Methods from MultiColorReplaceFilter
void |
|
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.05
Tolerance of the floating-point comparison between colors (lower = more exact, higher = more inclusive)
maxColors: number
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.
Public Methods
refresh() → {void}
Should be called after changing any of the contents of the replacements.
This is a convenience method for resetting the replacements
.
Type | Description |
---|---|
void |