Color
-
class
common.Color() An object representing an RGB Color. Values are specified in the 0-255 range.
Constructors
-
common.Color.constructor() - Color(r: number, g: number, b: number):
ColorCreates a new color object. Values are specified in the 0-255 range.
Parameters
r: number
red color componentg: number
green color componentb: number
blue color componentReturns:
Color
Properties
-
common.Color.b - b: number
-
common.Color.g - g: number
-
common.Color.r - r: number
Methods
-
static common.Color.black() static
black():ColorCreates a new color object initialized to black.
Returns:
Colornew color object
-
static common.Color.blue() static
blue():ColorCreates a new color object initialized to blue.
Returns:
Colornew color object
-
static common.Color.createFromFloat() static
createFromFloat(r: number, g: number, b: number):ColorCreates a color object from floating point values. Values are specified in the 0.0-1.0 range.
Parameters
r: number
red color componentg: number
green color componentb: number
blue color componentReturns:
Colornew color object
-
static common.Color.createFromFloatArray() static
createFromFloatArray(values: number[]):ColorCreates a color object from an array of floating point values. Values are specified in the 0.0-1.0 range.
Parameters
values: number[]Returns:
Color
-
static common.Color.fromHexString() static
fromHexString(hexString: string):ColorCreates a color object from a hexadecimal string.
Parameters
hexString: string
Hexadecimal string representation of the color.Returns:
Colornew color object
-
static common.Color.fromJson() static
fromJson(objData: unknown):ColorCreates a new [[Color]] from an object given by [[toJson]].
Parameters
objData: unknown
An object given by [[toJson]].Returns:
ColorThe prepared object.
-
static common.Color.green() static
green():ColorCreates a new color object initialized to green.
Returns:
Colornew color object
-
static common.Color.red() static
red():ColorCreates a new color object initialized to red.
Returns:
Colornew color object
-
static common.Color.white() static
white():ColorCreates a new color object initialized to white.
Returns:
Colornew color object
-
static common.Color.yellow() static
yellow():ColorCreates a new color object initialized to yellow.
Returns:
Colornew color object
-
common.Color.assign() - assign(color:
Color): thisSets this color equal to another color
Parameters
color:
Colorthe point whose values will be used to set this colorReturns: this
the color object
-
common.Color.equals() - equals(color:
Color): booleanCompares this color with another color
Parameters
color:
Colorthe color to compare withReturns: boolean
True if the values of this color equal the other. False otherwise.
-
common.Color.fromFloatArray() - fromFloatArray(arr: number[]): void
Sets this color from an array of normalized floating point values
Parameters
arr: number[]
the array to assign fromReturns: void
-
common.Color.getFloatArray() - getFloatArray(): [number, number, number]
Gets an array of floating point values representing this color. Values are clamped in the 0.0 - 1.0 range.
Returns: [number, number, number]
array of floating point values for this color.
-
common.Color.set() - set(r: number, g: number, b: number): void
Sets the color object. Values are specified in the 0-255 range.
Parameters
r: number
red color componentg: number
green color componentb: number
blue color componentReturns: void
-
common.Color.setFromFloat() - setFromFloat(r: number, g: number, b: number): void
Sets the color object from floating point values. Values are specified in the 0.0-1.0 range.
Parameters
r: number
red color componentg: number
green color componentb: number
blue color componentReturns: void
-
common.Color.toFloatArray() - toFloatArray(arr: number[]?): number[]
Populates an array with floating point values for this color. Values are clamped in the 0.0 - 1.0 range.
Parameters
arr: number[] = …
array whose first three elements will be populated with the r,g, and b values of this color respectively.Returns: number[]
-
common.Color.toHexString() - toHexString(): string
Converts the color to a hexadecimal string.
Returns: string
Hexadecimal string representation of the color.