Color4

Objects

Description

class Color4

Constructor

new Color4(r, g, b, a)

Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha.

Parameters

Name Type Description
optional r number
optional g number
optional b number

Members

r : number

g : number

b : number

a : number

Methods

addInPlace(right) Color4

Adds in place the passed Color4 values to the current Color4.

Returns the updated Color4.

Parameters

Name Type Description
right Color4

asArray() number[]

Returns a new array populated with 4 numeric elements : red, green, blue, alpha values.

toArray(array, index) Color4

Stores from the starting index in the passed array the Color4 successive values.

Returns the Color4.

Parameters

Name Type Description
array number[]
optional index number

add(right) Color4

Returns a new Color4 set with the added values of the current Color4 and of the passed one.

Parameters

Name Type Description
right Color4

subtract(right) Color4

Returns a new Color4 set with the subtracted values of the passed one from the current Color4.

Parameters

Name Type Description
right Color4

subtractToRef(right, result) Color4

Subtracts the passed ones from the current Color4 values and stores the results in "result".

Returns the Color4.

Parameters

Name Type Description
right Color4
result Color4

scale(scale) Color4

Creates a new Color4 with the current Color4 values multiplied by scale.

Parameters

Name Type Description
scale number

scaleToRef(scale, result) Color4

Multiplies the current Color4 values by scale and stores the result in "result".

Returns the Color4.

Parameters

Name Type Description
scale number
result Color4

multiply(color) Color4

Multipy an RGBA Color4 value by another and return a new Color4 object

@returns A new Color4.

Parameters

Name Type Description
color Color4 The Color4 (RGBA) value to multiply by

multiplyToRef(color, result) Color4

Multipy an RGBA Color4 value by another and push the result in a reference value

@returns the result Color4.

Parameters

Name Type Description
color Color4 The Color4 (RGBA) value to multiply by
result Color4 The Color4 (RGBA) to fill the result in

toString() string

Returns a string with the Color4 values.

getClassName() string

Returns the string "Color4"

getHashCode() number

Return the Color4 hash code as a number.

clone() Color4

Creates a new Color4 copied from the current one.

copyFrom(source) Color4

Copies the passed Color4 values into the current one.

Returns the updated Color4.

Parameters

Name Type Description
source Color4

copyFromFloats(r, g, b, a) Color4

Copies the passed float values into the current one.

Returns the updated Color4.

Parameters

Name Type Description
r number
g number
b number

set(r, g, b, a) Color4

Copies the passed float values into the current one.

Returns the updated Color4.

Parameters

Name Type Description
r number
g number
b number

toHexString() string

Returns a string containing the hexadecimal Color4 code.

toLinearSpace() Color4

Returns a new Color4 converted to linear space.

toLinearSpaceToRef(convertedColor) Color4

Converts the Color4 values to linear space and stores the result in "convertedColor".

Returns the unmodified Color4.

Parameters

Name Type Description
convertedColor Color4

toGammaSpace() Color4

Returns a new Color4 converted to gamma space.

toGammaSpaceToRef(convertedColor) Color4

Converts the Color4 values to gamma space and stores the result in "convertedColor".

Returns the unmodified Color4.

Parameters

Name Type Description
convertedColor Color4

static FromHexString(hex) Color4

Creates a new Color4 from the valid hexadecimal value contained in the passed string.

Parameters

Name Type Description
hex string

static Lerp(left, right, amount) Color4

Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4.

Parameters

Name Type Description
left Color4
right Color4
amount number

static LerpToRef(left, right, amount, result) void

Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4.

Parameters

Name Type Description
left Color4
right Color4
amount number

static FromArray(array, offset) Color4

Creates a new Color4 from the starting index element of the passed array.

Parameters

Name Type Description
array ArrayLike<number>
optional offset number

static FromInts(r, g, b, a) Color4

Creates a new Color4 from the passed integers ( < 256 ).

Parameters

Name Type Description
r number
g number
b number

static CheckColors4(colors, count) number[]

Parameters

Name Type Description
colors number[]
count number