TIScript – Date object

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 sting using CSS syntax rules.

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.
opacity
read-only, float 0.0 .. 1.0, that is alpha value expressed as a float.

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

tint

( luminance: float [, saturation: float[, hue: float | angle]] ) : color

Returns color – tint of the color this method is applied to. luminance and saturation are float numbers in the range -1.0 … +1.0. hue is either angle or float (degrees 0 .. 360)

parse

( text: string )

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

  • "#RGB"
  • "#RRGGBB"
  • "rgb(r,g,b)"
  • "rgba(r,g,b,a)"
  • literal color names like: "yellow", "gold", "red", etc.
toString

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

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

  • #RGB – outputs color as "#RRGGBB";
  • #rgb – outputs color as "rgb(r,g,b)" string;
  • #rgba – as "rgba(r,g,b,a)" string.
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.