RGB
The RGB class holds a single color value expressed as normalized red, green, and blue components, each in the range 0 to 1. It is used internally by WebGL pipelines and other Phaser systems that need to track color state efficiently. Changes to any component automatically set the dirty flag and invoke an optional onChangeCallback, making it straightforward to react to color mutations without manual polling.
Constructor
new RGB([red], [green], [blue])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| red | number | Yes | 0 | The red color value. A number between 0 and 1. |
| green | number | Yes | 0 | The green color value. A number between 0 and 1. |
| blue | number | Yes | 0 | The blue color value. A number between 0 and 1. |
Scope: static
Source: src/display/RGB.js#L10
Since: 3.50.0
Public Members
b
b: number
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.
Source: src/display/RGB.js#L180
Since: 3.50.0
dirty
dirty: boolean
Description:
Is this color dirty?
Source: src/display/RGB.js#L55
Since: 3.50.0
g
g: number
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.
Source: src/display/RGB.js#L155
Since: 3.50.0
onChangeCallback
onChangeCallback: function
Description:
This callback will be invoked each time one of the RGB color values change.
The callback receives the red, green, and blue values as three separate numeric arguments, each in the range 0 to 1.
Source: src/display/RGB.js#L43
Since: 3.50.0
r
r: number
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.
Source: src/display/RGB.js#L130
Since: 3.50.0
Public Methods
destroy
<instance> destroy()
Description:
Destroys this RGB instance by nulling the onChangeCallback reference, releasing any external listener held by this object.
Source: src/display/RGB.js#L205
Since: 3.50.0
equals
<instance> equals(red, green, blue)
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 | optional | description |
|---|---|---|---|
| red | number | No | The red value to compare with this object. |
| green | number | No | The green value to compare with this object. |
| blue | number | No | The blue value to compare with this object. |
Returns: boolean - true if the given values match those in this object, otherwise false.
Source: src/display/RGB.js#L93
Since: 3.50.0
onChange
<instance> onChange()
Description:
Internal on change handler. Sets this object as being dirty and then invokes the onChangeCallback, if set, passing in the new RGB values.
Source: src/display/RGB.js#L113
Since: 3.50.0
set
<instance> set([red], [green], [blue])
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 | optional | default | description |
|---|---|---|---|---|
| red | number | Yes | 0 | The red color value. A number between 0 and 1. |
| green | number | Yes | 0 | The green color value. A number between 0 and 1. |
| blue | number | Yes | 0 | The blue color value. A number between 0 and 1. |
Returns: Phaser.Display.RGB - This RGB instance.
Source: src/display/RGB.js#L67
Since: 3.50.0