Color3

A Color3 instance is represented by RGB components.

Constructor

new Color3(ropt, gopt, bopt)

Constructs a new three-component color.

Parameters:
NameTypeAttributesDescription
rnumber<optional>

The red component of the color. If g and b are not provided, it can be a hexadecimal triplet.

gnumber<optional>

The green component.

bnumber<optional>

The blue component.

Members

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() → {Color3}

Returns a new color with copied values from this instance.

Returns:

A clone of this instance.

Type: 
Color3

convertLinearToSRGB() → {Color3}

Converts this color from linear space to sRGB space.

Returns:

A reference to this color.

Type: 
Color3

convertSRGBToLinear() → {Color3}

Converts this color from sRGB space to linear space.

Returns:

A reference to this color.

Type: 
Color3

copy(color) → {Color3}

Copies the values of the given color to this instance.

Parameters:
NameTypeDescription
colorColor3

The color to copy.

Returns:

A reference to this color.

Type: 
Color3

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

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

Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<number>

An array holding the RGB 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: 
Color3

getHex() → {number}

Returns the hexadecimal value of this color.

Returns:

The hexadecimal value.

Type: 
number

lerp(color, alpha) → {Color3}

Linearly interpolates this color's RGB values toward the RGB values of the given color. The alpha argument can be thought of as the ratio between the two colors, where 0.0 is this color and 1.0 is the first argument.

Parameters:
NameTypeDescription
colorColor3

The color to converge on.

alphanumber

The interpolation factor in the closed interval [0,1].

Returns:

A reference to this color.

Type: 
Color3

lerpColors(color1, color2, alpha) → {Color3}

Linearly interpolates between the given colors and stores the result in this instance. The alpha argument can be thought of as the ratio between the two colors, where 0.0 is the first and 1.0 is the second color.

Parameters:
NameTypeDescription
color1Color3

The first color.

color2Color3

The second color.

alphanumber

The interpolation factor in the closed interval [0,1].

Returns:

A reference to this color.

Type: 
Color3

setHSL(h, s, l) → {Color3}

Set this color from HSL values.

Parameters:
NameTypeDescription
hnumber

Hue value between 0.0 and 1.0.

snumber

Saturation value between 0.0 and 1.0.

lnumber

Lightness value between 0.0 and 1.0.

Returns:

A reference to this color.

Type: 
Color3

setHex(hex) → {Color3}

Sets this color from a hexadecimal value.

Parameters:
NameTypeDescription
hexnumber

The hexadecimal value.

Returns:

A reference to this color.

Type: 
Color3

setRGB(r, g, b) → {Color3}

Sets this color from RGB 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.

Returns:

A reference to this color.

Type: 
Color3

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

Writes the RGB 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>