new Color(r [, g] [, b] [, a])
Creates a new instance of Color.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
r |
number | string | Core.Annotations.Color | Array.<number> | Can be: a Color object to copy, a hex color string (e.g., '#FFFFFF'), an array representing grayscale [g], RGB [r,g,b], or CMYK [c,m,y,k] values (0-1.0 range), or the red value (0-255) when used with g, b, a parameters | |
g |
number | string |
<optional> |
The green value (0-255) |
b |
number | string |
<optional> |
The blue value (0-255) |
a |
number | string |
<optional> |
The alpha value (0-1.0) |
Properties:
| Name | Type | Description |
|---|---|---|
R |
number | The R (red) value (0-255) |
G |
number | The G (green) value (0-255) |
B |
number | The B (blue) value (0-255) |
A |
number | The A (alpha) value (0-1.0) |
Methods
-
toHexString()
-
Returns the color as a hex string
Returns:
The hex color string (e.g., "#FFFFFF")- Type
- string
Example
const color = new Core.Annotations.Color(255, 255, 255); color.toHexString(); // Returns "#FFFFFF"
-
toString()
-
Outputs the current color as a CSS3 RGB color string
Returns:
The CSS3 RGB color string- Type
- string
Example
const color = new Core.Annotations.Color(255, 0, 0, 0.5); color.toString(); // Returns "rgba(255,0,0,0.5)"