Color

class Color

A color manipulation object.

Constructor


new Color(r: number, g: number, b: number, alpha: number) → {}
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]

Public Properties


alpha color.js:247
alpha: number

number

Color Alpha Component [0.0 .. 1.0]

b color.js:236
b: number

number

Color Blue Component [0 .. 255]

g color.js:223
g: number

number

Color Green Component [0 .. 255]

r color.js:210
r: number

number

Color Red Component [0 .. 255]

Public Methods


add color.js:365
add(color: Color) → {Color}

Blend this color with the given one using addition.

Parameters:
Name Type Description
color Color
Returns:
Type Description
Color

Reference to this object for method chaining

clone color.js:343
clone() → {Color}

Create a new copy of this color object.

Returns:
Type Description
Color

Reference to the newly cloned object

copy color.js:351
copy(color: Color | string) → {Color}

Copy a color object or CSS color into this one.

Parameters:
Name Type Description
color Color | string
Returns:
Type Description
Color

Reference to this object for method chaining

darken color.js:379
darken(scale: number) → {Color}

Darken this color value by 0..1

Parameters:
Name Type Description
scale number
Returns:
Type Description
Color

Reference to this object for method chaining

equals color.js:444
equals(color: Color) → {boolean}

Return true if the r,g,b,a values of this color are equal with the given one.

Parameters:
Name Type Description
color Color
Returns:
Type Description
boolean
lerp color.js:393
lerp(color: Color, alpha: number) → {Color}

Linearly interpolate between this color and the given one.

Parameters:
Name Type Description
color Color
alpha number

with alpha = 0 being this color, and alpha = 1 being the given one.

Returns:
Type Description
Color

Reference to this object for method chaining

lighten color.js:408
lighten(scale: number) → {Color}

Lighten this color value by 0..1

Parameters:
Name Type Description
scale number
Returns:
Type Description
Color

Reference to this object for method chaining

parseCSS color.js:459
parseCSS(cssColor: string) → {Color}

Parse a CSS color string and set this color to the corresponding r,g,b values

Parameters:
Name Type Description
cssColor string
Returns:
Type Description
Color

Reference to this object for method chaining

parseHex color.js:491
parseHex(hexColor: string, argb : boolean) → {Color}

Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to the corresponding r,g,b,a values

Parameters:
Name Type Attributes Default Description
hexColor string
argb boolean

<optional>

false

true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)

Returns:
Type Description
Color

Reference to this object for method chaining

parseRGB color.js:475
parseRGB(rgbColor: string) → {Color}

Parse an RGB or RGBA CSS color string

Parameters:
Name Type Description
rgbColor string
Returns:
Type Description
Color

Reference to this object for method chaining

random color.js:422
random(min: number, max: number) → {Color}

Generate random r,g,b values for this color object

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:
Type Description
Color

Reference to this object for method chaining

setColor color.js:259
setColor(r: number, g: number, b: number, alpha: number) → {Color}

Set this color to the specified value.

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:
Type Description
Color

Reference to this object for method chaining

setFloat color.js:275
setFloat(r: number, g: number, b: number, alpha: number) → {Color}

set this color to the specified normalized float values

Parameters:
Name Type Attributes Default Description
r number

red component [0.0 .. 1.0]

g number

green component [0.0 .. 1.0]

b number

blue component [0.0 .. 1.0]

alpha number

<optional>

1.0

alpha value [0.0 .. 1.0]

Returns:
Type Description
Color

Reference to this object for method chaining

setHSL color.js:319
setHSL(h: number, s: number, l: number) → {Color}

set this color to the specified HSL value

Parameters:
Name Type Description
h number

hue (a value from 0 to 1)

s number

saturation (a value from 0 to 1)

l number

lightness (a value from 0 to 1)

Returns:
Type Description
Color

Reference to this object for method chaining

setHSV color.js:292
setHSV(h: number, s: number, v: number) → {Color}

set this color to the specified HSV value

Parameters:
Name Type Description
h number

hue (a value from 0 to 1)

s number

saturation (a value from 0 to 1)

v number

value (a value from 0 to 1)

Returns:
Type Description
Color

Reference to this object for method chaining

toArray color.js:564
toArray() → {Float32Array}

return an Float Array representation of this object

Returns:
Type Description
Float32Array
toHex color.js:573
toHex() → {string}

return the color in "#RRGGBB" format

Returns:
Type Description
string
toHex8 color.js:584
toHex8(alpha) → {string}

Get the color in "#RRGGBBAA" format

Parameters:
Name Type Description
alpha
Returns:
Type Description
string
toRGB color.js:595
toRGB() → {string}

Get the color in "rgb(R,G,B)" format

Returns:
Type Description
string
toRGBA color.js:610
toRGBA(alpha: number) → {string}

Get the color in "rgba(R,G,B,A)" format

Parameters:
Name Type Attributes Default Description
alpha number

<optional>

1.0

alpha value [0.0 .. 1.0]

Returns:
Type Description
string
toUint32 color.js:549
toUint32(alpha: number) → {number}

Pack this color RGB components into a Uint32 ARGB representation

Parameters:
Name Type Attributes Default Description
alpha number

<optional>

1.0

alpha value [0.0 .. 1.0]

Returns:
Type Description
number

Powered by webdoc!