Color4

A Color4 instance is represented by RGBA components.

Constructor

new Color4(ropt, gopt, bopt, aopt)

Constructs a new four-component color.

Parameters:
NameTypeAttributesDefaultDescription
rnumber<optional>
0

The red value.

gnumber<optional>
0

The green value.

bnumber<optional>
0

The blue value.

anumber<optional>
1

The alpha value.

Members

a :number

The alpha component.

Type:
  • number
Default Value
  • 1

b :number

The blue component.

Type:
  • number
Default Value
  • 0

g :number

The green component.

Type:
  • number
Default Value
  • 0

r :number

The red component.

Type:
  • number
Default Value
  • 0

Methods

clone() → {Color4}

Returns a new color with copied values from this instance.

Returns:

A clone of this instance.

Type: 
Color4

copy(color) → {Color4}

Copies the values of the given color to this instance.

Parameters:
NameTypeDescription
colorColor4

The color to copy.

Returns:

A clone of this instance.

Type: 
Color4

fromArray(array, offsetopt, denormalizeopt) → {Color4}

Sets this color's RGBA components from the given array.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number>

An array holding the RGBA values.

offsetnumber<optional>
0

The offset into the array.

denormalizeboolean<optional>
false

If true, denormalize the values, and array should be a typed array.

Returns:

A reference to this color.

Type: 
Color4

setRGBA(r, g, b, a) → {Color4}

Sets this color from RGBA values.

Parameters:
NameTypeDescription
rnumber

Red channel value between 0.0 and 1.0.

gnumber

Green channel value between 0.0 and 1.0.

bnumber

Blue channel value between 0.0 and 1.0.

anumber

Alpha channel value between 0.0 and 1.0.

Returns:

A reference to this color.

Type: 
Color4

toArray(arrayopt, offsetopt, normalizeopt) → {Array.<number>}

Writes the RGBA components of this color to the given array. If no array is provided, the method returns a new instance.

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number><optional>
[]

The target array holding the color components.

offsetnumber<optional>
0

Index of the first element in the array.

normalizeboolean<optional>
false

If true, normalize the values, and array should be a typed array.

Returns:

The color components.

Type: 
Array.<number>