Skip to content
M2O Scripting APIScripting reference
Runtime classServer APIGenerated

Color

Defined in: server/api.d.ts:2466

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

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

Defined in: server/api.d.ts:2474

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: server/api.d.ts:2518

Creates an independent copy of this color.

Color

New color with the same components.


lerp(target, t): this

Defined in: server/api.d.ts:2502

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: server/api.d.ts:2512

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: server/api.d.ts:2525

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: server/api.d.ts:2537

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: server/api.d.ts:2531

Formats this color for logging and debugging.

string

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


static black(): Color

Defined in: server/api.d.ts:2566

Creates opaque black.

Color

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


static blue(): Color

Defined in: server/api.d.ts:2584

Creates opaque blue.

Color

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


static cyan(): Color

Defined in: server/api.d.ts:2596

Creates opaque cyan.

Color

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


static fromHex(hex): Color

Defined in: server/api.d.ts:2544

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: server/api.d.ts:2554

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: server/api.d.ts:2578

Creates opaque green.

Color

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


static magenta(): Color

Defined in: server/api.d.ts:2602

Creates opaque magenta.

Color

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


static red(): Color

Defined in: server/api.d.ts:2572

Creates opaque red.

Color

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


static transparent(): Color

Defined in: server/api.d.ts:2608

Creates fully transparent black.

Color

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


static white(): Color

Defined in: server/api.d.ts:2560

Creates opaque white.

Color

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


static yellow(): Color

Defined in: server/api.d.ts:2590

Creates opaque yellow.

Color

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

a: number

Defined in: server/api.d.ts:2494

Mutable normalized alpha component.


b: number

Defined in: server/api.d.ts:2489

Mutable normalized blue component.


g: number

Defined in: server/api.d.ts:2484

Mutable normalized green component.


r: number

Defined in: server/api.d.ts:2479

Mutable normalized red component.