Phaser API Documentation

  Version: 
Filter

The RGB class holds a single color value and allows for easy modification and reading of it, with optional on-change callback notification and a dirty flag.

Constructor:

new RGB([red], [green], [blue])

Parameters:

name type arguments description
red number <optional>

The red color value. A number between 0 and 1.

green number <optional>

The green color value. A number between 0 and 1.

blue number <optional>

The blue color value. A number between 0 and 1.

Since: 3.50.0
Source: src/display/RGB.js (Line 10)

Members

<private> _rgb: Array.<number>
Focus
Focus

Description:

Cached RGB values.

Type:
Array.<number>
Since: 3.50.0
Source: src/display/RGB.js (Line 30)
Focus
Focus
b: number
Focus
Focus

Description:

The blue color value. Between 0 and 1.

Changing this property will flag this RGB object as being dirty and invoke the onChangeCallback , if set.

Type:
number
Since: 3.50.0
Source: src/display/RGB.js (Line 176)
Focus
Focus
dirty: boolean
Focus
Focus

Description:

Is this color dirty?

Type:
boolean
Since: 3.50.0
Source: src/display/RGB.js (Line 51)
Focus
Focus
g: number
Focus
Focus

Description:

The green color value. Between 0 and 1.

Changing this property will flag this RGB object as being dirty and invoke the onChangeCallback , if set.

Type:
number
Since: 3.50.0
Source: src/display/RGB.js (Line 151)
Focus
Focus
onChangeCallback: function
Focus
Focus

Description:

This callback will be invoked each time one of the RGB color values change.

The callback is sent the new color values as the parameters.

Type:
function
Since: 3.50.0
Source: src/display/RGB.js (Line 40)
Focus
Focus
r: number
Focus
Focus

Description:

The red color value. Between 0 and 1.

Changing this property will flag this RGB object as being dirty and invoke the onChangeCallback , if set.

Type:
number
Since: 3.50.0
Source: src/display/RGB.js (Line 126)
Focus
Focus

Methods

destroy()
Focus
Focus

Description:

Nulls any external references this object contains.

Since: 3.50.0
Source: src/display/RGB.js (Line 201)
Focus
Focus
equals(red, green, blue)
Focus
Focus

Description:

Compares the given rgb parameters with those in this object and returns a boolean true value if they are equal, otherwise it returns false.

Parameters:

name type description
red number

The red value to compare with this object.

green number

The green value to compare with this object.

blue number

The blue value to compare with this object.

Returns:
Description:

true if the given values match those in this object, otherwise false.

Type:
  • boolean
Since: 3.50.0
Source: src/display/RGB.js (Line 89)
Focus
Focus
onChange()
Focus
Focus

Description:

Internal on change handler. Sets this object as being dirty and then invokes the onChangeCallback, if set, passing in the new RGB values.

Since: 3.50.0
Source: src/display/RGB.js (Line 109)
Focus
Focus
set([red], [green], [blue])
Focus
Focus

Description:

Sets the red, green and blue values of this RGB object, flags it as being dirty and then invokes the onChangeCallback, if set.

Parameters:

name type arguments description
red number <optional>

The red color value. A number between 0 and 1.

green number <optional>

The green color value. A number between 0 and 1.

blue number <optional>

The blue color value. A number between 0 and 1.

Returns:
Description:

This RGB instance.

Since: 3.50.0
Source: src/display/RGB.js (Line 63)
Focus
Focus