Skip to main content

Class: Color

Defined in: rendering/color.ts:6

The Color class represents a color that can be created using RGB(A) or HSL(A).

Constructors

Constructor

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

Defined in: rendering/color.ts:32

Constructs a new Color instance using RGBA values.

Parameters

r

number

The red component (0-1).

g

number

The green component (0-1).

b

number

The blue component (0-1).

a

number = 1

The alpha component (0-1). Defaults to 1 (fully opaque).

Returns

Color

Properties

black

readonly static black: Color

Defined in: rendering/color.ts:15

Black color constant rgba(0, 0, 0, 1)


blue

readonly static blue: Color

Defined in: rendering/color.ts:21

Blue color constant rgba(0, 0, 1, 1)


green

readonly static green: Color

Defined in: rendering/color.ts:19

Green color constant rgba(0, 1, 0, 1)


red

readonly static red: Color

Defined in: rendering/color.ts:17

Red color constant rgba(1, 0, 0, 1)


transparent

readonly static transparent: Color

Defined in: rendering/color.ts:23

Transparent color constant rgba(0, 0, 0, 0)


white

readonly static white: Color

Defined in: rendering/color.ts:13

White color constant rgba(1, 1, 1, 1)

Accessors

a

Get Signature

get a(): number

Defined in: rendering/color.ts:118

Gets the alpha component of the color.

Returns

number


b

Get Signature

get b(): number

Defined in: rendering/color.ts:111

Gets the blue component of the color.

Returns

number


g

Get Signature

get g(): number

Defined in: rendering/color.ts:104

Gets the green component of the color.

Returns

number


r

Get Signature

get r(): number

Defined in: rendering/color.ts:97

Gets the red component of the color.

Returns

number

Methods

toFloat32Array()

toFloat32Array(): Float32Array

Defined in: rendering/color.ts:134

Converts the color to a glsl-compatible float32 array.

Returns

Float32Array

The RGBA array (e.g. [1, 0, 0, 1] for red).


toRGBAString()

toRGBAString(): string

Defined in: rendering/color.ts:126

Converts the color to a CSS-compatible RGBA string.

Returns

string

The RGBA string (e.g., rgba(255, 0, 0, 1)).


fromHSLA()

static fromHSLA(h, s, l, a): Color

Defined in: rendering/color.ts:47

Creates a Color instance using HSLA values.

Parameters

h

number

The hue (0-360).

s

number

The saturation (0-100).

l

number

The lightness (0-100).

a

number = 1

The alpha component (0-1). Defaults to 1 (fully opaque).

Returns

Color

A new Color instance.