Constructor
new Color3(r, g, b)
Parameters:
Name | Type | Description |
---|---|---|
r | Number | (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). |
g | Number | (optional) If it is defined, the green component of the color. |
b | Number | (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:
Name | Type | Description |
---|---|---|
v | t3d. |
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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | Array of floats in the form [ r, g, b ]. | ||
offset | Number | <optional> | 0 | An offset into the array. |
denormalize | Boolean | <optional> | false | if 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:
Name | Type | Description |
---|---|---|
c | t3d. | color to converge on. |
ratio | Number | interpolation 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:
Name | Type | Description |
---|---|---|
c1 | t3d. | the starting Color. |
c2 | t3d. | Color to interpolate towards. |
ratio | Number | interpolation factor, typically in the closed interval [0, 1]. |
setHSL(h, s, l) → {t3d.Color3}
Set from HSL.
Parameters:
Name | Type | Description |
---|---|---|
h | Number | hue value between 0.0 and 1.0 |
s | Number | saturation value between 0.0 and 1.0 |
l | Number | lightness value between 0.0 and 1.0 |
Returns:
- Type:
- t3d.
Color3
setHex(hex) → {t3d.Color3}
Set from hex.
Parameters:
Name | Type | Description |
---|---|---|
hex | Number | hexadecimal triplet format. |
Returns:
- Type:
- t3d.
Color3
setRGB(r, g, b) → {t3d.Color3}
Sets this color from RGB values.
Parameters:
Name | Type | Description |
---|---|---|
r | Number | Red channel value between 0.0 and 1.0. |
g | Number | Green channel value between 0.0 and 1.0. |
b | Number | Blue 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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<Number> | <optional> | An array to store the color to. | |
offset | Number | <optional> | 0 | An offset into the array. |
normalize | Boolean | <optional> | false | if true, normalize the values, and array should be a typed array. |
Returns:
- Type:
- Array.<Number>