#

API Documentation for: NEXT
Show: Inherited Protected Private Deprecated

# ColorMatrix Class

Defined in: `ColorMatrix:39`
Module: EaselJS

Provides helper functions for assembling a matrix for use with the ColorMatrixFilter, or can be used directly as the matrix for a ColorMatrixFilter. Most methods return the instance to facilitate chained calls.

#### Example

     myColorMatrix.adjustHue(20).adjustBrightness(50);

See Filter for an example of how to apply filters, or ColorMatrixFilter for an example of how to use ColorMatrix to change a DisplayObject's color.

## Constructor

### `ColorMatrix`

(

- `brightness`
- `contrast`
- `saturation`
- `hue`

)

Defined in `ColorMatrix:39`

#### Parameters:

- `brightness` Number
- `contrast` Number
- `saturation` Number
- `hue` Number

- Index
- Methods
- Properties

## Item Index

### Methods

- _cleanValue
- _fixMatrix
- _multiplyMatrix
- adjustBrightness
- adjustColor
- adjustContrast
- adjustHue
- adjustSaturation
- clone
- concat
- copyMatrix
- initialize
- reset
- toArray
- toString

### Properties

- DELTA_INDEX static
- IDENTITY_MATRIX static
- LENGTH static

## Methods

### `_cleanValue`

(

- `value`
- `limit`

)
protected

Defined in `_cleanValue:333`

Make sure values are within the specified range, hue has a limit of 180, brightness is 255, others are 100.

#### Parameters:

- `value` Number

  The raw number

- `limit` Number

  The maximum that the number can be. The minimum is the limit * -1.

### `_fixMatrix`

(

- `matrix`

)
protected

Defined in `_fixMatrix:345`

Makes sure matrixes are 5x5 (25 long).

#### Parameters:

- `matrix` Array

### `_multiplyMatrix`

(

- `matrix`

)
protected

Defined in `_multiplyMatrix:311`

#### Parameters:

- `matrix` Array

### `adjustBrightness`

(

- `value`

)
ColorMatrix

Defined in `adjustBrightness:150`

Adjusts the brightness of pixel color by adding the specified value to the red, green and blue channels. Positive values will make the image brighter, negative values will make it darker.

#### Parameters:

- `value` Number

  A value between -255 & 255 that will be added to the RGB channels.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `adjustColor`

(

- `brightness`
- `contrast`
- `saturation`
- `hue`

)
ColorMatrix

Defined in `adjustColor:132`

Shortcut method to adjust brightness, contrast, saturation and hue. Equivalent to calling adjustHue(hue), adjustContrast(contrast), adjustBrightness(brightness), adjustSaturation(saturation), in that order.

#### Parameters:

- `brightness` Number
- `contrast` Number
- `saturation` Number
- `hue` Number

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `adjustContrast`

(

- `value`

)
ColorMatrix

Defined in `adjustContrast:170`

Adjusts the contrast of pixel color. Positive values will increase contrast, negative values will decrease contrast.

#### Parameters:

- `value` Number

  A value between -100 & 100.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `adjustHue`

(

- `value`

)
ColorMatrix

Defined in `adjustHue:227`

Adjusts the hue of the pixel color.

#### Parameters:

- `value` Number

  A value between -180 & 180.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `adjustSaturation`

(

- `value`

)
ColorMatrix

Defined in `adjustSaturation:202`

Adjusts the color saturation of the pixel. Positive values will increase saturation, negative values will decrease saturation (trend towards greyscale).

#### Parameters:

- `value` Number

  A value between -100 & 100.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `clone`

() ColorMatrix

Defined in `clone:264`

Returns a clone of this ColorMatrix.

#### Returns:

ColorMatrix:

A clone of this ColorMatrix.

### `concat`

(

- `matrix`

)
ColorMatrix

Defined in `concat:251`

Concatenates (multiplies) the specified matrix with this one.

#### Parameters:

- `matrix` Array

  An array or ColorMatrix instance.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `copyMatrix`

(

- `matrix`

)
ColorMatrix

Defined in `copyMatrix:286`

Copy the specified matrix's values to this matrix.

#### Parameters:

- `matrix` Array

  An array or ColorMatrix instance.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `initialize`

(

- `brightness`
- `contrast`
- `saturation`
- `hue`

)
protected

Defined in `initialize:108`

Initialization method.

#### Parameters:

- `brightness` Number
- `contrast` Number
- `saturation` Number
- `hue` Number

### `reset`

() ColorMatrix

Defined in `reset:123`

Resets the matrix to identity values.

#### Returns:

ColorMatrix:

The ColorMatrix instance the method is called on (useful for chaining calls.)

### `toArray`

() Array

Defined in `toArray:273`

Return a length 25 (5x5) array instance containing this matrix's values.

#### Returns:

Array:

An array holding this matrix's values.

### `toString`

() String

Defined in `toString:300`

Returns a string representation of this object.

#### Returns:

String:

a string representation of the instance.

## Properties

### `DELTA_INDEX`

Array protected static

Defined in `DELTA_INDEX:62`

Array of delta values for contrast calculations.

### `IDENTITY_MATRIX`

Array protected static

Defined in `IDENTITY_MATRIX:83`

Identity matrix values.

### `LENGTH`

Number protected static

Defined in `LENGTH:98`

The constant length of a color matrix.