me.Color(ropt, gopt, bopt, alphaopt)

new Color(ropt, gopt, bopt, alphaopt)

A color manipulation object.

Parameters:
Name Type Attributes Default Description
r Float32Array | Number <optional>
0

red component or array of color components

g Number <optional>
0

green component

b Number <optional>
0

blue component

alpha Number <optional>
1.0

alpha value

Extends

Members

static, readonly alpha :Number

Color Alpha Component

static, readonly b :Number

Color Blue Component

static, readonly g :Number

Color Green Component

static, readonly glArray :Float32Array

Color components in a Float32Array suitable for WebGL

static, readonly r :Number

Color Red Component

Methods

static add(color) → {me.Color}

Blend this color with the given one using addition.

Parameters:
Name Type Description
color me.Color
Returns:
me.Color -

Reference to this object for method chaining

static clone() → {me.Color}

Create a new copy of this color object.

Returns:
me.Color -

Reference to the newly cloned object

static copy(color) → {me.Color}

Copy a color object or CSS color into this one.

Parameters:
Name Type Description
color me.Color | String
Returns:
me.Color -

Reference to this object for method chaining

static darken(scale) → {me.Color}

Darken this color value by 0..1

Parameters:
Name Type Description
scale Number
Returns:
me.Color -

Reference to this object for method chaining

static equals(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 me.Color
Returns:
Boolean

static lighten(scale) → {me.Color}

Lighten this color value by 0..1

Parameters:
Name Type Description
scale Number
Returns:
me.Color -

Reference to this object for method chaining

static parseCSS(color) → {me.Color}

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

Parameters:
Name Type Description
color String
Returns:
me.Color -

Reference to this object for method chaining

static parseHex(color) → {me.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 Description
color String
Returns:
me.Color -

Reference to this object for method chaining

static parseRGB(color) → {me.Color}

Parse an RGB or RGBA CSS color string

Parameters:
Name Type Description
color String
Returns:
me.Color -

Reference to this object for method chaining

static random() → {me.Color}

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

Returns:
me.Color -

Reference to this object for method chaining

static setColor(r, g, b, alphaopt) → {me.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:
me.Color -

Reference to this object for method chaining

static toHex() → {String}

Get the color in "#RRGGBB" format

Returns:
String

static toHex8() → {String}

Get the color in "#RRGGBBAA" format

Returns:
String

static toRGB() → {String}

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

Returns:
String

static toRGBA() → {String}

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

Returns:
String