new Color(r [, g] [, b] [, a])
Creates a new Color instance.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
r |
number | string | Red component [0.0, 1.0] or color string ('#RGB', '#RGBA', '#RRGGBB', '#RRGGBBAA', 'rgb()', 'rgba()') |
|
g |
number |
<optional> |
Green component [0.0, 1.0] |
b |
number |
<optional> |
Blue component [0.0, 1.0] |
a |
number |
<optional> |
Alpha component [0.0, 1.0] |
- Source:
Throws:
-
If string value is not a valid color format
- Type
- Error
Methods
-
toHex()
-
Converts color to hexadecimal string.
- Source:
Returns:
Color in '#RRGGBB' format
- Type
- string
-
toHexa()
-
Converts color to hexadecimal string with alpha.
- Source:
Returns:
Color in '#RRGGBBAA' format
- Type
- string
-
toRGB()
-
Converts color to RGB values [0, 255].
- Source:
Returns:
Array of [r, g, b] values
- Type
- Array.<number>
-
toRGBA()
-
Converts color to RGBA values [0-255].
- Source:
Returns:
Array of [r, g, b, a] values
- Type
- Array.<number>
-
value()
-
Gets color components as an array.
- Source:
Returns:
Array of [r, g, b, a] values
- Type
- Array.<number>