Color

Color

A color manipulation class.

Constructor

new Color(ropt, gopt, bopt, alphaopt)

Source:
Parameters:
Name Type Attributes Default Description
r number <optional>
0 red component [0 .. 255]
g number <optional>
0 green component [0 .. 255]
b number <optional>
0 blue component [0 .. 255]
alpha number <optional>
1.0 alpha value [0.0 .. 1.0]

Classes

Color

Methods

add(color) → {Color}

Description:
  • Blend this color with the given one using addition.
Source:
Deprecated:
  • Yes
Parameters:
Name Type Description
color Color
Returns:
Reference to this object for method chaining
Type
Color

clone() → {Color}

Source:
Returns:
Reference to the newly cloned object
Type
Color

copy(color) → {Color}

Source:
Parameters:
Name Type Description
color Color
Returns:
Reference to this object for method chaining
Type
Color

darken(scale) → {Color}

Description:
  • Darken this color value by 0..1
Source:
Deprecated:
  • Yes
Parameters:
Name Type Description
scale number
Returns:
Reference to this object for method chaining
Type
Color

lerp(color, alpha) → {Color}

Description:
  • Linearly interpolate between this color and the given one.
Source:
Deprecated:
  • Yes
Parameters:
Name Type Description
color Color
alpha number with alpha = 0 being this color, and alpha = 1 being the given one.
Returns:
Reference to this object for method chaining
Type
Color

lighten(scale) → {Color}

Description:
  • Lighten this color value by 0..1
Source:
Deprecated:
  • Yes
Parameters:
Name Type Description
scale number
Returns:
Reference to this object for method chaining
Type
Color

random(minopt, maxopt) → {Color}

Description:
  • Generate random r,g,b values for this color object
Source:
Deprecated:
  • Yes
Parameters:
Name Type Attributes Default Description
min number <optional>
0 minimum value for the random range
max number <optional>
255 maxmium value for the random range
Returns:
Reference to this object for method chaining
Type
Color

set(r, g, b, alphaopt) → {Color}

Source:
Parameters:
Name Type Attributes Default Description
r number red component [0 .. 255]
g number green component [0 .. 255]
b number blue component [0 .. 255]
alpha number <optional>
1.0 alpha value [0.0 .. 1.0]
Returns:
Reference to this object for method chaining
Type
Color

toArray(array)

Source:
Parameters:
Name Type Description
array Array.<number>

(static) add(color1, color2)

Source:
Parameters:
Name Type Description
color1 Color
color2 Color

(static) copy(color)

Source:
Parameters:
Name Type Description
color Color

(static) darken(color, scale)

Source:
Parameters:
Name Type Description
color Color
scale number

(static) lerp(color1, color2, t)

Source:
Parameters:
Name Type Description
color1 Color
color2 Color
t number

(static) lighten(color, scale)

Source:
Parameters:
Name Type Description
color Color
scale number

(static) set(color, r, g, b)

Source:
Parameters:
Name Type Description
color Color
r number
g number
b number

(static) sub(color1, color2)

Source:
Parameters:
Name Type Description
color1 Color
color2 Color