B.Math.Color()

Represents a RGBA color.

To create the object use B.Math.makeColor().

CONSTANTS:

{B.Math.Color} WHITE = {r: 1.0, g: 1.0, b: 1.0, a: 1.0}

White color.

{B.Math.Color} GRAY = {r: 0.5, g: 0.5, b: 0.5, a: 1.0}

Gray color.

{B.Math.Color} BLACK = {r: 0.0, g: 0.0, b: 0.0, a: 1.0}

Black color.

{B.Math.Color} RED = {r: 1.0, g: 0.0, b: 0.0, a: 1.0}

Red color.

{B.Math.Color} GREEN = {r: 0.0, g: 1.0, b: 0.0, a: 1.0}

Green color.

{B.Math.Color} BLUE = {r: 0.0, g: 0.0, b: 1.0, a: 1.0}

Blue color.

PROPERTIES:

{number} r

Red component.

{number} g

Green component.

{number} b

Blue component.

{number} a

Alpha component.

METHODS:

copy(color)

Copies a given color into this color.

PARAMETERS:

{B.Math.Color} color

RETURNS:

{B.Math.Color}

this

clone()

Clones this color to a new color.

RETURNS:

{B.Math.Color}

this

set(r, g, b, a)

Sets this color from separated components.

PARAMETERS:

{number} r

{number} g

{number} b

{number} a

RETURNS:

{B.Math.Color}

this

get(index)

Gets an element by its index.

PARAMETERS:

{number} index

RETURNS:

{number}

THROWS:

{Error}

if the index is out of range

setHex(hex)

Sets RGB-components of this color from a hexadecimal value.

PARAMETERS:

{number} hex

RETURNS:

{B.Math.Color}

this

getHex()

Returns the hexadecimal value of this color (RGB-components).

RETURNS:

{number}

fromArray(array, offset)

Sets this color from a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

toArray(array, offset)

Sets this color components to a part of array.

PARAMETERS:

{Array.<number>} array

{number} [offset] = 0

RETURNS:

{number}

new offset

clamp()

Clamps components of this color to the range [0.0, 1.0].

RETURNS:

{B.Math.Color}

this

add(v)

Adds a color or a scalar to this color.

PARAMETERS:

{number | B.Math.Color} v

RETURNS:

{B.Math.Color}

this

addColors(a, b)

Adds two given colors and sets the result to this.

PARAMETERS:

RETURNS:

{B.Math.Color}

this

sub(v)

Subtracts a color or a scalar from this color.

PARAMETERS:

{number | B.Math.Color} v

RETURNS:

{B.Math.Color}

this

subColors(a, b)

Subtracts two given colors and sets the result to this.

PARAMETERS:

RETURNS:

{B.Math.Color}

this

mul(v)

Multiplies this color by a given color or a scalar.

PARAMETERS:

{number | B.Math.Color} v

RETURNS:

{B.Math.Color}

this

mulColors(a, b)

Multiplies two given colors and sets the result to this.

PARAMETERS:

RETURNS:

{B.Math.Color}

this

equal(v)

Checks for strict equality of this color and another color.

PARAMETERS:

RETURNS:

{boolean}

CONSTANTS:

PROPERTIES:

METHODS: