Color
Defined in: server/api.d.ts:2466
Mutable RGBA color exposed as Core.Color, with components stored from 0 to 1.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Color(
r,g,b,a?):Color
Defined in: server/api.d.ts:2474
Creates a color from normalized RGBA components.
Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Color
Methods
Section titled “Methods”clone()
Section titled “clone()”clone():
Color
Defined in: server/api.d.ts:2518
Creates an independent copy of this color.
Returns
Section titled “Returns”Color
New color with the same components.
lerp()
Section titled “lerp()”lerp(
target,t):this
Defined in: server/api.d.ts:2502
Linearly interpolates every component toward a target in place.
Parameters
Section titled “Parameters”target
Section titled “target”Color
Destination color.
number
Interpolation factor; 0 keeps this color and 1 reaches target.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”this
This mutated color for chaining.
toHex()
Section titled “toHex()”toHex(
includeAlpha?):string
Defined in: server/api.d.ts:2525
Converts normalized components to a hexadecimal CSS-style string.
Parameters
Section titled “Parameters”includeAlpha?
Section titled “includeAlpha?”boolean
Whether to append the alpha byte; defaults to false.
Returns
Section titled “Returns”string
Lowercase #rrggbb or #rrggbbaa string.
toJSON()
Section titled “toJSON()”toJSON():
object
Defined in: server/api.d.ts:2537
Converts this color to a plain object for JSON.stringify.
Returns
Section titled “Returns”object
Object containing the current normalized components.
a:
number
b:
number
g:
number
r:
number
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:2531
Formats this color for logging and debugging.
Returns
Section titled “Returns”string
Text in Color(r, g, b, a) form.
black()
Section titled “black()”
staticblack():Color
Defined in: server/api.d.ts:2566
Creates opaque black.
Returns
Section titled “Returns”Color
New Color(0, 0, 0, 1).
blue()
Section titled “blue()”
staticblue():Color
Defined in: server/api.d.ts:2584
Creates opaque blue.
Returns
Section titled “Returns”Color
New Color(0, 0, 1, 1).
cyan()
Section titled “cyan()”
staticcyan():Color
Defined in: server/api.d.ts:2596
Creates opaque cyan.
Returns
Section titled “Returns”Color
New Color(0, 1, 1, 1).
fromHex()
Section titled “fromHex()”
staticfromHex(hex):Color
Defined in: server/api.d.ts:2544
Parses a hexadecimal color string.
Parameters
Section titled “Parameters”string
Hexadecimal color in #RRGGBB or #RRGGBBAA form; the leading # is optional. Three- and four-digit shorthands are not supported.
Returns
Section titled “Returns”Color
Parsed color, or opaque white when the input is invalid.
fromRGB()
Section titled “fromRGB()”
staticfromRGB(r,g,b,a?):Color
Defined in: server/api.d.ts:2554
Creates a normalized color from byte components.
Parameters
Section titled “Parameters”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.
Returns
Section titled “Returns”Color
New normalized color.
green()
Section titled “green()”
staticgreen():Color
Defined in: server/api.d.ts:2578
Creates opaque green.
Returns
Section titled “Returns”Color
New Color(0, 1, 0, 1).
magenta()
Section titled “magenta()”
staticmagenta():Color
Defined in: server/api.d.ts:2602
Creates opaque magenta.
Returns
Section titled “Returns”Color
New Color(1, 0, 1, 1).
staticred():Color
Defined in: server/api.d.ts:2572
Creates opaque red.
Returns
Section titled “Returns”Color
New Color(1, 0, 0, 1).
transparent()
Section titled “transparent()”
statictransparent():Color
Defined in: server/api.d.ts:2608
Creates fully transparent black.
Returns
Section titled “Returns”Color
New Color(0, 0, 0, 0).
white()
Section titled “white()”
staticwhite():Color
Defined in: server/api.d.ts:2560
Creates opaque white.
Returns
Section titled “Returns”Color
New Color(1, 1, 1, 1).
yellow()
Section titled “yellow()”
staticyellow():Color
Defined in: server/api.d.ts:2590
Creates opaque yellow.
Returns
Section titled “Returns”Color
New Color(1, 1, 0, 1).
Properties
Section titled “Properties”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.
