Color
RGBA color, conventionally using 0–1 channels. Arithmetic returns new colors and includes alpha without clamping.
Module: atlas/units
RGBA color, conventionally using 0–1 channels. Arithmetic returns new colors and includes alpha without clamping.
Declaration
export class Color { ... }Constructors
Creates a new color.
constructor(r: number, g: number, b: number, a?: number);Properties
r
The red channel.
r: number;g
The green channel.
g: number;b
The blue channel.
b: number;a
Alpha channel; the constructor defaults to 1 (opaque).
a: number;Methods
add
Returns a new value by adding the operand component-wise; a numeric operand applies to every component.
add(other: Color | number): Color;subtract
Returns a new value by subtracting the operand component-wise; a numeric operand applies to every component.
subtract(other: Color | number): Color;multiply
Returns a new value by multiplying by the operand component-wise; a numeric operand applies to every component.
multiply(other: Color | number): Color;divide
Returns a new value by dividing by the operand component-wise; a numeric operand applies to every component.
divide(other: Color | number): Color;is
Tests exact equality of all components.
is(other: Color): boolean;white
White.
static white(): Color;black
Black.
static black(): Color;red
Red.
static red(): Color;green
Green.
static green(): Color;blue
Blue.
static blue(): Color;transparent
Transparent.
static transparent(): Color;yellow
Yellow.
static yellow(): Color;cyan
Cyan.
static cyan(): Color;magenta
Magenta.
static magenta(): Color;gray
Gray.
static gray(): Color;orange
Orange.
static orange(): Color;purple
Purple.
static purple(): Color;brown
Brown.
static brown(): Color;pink
Pink.
static pink(): Color;lime
Lime.
static lime(): Color;navy
Navy.
static navy(): Color;teal
Teal.
static teal(): Color;olive
Olive.
static olive(): Color;maroon
Maroon.
static maroon(): Color;fromHex
Creates an opaque color from RGB or RRGGBB hexadecimal text, with an optional leading #.
static fromHex(hex: string): Color;mix
Linearly interpolates all RGBA channels; t = 0 selects color1 and t = 1 selects color2. The factor is not clamped.
static mix(color1: Color, color2: Color, t: number): Color;