t3d. Color3

Color3 Class.

Constructor

new Color3(r, g, b)

Parameters:
NameTypeDescription
rNumber(optional) If arguments g and b are defined, the red component of the color. If they are not defined, it can be a hexadecimal triplet (recommended).
gNumber(optional) If it is defined, the green component of the color.
bNumber(optional) If it is defined, the blue component of the color.

Methods

clone() → {t3d.Color3}

Returns a new Color with the same r, g and b values as this one.
Returns:
Type: 
t3d.Color3

convertLinearToSRGB() → {t3d.Color3}

Converts this color from linear space to sRGB space.
Returns:
Type: 
t3d.Color3

convertSRGBToLinear() → {t3d.Color3}

Converts this color from sRGB space to linear space.
Returns:
Type: 
t3d.Color3

copy(v) → {t3d.Color3}

Copies the r, g and b parameters from v in to this color.
Parameters:
NameTypeDescription
vt3d.Color3
Returns:
Type: 
t3d.Color3

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

Sets this color's components based on an array formatted like [ r, g, b ].
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number>Array of floats in the form [ r, g, b ].
offsetNumber<optional>
0An offset into the array.
denormalizeBoolean<optional>
falseif true, denormalize the values, and array should be a typed array.
Returns:
Type: 
t3d.Color3

getHex() → {Number}

Returns the hexadecimal value of this color.
Returns:
Type: 
Number

lerp(c, ratio)

Linearly interpolates this color's RGB values toward the RGB values of the passed argument. The ratio 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
ct3d.Color3color to converge on.
ratioNumberinterpolation factor in the closed interval [0, 1].

lerpColors(c1, c2, ratio)

Sets this color to be the color linearly interpolated between color1 and color2 where ratio is the percent distance along the line connecting the two colors - ratio = 0 will be color1, and ratio = 1 will be color2.
Parameters:
NameTypeDescription
c1t3d.Color3the starting Color.
c2t3d.Color3Color to interpolate towards.
ratioNumberinterpolation factor, typically in the closed interval [0, 1].

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

Set from HSL.
Parameters:
NameTypeDescription
hNumberhue value between 0.0 and 1.0
sNumbersaturation value between 0.0 and 1.0
lNumberlightness value between 0.0 and 1.0
Returns:
Type: 
t3d.Color3

setHex(hex) → {t3d.Color3}

Set from hex.
Parameters:
NameTypeDescription
hexNumberhexadecimal triplet format.
Returns:
Type: 
t3d.Color3

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

Sets this color from RGB values.
Parameters:
NameTypeDescription
rNumberRed channel value between 0.0 and 1.0.
gNumberGreen channel value between 0.0 and 1.0.
bNumberBlue channel value between 0.0 and 1.0.
Returns:
Type: 
t3d.Color3

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

Returns an array of the form [ r, g, b ].
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number><optional>
An array to store the color to.
offsetNumber<optional>
0An offset into the array.
normalizeBoolean<optional>
falseif true, normalize the values, and array should be a typed array.
Returns:
Type: 
Array.<Number>