Class: ColorMatrix

Phaser.Display. ColorMatrix

The ColorMatrix class creates a 5x4 matrix that can be used in shaders and graphics operations. It provides methods required to modify the color values, such as adjusting the brightness, setting a sepia tone, hue rotation and more.

Use the method getData to return a Float32Array containing the current color values.


new ColorMatrix()

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 9)

Members


alpha :number

The value that determines how much of the original color is used when mixing the colors. A value between 0 (all original) and 1 (all final)

Type:
  • number
Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 43)

Methods


blackWhite( [multiply])

Sets this ColorMatrix to be black and white.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 289)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

brightness( [value] [, multiply])

Changes the brightness of this ColorMatrix by the given amount.

Parameters:
Name Type Argument Default Description
value number <optional>
0

The amount of brightness to apply to this ColorMatrix. Between 0 (black) and 1.

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 168)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

brown( [multiply])

Applies a brown tone to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 450)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

contrast( [value] [, multiply])

Change the contrast of this ColorMatrix by the amount given.

Parameters:
Name Type Argument Default Description
value number <optional>
0

The amount of contrast to apply to this ColorMatrix.

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 311)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

desaturateLuminance( [multiply])

Apply a desaturated luminance to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 360)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

getData()

Gets the ColorMatrix as a Float32Array.

Can be used directly as a 1fv shader uniform value.

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 139)
Returns:

The ColorMatrix as a Float32Array.

Type
Float32Array

grayscale( [value] [, multiply])

Sets this ColorMatrix to be grayscale.

Parameters:
Name Type Argument Default Description
value number <optional>
1

The grayscale scale (0 is black).

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 270)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

hue( [rotation] [, multiply])

Rotates the hues of this ColorMatrix by the value given.

Parameters:
Name Type Argument Default Description
rotation number <optional>
0

The amount of hue rotation to apply to this ColorMatrix, in degrees.

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 238)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

kodachrome( [multiply])

Applies a kodachrome color effect to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 494)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

lsd( [multiply])

Applies a trippy color tone to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 428)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

multiply(a)

Multiplies the two given matrices.

Parameters:
Name Type Description
a Array.<number>

The 5x4 array to multiply with ColorMatrix._matrix.

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 582)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

negative( [multiply])

Converts this ColorMatrix to have negative values.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 338)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

night( [intensity] [, multiply])

Applies a night vision tone to this ColorMatrix.

Parameters:
Name Type Argument Default Description
intensity number <optional>
0.1

The intensity of this effect.

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 404)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

polaroid( [multiply])

Applies a polaroid color effect to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 538)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

reset()

Resets the ColorMatrix.

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 95)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

saturate( [value] [, multiply])

Changes the saturation of this ColorMatrix by the given amount.

Parameters:
Name Type Argument Default Description
value number <optional>
0

The amount of saturation to apply to this ColorMatrix.

multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 194)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

saturation( [multiply])

Desaturates this ColorMatrix (removes color from it).

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 221)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

sepia( [multiply])

Applies a sepia tone to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 382)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

set(value)

Sets this ColorMatrix from the given array of color values.

Parameters:
Name Type Description
value Array.<number>

The ColorMatrix values to set.

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 76)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

shiftToBGR( [multiply])

Shifts the values of this ColorMatrix into BGR order.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 560)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

technicolor( [multiply])

Applies a technicolor color effect to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 516)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix

vintagePinhole( [multiply])

Applies a vintage pinhole color effect to this ColorMatrix.

Parameters:
Name Type Argument Default Description
multiply boolean <optional>
false

Multiply the resulting ColorMatrix (true), or set it (false) ?

Since: 3.50.0
Source: src/display/ColorMatrix.js (Line 472)
Returns:

This ColorMatrix instance.

Type
Phaser.Display.ColorMatrix