ComponentOne ASP.NET MVC Controls
Color Class
File
wijmo.js
Module
wijmo

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 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 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}

Constructor

Properties

Methods

Constructor

constructor

constructor(color: string): Color

Initializes a new Color from a CSS color specification.

Parameters
Returns
Color

Properties

a

Gets or sets the alpha component of this Color, in a range from 0 to 1 (zero is transparent, one is solid).

Type
number

b

Gets or sets the blue component of this Color, in a range from 0 to 255.

Type
number

g

Gets or sets the green component of this Color, in a range from 0 to 255.

Type
number

r

Gets or sets the red component of this Color, in a range from 0 to 255.

Type
number

Methods

equals

equals(clr: Color): boolean

Returns true if a Color has the same value as this Color.

Parameters
Returns
boolean

 

Static fromHsb
fromHsb(h: number, s: number, b: number, a?: number): Color

Creates a new Color using the specified HSB values.

Parameters
Optional

Alpha value, from 0 to 1.

Returns
Color

 

Static fromHsl
fromHsl(h: number, s: number, l: number, a?: number): Color

Creates a new Color using the specified HSL values.

Parameters
Returns
Color

Static fromRgba

fromRgba(r: number, g: number, b: number, a?: number): Color

Creates a new Color using the specified RGBA color channel values.

Parameters
Returns
Color

Static fromString

fromString(value: string): Color

Creates a new Color from a CSS color string.

Parameters
Returns
Color

getHsb

getHsb(): number[]

Gets an array with this color's HSB components.

Returns
number[]

getHsl

getHsl(): number[]

Gets an array with this color's HSL components.

Returns
number[]

Static interpolate

interpolate(c1: Color, c2: Color, pct: number): Color

Creates a Color by interpolating between two colors.

Parameters
Returns
Color

Static toOpaque

toOpaque(c: any, bkg?: any): Color

Gets the closest opaque color to a given color.

Parameters
Returns
Color

toString

toString(): string

Gets a string representation of this Color.

Returns
string