Colorclass

new Color(r = 255, g = 255, b = 255, a = 255)
ParamType
runknown
Red channel, bounded to 0255 (defaults to 255). Defaults to 255
gunknown
Green channel, bounded to 0255 (defaults to 255). Defaults to 255
bunknown
Blue channel, bounded to 0255 (defaults to 255). Defaults to 255
aunknown
Alpha channel, bounded to 0255 (defaults to 255). Defaults to 255
Return
Color
Represents an RGBA color with red, green, blue, and alpha channels (each 0–255).
PropertyType
.rnumber
Red channel, bounded to 0255. required readonly
.gnumber
Green channel, bounded to 0255. required readonly
.bnumber
Blue channel, bounded to 0255. required readonly
.anumber
Alpha channel, bounded to 0255. required readonly
.hexstring
This color as a six or eight digit hex string (eight digits when the alpha channel is less than 255). required readonly
.rgbstring
This color as a CSS rgb() string. required readonly
.rgbastring
This color as a CSS rgba() string. required readonly
.luminancenumber
The sRGB luminance of this color (0255). required readonly
.isLightboolean
Whether this color is light (its luminance is above the dark/light threshold). required readonly
.isDarkboolean
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 0255).

Examples

new Color(255, 0, 0).hex // "#FF0000"

Static methods

Go

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

Methods

Go

Color.toString()method

Return this color as an rgba() string.

toString(): void