V8 Javascript API

RS.Math.Color Class Reference

[Math]

Description

A Color.

Constructor

 Color( Object color)
More...

Functions

Color add( Color rhs)
Adds rhs to this color and stores the result in this color. More...
 cie_intensity()
Returns the intensity of the RGB components, weighted according to the CIE standard.
RS.​Math.​Color clone()
returns a copy of this color. More...
Boolean equal( Color rhs, Boolean use_tolerance)
Returns true if this vector equals rhs. More...
Boolean equal_with_tolerance( Color rhs, Number tolerance)
Returns true if this vector equals rhs using tolerance. More...
 gamma_correct( undefined gamma_factor)
Returns a gamma corrected color. Does not affect this colour.
Boolean is_black( Number tolerance)
Checks if the color is black. More...
 linear_intensity()
Returns the intensity of the RGB components, equally weighted.
 ntsc_intensity()
Returns the intensity of the RGB components, weighted according to the NTSC standard.
Color scale( Number scale)
Scales this color. More...
 set( Object rhs)
Sets this vector from an object. More...
Color subtract( Color rhs)
Subtracts rhs from this color and stores the result in this color. More...
Color tint( Color rhs)
Tints this color by rhs. More...
String toString()
Returns a string describing this Object. More...

Constructor

RS.​Math.​Color( Object color)

Parameters

color
Initial value. May be one of the following:
  • Spectrum
  • Object
  • Array
  • Color

Functions

Color RS.​Math.​Color.add( Color rhs)

Adds rhs to this color and stores the result in this color.

Parameters

rhs
the color to add.

Returns

this

RS.​Math.​Color.cie_intensity()

Returns the intensity of the RGB components, weighted according to the CIE standard.

RS.​Math.​Color RS.​Math.​Color.clone()

returns a copy of this color.

Boolean RS.​Math.​Color.equal( Color rhs, Boolean use_tolerance)

Returns true if this vector equals rhs.

Parameters

rhs
The vector to compare with.
use_tolerance
if supplied and true then use tolerance
Boolean RS.​Math.​Color.equal_with_tolerance( Color rhs, Number tolerance)

Returns true if this vector equals rhs using tolerance.

Parameters

rhs
The vector to compare with.
tolerance
The tolerance to use or RS.Math.ALMOST_ZERO if not supplied.
RS.​Math.​Color.gamma_correct( undefined gamma_factor)

Returns a gamma corrected color. Does not affect this colour.

Boolean RS.​Math.​Color.is_black( Number tolerance)

Checks if the color is black.

Parameters

tolerance
Optional. A Number used to approximate the comparison.
RS.​Math.​Color.linear_intensity()

Returns the intensity of the RGB components, equally weighted.

RS.​Math.​Color.ntsc_intensity()

Returns the intensity of the RGB components, weighted according to the NTSC standard.

Color RS.​Math.​Color.scale( Number scale)

Scales this color.

Parameters

scale
Scale the scalar to apply.

Returns

this

RS.​Math.​Color.set( Object rhs)

Sets this vector from an object. The object may be of the following types: Color, and Array with 3 or more members or an Object. In the case of an object it must have the members x, y, z, and optionally w. If w is omitted then w will be set to 1.

Parameters

rhs
The object to set from. May be one of the following:
  • Spectrum
  • Object
  • Array
  • Color
Color RS.​Math.​Color.subtract( Color rhs)

Subtracts rhs from this color and stores the result in this color.

Parameters

rhs
the color to subtract.

Returns

this

Color RS.​Math.​Color.tint( Color rhs)

Tints this color by rhs.

Parameters

rhs
the color to subtract.

Returns

this

String RS.​Math.​Color.toString()

Returns a string describing this Object.

Returns

A String describing this Object.