Color object

Just a color.

Color values are constructed by the global function color():

color
(r: int, g: int, b: int [, opacity: int | float]) : color
(s: string ) : color

The color function constructs color value from red, green, blue and opacity components. Or by parsing the string using CSS syntax rules.

Colors can be declared by using CSS alike color constants:

where r, g, b and a are hex digits 0...f.

Or by their HTML color names:

Constants

N/A

Properties

r
read-only, integer 0..255, red channel.
g
read-only, integer 0..255, green channel.
b
read-only, integer 0..255, blue channel.
a
read-only, integer 0..255, alpha value.

Methods

rgba
(r: int, g: int, b: int [, opacity: int | float]) : color

Static method (of the class), constructs color value from red, green, blue and opacity components.

hsv
(hue: float | angle, saturation: float, value: float [, opacity: int | float]) : color

Static method (of the class), В constructs the color from HSV values, see: http://en.wikipedia.org/wiki/HSL_color_space

hsl
(hue: float | angle, saturation: float, lightness: float [, opacity: int | float]) : color

Static method (of the class), В constructs the color from HSL values, see: http://en.wikipedia.org/wiki/HSL_color_space

hue
( hue: angle ) : color

Returns new color by setting hue component of the color in HSL color space, hue is either angle or float, degrees 0 .. 360.

rotate
( hue: angle ) : color

Returns new color by incrementing/decrementing hue component of the color in HSL color space by the given angle

lightness
( lightness: 0.0...1.0 ) : color

Returns new color by setting lightness component of the color in HSL color space.

lighten
( dl: 0.0...1.0 ) : color

Returns new color by incrementing lightness component of the color in HSL color space.

darken
( dl: 0.0...1.0 ) : color

Returns new color by decrementing lightness component of the color in HSL color space.

saturation
( saturation: 0.0...1.0 ) : color

Returns new color by setting saturation component of the color in HSL color space.

saturate
( ds: 0.0...1.0 ) : color

Returns new color by incrementing saturation component of the color in HSL color space.

desaturate
( ds: 0.0...1.0 ) : color

Returns new color by decrementing saturation component of the color in HSL color space.

opacity
( opacity: 0.0...1.0 ) : color

Returns new color by changing alpha component of the color in RGBA color space.

opacify
( delta: 0.0...1.0 ) : color

Returns new color by incrementing/decrementing alpha component of the color in RGBA color space.

grayscale
( ratio: 0.0...1.0 = 1.0) : color

Returns new color by mixing the color with its pure grayscale version.

parse
( text: string )

Static method (of the class), В parses the string and constructs the color value. Supported formats:

toString

( [#RGB | #rgb | #rgba] ) : string

Returns string representation of the color value according to the format provided by the symbol defining one of formats:

toInteger

( ) : int

Converts the color to 32bit integer.

toHSV

( ) : float,float,float

Returns three values - H,S, and V color components .

toHSL

( ) : float,float,float

Returns three values - H,S, and L color components .

morph

( from : color, to:color, ratio: float ) : color

Computes the average color using the formula: (to - from) * ratio + from for each color component. Transformation is made in premultiplied color space.