Class: ColorMatrixFilter

PIXI.filters~ColorMatrixFilter

The ColorMatrixFilter class lets you apply a 5x4 matrix transformation on the RGBA color and alpha values of every pixel on your displayObject to produce a result with a new set of RGBA color and alpha values. It's pretty powerful!

 let colorMatrix = new PIXI.filters.ColorMatrixFilter();
 container.filters = [colorMatrix];
 colorMatrix.contrast(2);

new ColorMatrixFilter ()

Author:

Extends

Members

alpha number

The opacity value to use when mixing the original and resultant colors.

When the value is 0, the original color is used without modification. When the value is 1, the result color is used. When in the range (0, 1) the color is interpolated between the original and result by this amount.

Default Value:
  • 1

autoFit boolean inherited overrides

如果启用,PixiJS将使滤镜区域适合边界以提高性能。 如果它不适用于指定的着色器,请将其关闭。

blendMode number inherited overrides

设置滤镜的混合模式

Default Value:
  • PIXI.BLEND_MODES.NORMAL

enabled boolean inherited overrides

如果启用为true,则应用过滤器;如果为false,则不应用过滤器。

legacy boolean readonly inherited overrides

传统过滤器使用属性中的位置和uvs

matrix Array.<number>

The matrix of the color matrix filter

Default Value:
  • [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]

padding number inherited overrides

滤镜的填充。一些滤镜需要额外的空间呼吸运动,例如模糊。 增大此值将为应用滤镜的对象的边界增加额外的宽度和高度。

着色器使用的程序

resolution number inherited overrides

滤镜的分辨率。将此值设置得较低会降低质量,但会提高滤镜的性能。

滤镜需要渲染的WebGL状态

uniforms object readonly inherited overrides

着色器uniform统,uniformGroup.uniforms 的快捷方式

Methods

_loadMatrix (matrix, multiply)

Transforms current matrix and set the new one

Name Type Default Description
matrix Array.<number>

5x4 matrix

multiply boolean false

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

apply (filterManager, input, output, clearMode, currentState) inherited overrides

应用滤镜

Name Type Description
filterManager PIXI.systems.FilterSystem

渲染器从中检索滤镜

input PIXI.RenderTexture

输入的渲染目标。

output PIXI.RenderTexture

要输出到的目标。

clearMode PIXI.CLEAR_MODES

在渲染到输出之前是否清除输出。

currentState object optional

它是滤镜的当前状态。 currentState中有一些有用的属性: target, filters, sourceFrame, destinationFrame, renderTarget, resolution

blackAndWhite (multiply)

Set the black and white matrice.

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

brightness (b, multiply)

Adjusts brightness

Name Type Description
b number

value of the brigthness (0-1, where 0 is black)

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

browni (multiply)

Brown delicious browni filter (thanks Dominic Szablewski)

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

colorTone (desaturation, toned, lightColor, darkColor, multiply)

We don't know exactly what it does, kind of gradient map, but funny to play with!

Name Type Description
desaturation number

Tone values.

toned number

Tone values.

lightColor string

Tone values, example: 0xFFE580

darkColor string

Tone values, example: 0xFFE580

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

contrast (amount, multiply)

Set the contrast matrix, increase the separation between dark and bright Increase contrast : shadows darker and highlights brighter Decrease contrast : bring the shadows up and the highlights down

Name Type Description
amount number

value of the contrast (0-1)

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

desaturate ()

Desaturate image (remove color)

Call the saturate function

greyscale (scale, multiply)

Set the matrices in grey scales

Name Type Description
scale number

value of the grey (0-1, where 0 is black)

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

hue (rotation, multiply)

Set the hue property of the color

Name Type Description
rotation number

in degrees

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

kodachrome (multiply)

Color reversal film introduced by Eastman Kodak in 1935. (thanks Dominic Szablewski)

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

lsd (multiply)

LSD effect

Multiply the current matrix

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

negative (multiply)

Negative image (inverse of classic rgb matrix)

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

night (intensity, multiply)

Night effect

Name Type Description
intensity number

The intensity of the night effect.

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

polaroid (multiply)

Polaroid filter

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

predator (amount, multiply)

Predator effect

Erase the current matrix by setting a new indepent one

Name Type Description
amount number

how much the predator feels his future victim

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

Erase the current matrix by setting the default one

saturate (amount, multiply)

Set the saturation matrix, increase the separation between colors Increase saturation : increase contrast, brightness, and sharpness

Name Type Default Description
amount number 0

The saturation amount (0-1)

multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

sepia (multiply)

Sepia image

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

technicolor (multiply)

Color motion picture process invented in 1916 (thanks Dominic Szablewski)

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

toBGR (multiply)

Filter who transforms : Red -> Blue and Blue -> Red

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix

vintage (multiply)

Vintage filter (thanks Dominic Szablewski)

Name Type Description
multiply boolean

if true, current matrix and matrix are multiplied. If false, just set the current matrix with @param matrix