Color.from()static method
Make a Color from an unknown value, or undefined if it can't be parsed.
static from(possible: unknown): Color | undefined
new Color(r = 255, g = 255, b = 255, a = 255)
| Param | Type | |
|---|---|---|
r | unknown | Red channel, bounded to 0–255 (defaults to 255). Defaults to 255 |
g | unknown | Green channel, bounded to 0–255 (defaults to 255). Defaults to 255 |
b | unknown | Blue channel, bounded to 0–255 (defaults to 255). Defaults to 255 |
a | unknown | Alpha channel, bounded to 0–255 (defaults to 255). Defaults to 255 |
| Return | |
|---|---|
Color | Represents an RGBA color with red, green, blue, and alpha channels (each 0–255). |
| Property | Type | |
|---|---|---|
.r | number | Red channel, bounded to 0–255. required readonly |
.g | number | Green channel, bounded to 0–255. required readonly |
.b | number | Blue channel, bounded to 0–255. required readonly |
.a | number | Alpha channel, bounded to 0–255. required readonly |
.hex | string | This color as a six or eight digit hex string (eight digits when the alpha channel is less than 255). required readonly |
.rgb | string | This color as a CSS rgb() string. required readonly |
.rgba | string | This color as a CSS rgba() string. required readonly |
.luminance | number | The sRGB luminance of this color ( 0–255). required readonly |
.isLight | boolean | Whether this color is light (its luminance is above the dark/light threshold). required readonly |
.isDark | boolean | Whether this color is dark (its luminance is at or below the dark/light threshold). required readonly |
Represents an RGBA color with red, green, blue, and alpha channels (each 0–255).
new Color(255, 0, 0).hex // "#FF0000"
Make a Color from an unknown value, or undefined if it can't be parsed.
static from(possible: unknown): Color | undefined
Return this color as an rgba() string.
toString(): void