Constructor
new Color(red, green, blue, alpha)
Create a new color.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
red | number | 0 | Red value (0-255) |
green | number | 0 | Green value (0-255) |
blue | number | 0 | Blue value (0-255) |
alpha | number | 1 | (Optional) Alpha value (0-1) |
- Source
Methods
copy() → {Color}
Get an exact copy of the color.
- Source
Returns:
Cloned color
- Type:
- Color
darken(percent)
Darken this color by a specified percentage.
Parameters:
Name | Type | Description |
---|---|---|
percent | number | Percentage to darken by |
- Source
get(alpha) → {string}
Get the color in the form of a string. Useful for CSS styling and drawing colors on canvas.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
alpha | boolean | true | Whether to include alpha (true by default) |
- Source
Returns:
Resulting color string
- Type:
- string
getDarkened(percent) → {Color}
Get a darkened version of the color.
Parameters:
Name | Type | Description |
---|---|---|
percent | number | Percentage to darken by |
- Source
Returns:
Resulting color
- Type:
- Color
getLightened(percent) → {Color}
Get a lightened version of the color.
Parameters:
Name | Type | Description |
---|---|---|
percent | number | Percentage to lighten by |
- Source
Returns:
Resulting color
- Type:
- Color
invert()
Invert the color.
- Source
lerp(other, point) → {Color}
Linear interpolate with another color.
Parameters:
Name | Type | Description |
---|---|---|
other | Color | Other color to interpolate with |
point | number | Point (alpha) on the gradient |
- Source
Returns:
Resulting interpolated color
- Type:
- Color
lighten(percent)
Lighten this color by a specified percentage.
Parameters:
Name | Type | Description |
---|---|---|
percent | number | Percentage to lighten by |
- Source
set(red, green, blue, alpha)
Set (replace) the values of the color.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
red | number | Red value (0-255) | |
green | number | Green value (0-255) | |
blue | number | Blue value (0-255) | |
alpha | number | 1 | (Optional) Alpha value (0-1) |
- Source