Skip to content
M2O Scripting APIScripting reference
Runtime classClient APIGenerated

Color

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

Mutable RGBA color exposed as Core.Color, with components stored from 0 to 1.

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

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

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:1935

Creates an independent copy of this color.

Color

New color with the same components.


lerp(target, t): this

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

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:1929

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:1942

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:1954

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:1948

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:1983

Creates opaque black.

Color

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


static blue(): Color

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

Creates opaque blue.

Color

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


static cyan(): Color

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

Creates opaque cyan.

Color

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


static fromHex(hex): Color

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

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:1971

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:1995

Creates opaque green.

Color

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


static magenta(): Color

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

Creates opaque magenta.

Color

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


static red(): Color

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

Creates opaque red.

Color

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


static transparent(): Color

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

Creates fully transparent black.

Color

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


static white(): Color

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

Creates opaque white.

Color

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


static yellow(): Color

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

Creates opaque yellow.

Color

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

a: number

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

Mutable normalized alpha component.


b: number

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

Mutable normalized blue component.


g: number

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

Mutable normalized green component.


r: number

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

Mutable normalized red component.