Skip to content
M2O Scripting APIScripting reference
Runtime classClient APIGenerated

Color

Defined in: client/api.d.ts:2815

Mutable RGBA color, with components stored from 0 to 1.

new Color(r, g, b, a?): Color

Defined in: client/api.d.ts:2823

Creates a color from normalized RGBA components.

number

Initial red component from 0 to 1.

number

Initial green component from 0 to 1.

number

Initial blue component from 0 to 1.

number

Optional alpha component from 0 to 1; defaults to 1.

Color

clone(): Color

Defined in: client/api.d.ts:2867

Creates an independent copy of this color.

Color

New color with the same components.


lerp(target, t): this

Defined in: client/api.d.ts:2851

Linearly interpolates every component toward a target in place.

Color

Destination color.

number

Interpolation factor; 0 keeps this color and 1 reaches target.

this

This mutated color for chaining.


set(r, g, b, a?): this

Defined in: client/api.d.ts:2861

Replaces this color’s normalized components in place.

number

Replacement red component from 0 to 1.

number

Replacement green component from 0 to 1.

number

Replacement blue component from 0 to 1.

number

Optional replacement alpha; defaults to 1 when omitted.

this

This mutated color for chaining.


toHex(includeAlpha?): string

Defined in: client/api.d.ts:2874

Converts normalized components to a hexadecimal CSS-style string.

boolean

Whether to append the alpha byte; defaults to false.

string

Lowercase #rrggbb or #rrggbbaa string.


toJSON(): object

Defined in: client/api.d.ts:2886

Converts this color to a plain object for JSON.stringify.

object

Object containing the current normalized components.

a: number

b: number

g: number

r: number


toString(): string

Defined in: client/api.d.ts:2880

Formats this color for logging and debugging.

string

Text in Color(r, g, b, a) form.


static black(): Color

Defined in: client/api.d.ts:2915

Creates opaque black.

Color

New Color(0, 0, 0, 1).


static blue(): Color

Defined in: client/api.d.ts:2933

Creates opaque blue.

Color

New Color(0, 0, 1, 1).


static cyan(): Color

Defined in: client/api.d.ts:2945

Creates opaque cyan.

Color

New Color(0, 1, 1, 1).


static fromHex(hex): Color

Defined in: client/api.d.ts:2893

Parses a hexadecimal color string.

string

Hexadecimal color in #RRGGBB or #RRGGBBAA form; the leading # is optional. Three- and four-digit shorthands are not supported.

Color

Parsed color, or opaque white when the input is invalid.


static fromRGB(r, g, b, a?): Color

Defined in: client/api.d.ts:2903

Creates a normalized color from byte components.

number

Red byte from 0 to 255.

number

Green byte from 0 to 255.

number

Blue byte from 0 to 255.

number

Optional alpha byte from 0 to 255; defaults to 255.

Color

New normalized color.


static green(): Color

Defined in: client/api.d.ts:2927

Creates opaque green.

Color

New Color(0, 1, 0, 1).


static magenta(): Color

Defined in: client/api.d.ts:2951

Creates opaque magenta.

Color

New Color(1, 0, 1, 1).


static red(): Color

Defined in: client/api.d.ts:2921

Creates opaque red.

Color

New Color(1, 0, 0, 1).


static transparent(): Color

Defined in: client/api.d.ts:2957

Creates fully transparent black.

Color

New Color(0, 0, 0, 0).


static white(): Color

Defined in: client/api.d.ts:2909

Creates opaque white.

Color

New Color(1, 1, 1, 1).


static yellow(): Color

Defined in: client/api.d.ts:2939

Creates opaque yellow.

Color

New Color(1, 1, 0, 1).

a: number

Defined in: client/api.d.ts:2843

Mutable normalized alpha component.


b: number

Defined in: client/api.d.ts:2838

Mutable normalized blue component.


g: number

Defined in: client/api.d.ts:2833

Mutable normalized green component.


r: number

Defined in: client/api.d.ts:2828

Mutable normalized red component.