CLASSES
TagsA - Z

Color4

Objects

Description

class Color4

Color defined by Red Green Blue, plus the Alpha.

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
r number The red value (0<r<1)
g number The green value (0<g<1)
b number The blue value (0<b<1)

Members

r : number

The red value

g : number

The green value

b : number

The blue value

a : number

The alpha value

Methods

addInPlace(right) → Color4

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

Returns the updated Color4.

Parameters

Name Type Description
right any second color

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[] The given array
optional index number default : 0 The given index

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 second color

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 second color

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 second color
result Color4 The Color4 (RGBA) to fill the result in The Color4 (RGBA) to fill the result in The color which hold the result color

scale(scale) → Color4

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

Parameters

Name Type Description
scale number The scaling factor

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 The scaling factor
result Color4 The Color4 (RGBA) to fill the result in The Color4 (RGBA) to fill the result in The color which hold the result color

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 The Color4 (RGBA) value to multiply by 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 The Color4 (RGBA) value to multiply by The Color4 (RGBA) value to multiply by
result Color4 The Color4 (RGBA) to fill the result in The Color4 (RGBA) to fill the result in The Color4 (RGBA) to fill the result in The color which hold the result color

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 The red value (0<r<1)
g number The green value (0<g<1)
b number The blue value (0<b<1)

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 The red value (0<r<1)
g number The green value (0<g<1)
b number The blue value (0<b<1)

toHexString() → string

Returns a string containing the hexadecimal Color4 code.

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 first color
right Color4 second color
amount number Weighting factor.

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 first color
right Color4 second color
amount number Weighting factor.

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> The given array
optional offset number The first index of the array to look at

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

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

Parameters

Name Type Description
r number The red value (0<r<1)
g number The green value (0<g<1)
b number The blue value (0<b<1)

static CheckColors4(colors, count) → number[]

Parameters

Name Type Description
colors number[]
count number