constructor(color: string): Color
Initializes a new Color from a CSS color specification.
CSS color specification.
fromHsb(h: number, s: number, b: number, a?: number): Color
Creates a new Color using the specified HSB values.
Hue value, from 0 to 1.
Saturation value, from 0 to 1.
Brightness value, from 0 to 1.
Alpha value, from 0 to 1.
fromHsl(h: number, s: number, l: number, a?: number): Color
Creates a new Color using the specified HSL values.
Hue value, from 0 to 1.
Saturation value, from 0 to 1.
Lightness value, from 0 to 1.
Alpha value, from 0 to 1.
fromRgba(r: number, g: number, b: number, a?: number): Color
Creates a new Color using the specified RGBA color channel values.
Value for the red channel, from 0 to 255.
Value for the green channel, from 0 to 255.
Value for the blue channel, from 0 to 255.
Value for the alpha channel, from 0 to 1.
fromString(value: string): Color
Creates a new Color from a CSS color string.
String containing a CSS color specification.
interpolate(c1: Color, c2: Color, pct: number): Color
Creates a Color by interpolating between two colors.
First color.
Second color.
Value between zero and one that determines how close the interpolation should be to the second color.
toOpaque(c: any, bkg?: any): Color
Gets the closest opaque color to a given color.
Color to be converted to an opaque color (the color may also be specified as a string).
Background color to use when removing the transparency (defaults to white).
Represents a color.
The Color class parses colors specified as CSS strings and exposes their red, green, blue, and alpha channels as read-write properties.
The Color class also provides fromHsb and fromHsl methods for creating colors using the HSB and HSL color models instead of RGB, as well as getHsb and getHsl methods for retrieving the color components using those color models.
Finally, the Color class provides an interpolate method that creates colors by interpolating between two colors using the HSL model. This method is especially useful for creating color animations with the animate method.
The example below shows how this works:
{@sample Core/Color Example}