Color
- class Color()
An object representing an RGB Color. Values are specified in the 0-255 range.
Constructors
Methods
Constructors
- Color.constructor(r, g, b)
- Arguments
r (
number()
) – red color componentg (
number()
) – green color componentb (
number()
) – blue color component
Creates a new color object. Values are specified in the 0-255 range.
- Return type
Color
Properties
- Color.b
- Type
number
- Color.g
- Type
number
- Color.r
- Type
number
Methods
assign
copy
- Color.copy()
Creates a copy of this color
- Returns
Copy of this color
- Return type
Color
equals
fromFloatArray
- Color.fromFloatArray(arr)
- Arguments
arr (
[number]()
) – None
Sets this color from an array of normalized floating point values
- Return type
void
getFloatArray
- Color.getFloatArray()
Gets an array of floating point values representing this color. Values are clamped in the 0.0 - 1.0 range.
- Returns
array of floating point values for this color.
- Return type
(number, number, number)
set
- Color.set(r, g, b)
- Arguments
r (
number()
) – red color componentg (
number()
) – green color componentb (
number()
) – blue color component
Sets the color object. Values are specified in the 0-255 range.
- Return type
void
setFromFloat
- Color.setFromFloat(r, g, b)
- Arguments
r (
number()
) – red color componentg (
number()
) – green color componentb (
number()
) – blue color component
Sets the color object from floating point values. Values are specified in the 0.0-1.0 range.
- Return type
void
toFloatArray
- Color.toFloatArray(arr)
- Arguments
arr (
[number]()
) – array whose first three elements will be populated with the r,g, and b values of this color respectively.
Populates an array with floating point values for this color. Values are clamped in the 0.0 - 1.0 range.
- Return type
[number]
toJson
- Color.toJson()
Creates an object ready for JSON serialization.
- Returns
The prepared object.
- Return type
IColor
static black
- Color.black()
Creates a new color object initialized to black.
- Returns
new color object
- Return type
Color
static blue
- Color.blue()
Creates a new color object initialized to blue.
- Returns
new color object
- Return type
Color
static createFromFloat
- Color.createFromFloat(r, g, b)
- Arguments
r (
number()
) – red color componentg (
number()
) – green color componentb (
number()
) – blue color component
Creates a color object from floating point values. Values are specified in the 0.0-1.0 range.
- Returns
new color object
- Return type
Color
static createFromFloatArray
- Color.createFromFloatArray(values)
- Arguments
values (
[number]()
) – None
Creates a color object from an array of floating point values. Values are specified in the 0.0-1.0 range.
- Return type
Color
static fromJson
- Color.fromJson(objData)
- Arguments
objData (
unknown()
) – An object given by [[toJson]].
Creates a new [[Color]] from an object given by [[toJson]].
- Returns
The prepared object.
- Return type
Color
static green
- Color.green()
Creates a new color object initialized to green.
- Returns
new color object
- Return type
Color
static red
- Color.red()
Creates a new color object initialized to red.
- Returns
new color object
- Return type
Color
static white
- Color.white()
Creates a new color object initialized to white.
- Returns
new color object
- Return type
Color
static yellow
- Color.yellow()
Creates a new color object initialized to yellow.
- Returns
new color object
- Return type
Color