Atlas Engine
API Referenceatlasatlas/units

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

constructor(r: number, g: number, b: number, a?: number);

Properties

r

r: number;

g

g: number;

b

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

static white(): Color;

black

static black(): Color;

red

static red(): Color;

green

static green(): Color;

blue

static blue(): Color;

transparent

static transparent(): Color;

yellow

static yellow(): Color;

cyan

static cyan(): Color;

magenta

static magenta(): Color;

gray

static gray(): Color;

orange

static orange(): Color;

purple

static purple(): Color;

brown

static brown(): Color;

pink

static pink(): Color;

lime

static lime(): Color;
static navy(): Color;

teal

static teal(): Color;

olive

static olive(): Color;

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;

On this page