Skip to main content
Version: Phaser v4.0.0

ColorMatrix

The ColorMatrix Filter Controller.

This filter controller manages the color matrix effect for a Camera.

The color matrix effect is a visual technique that involves manipulating the colors of an image or scene using a mathematical matrix. This process can adjust hue, saturation, brightness, and contrast, allowing developers to create various stylistic appearances or mood settings within the game. Common applications include simulating different lighting conditions, applying color filters, or achieving a specific visual style.

A ColorMatrix effect is added to a Camera via the FilterList component:


const camera = this.cameras.main;



const cmFilter = camera.filters.internal.addColorMatrix();

camera.filters.external.addColorMatrix();



// To set the matrix values:

cmFilter.colorMatrix.sepia();

Constructor

new ColorMatrix(camera)

Parameters

nametypeoptionaldescription
cameraPhaser.Cameras.Scene2D.CameraNoThe camera that owns this filter.

Scope: static

Extends

Phaser.Filters.Controller

Source: src/filters/ColorMatrix.js#L11
Since: 4.0.0

Inherited Members

From Phaser.Filters.Controller:


Public Members

colorMatrix

colorMatrix: Phaser.Display.ColorMatrix

Description:

The color matrix instance for this effect. Use this to apply preset or custom color transformations such as sepia, grayscale, saturation, brightness, hue rotation, and more.

Source: src/filters/ColorMatrix.js#L49
Since: 4.0.0


Inherited Methods

From Phaser.Filters.Controller:


Public Methods

destroy

<instance> destroy()

Description:

Destroys this filter, releasing all references and resources.

Overrides: Phaser.Filters.Controller#destroy

Source: src/filters/ColorMatrix.js#L61
Since: 4.0.0