Constructor
new Color4(ropt, gopt, bopt, aopt)
Constructs a new four-component color.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
r | number | <optional> | 0 | The red value. |
g | number | <optional> | 0 | The green value. |
b | number | <optional> | 0 | The blue value. |
a | number | <optional> | 1 | The alpha value. |
Members
a :number
The alpha component.
- number
- Default Value
- 1
b :number
The blue component.
- number
- Default Value
- 0
g :number
The green component.
- number
- Default Value
- 0
r :number
The red component.
- number
- Default Value
- 0
Methods
clone() → {Color4}
Returns a new color with copied values from this instance.
A clone of this instance.
- Type:
- Color4
copy(color) → {Color4}
Copies the values of the given color to this instance.
Name | Type | Description |
---|---|---|
color | Color4 | The color to copy. |
A clone of this instance.
- Type:
- Color4
fromArray(array, offsetopt, denormalizeopt) → {Color4}
Sets this color's RGBA components from the given array.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<number> | An array holding the RGBA values. | ||
offset | number | <optional> | 0 | The offset into the array. |
denormalize | boolean | <optional> | false | If true, denormalize the values, and array should be a typed array. |
A reference to this color.
- Type:
- Color4
setRGBA(r, g, b, a) → {Color4}
Sets this color from RGBA values.
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. |
a | number | Alpha channel value between 0.0 and 1.0. |
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.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array | Array.<number> | <optional> | [] | The target array holding the color components. |
offset | number | <optional> | 0 | Index of the first element in the array. |
normalize | boolean | <optional> | false | If true, normalize the values, and array should be a typed array. |
The color components.
- Type:
- Array.<number>