color

(class)

class color

A color used by different parts of the graphics system

static color()
static color(gray)
static color(gray, alpha)
static color(red, green, blue)
static color(red, green, blue, alpha)

Creates a new color object from the given values between 0 and 255

static hsv(h, s, v)
static hsv(vec3)

Creates a new color object from HSV values

r: number

The red component of the color

g: number

The green component of the color

b: number

The blue component of the color

a: number

The alpha component of the color

linear() color

Returns the color converted to linear space

gamma() color

Returns the color converted to gamma space

grayscale() number

Returns the color converted to grayscale

hsv() vec3

Returns the color converted to HSV values

unpack() number, number, number, number

Returns the color as a tuple of 4 numbers

static mix(a, b, t) color

Linearly interpolates between two colors, performing a * (1-t) + b * t

Predefined colors

black: const
white: const
clear: const
cyan: const
gray: const
grey: const
red: const
green: const
blue: const
magenta: const
yellow: const

Color operators

  • + : Adds two colors together component-wise

  • - : Subtracts two colors component-wise

  • * : Multiplies a color by a scalar, or another color component-wise using their [0-1] range

  • / : Divides a color by a scalar