Options
All
  • Public
  • Public/Protected
  • All
Menu

A color represented by RGB components. The range for each component is from 0 to 1.

Hierarchy

  • Color

Implements

  • Iterable<number>

Index

Constructors

constructor

  • new Color(r: number, g: number, b: number, a?: number): Color
  • Make a color from individual color components (RGB space)

    Parameters

    • r: number

      Red component.

    • g: number

      Green component.

    • b: number

      Blue component.

    • Optional a: number

      Alpha component. Default: 1

    Returns Color

Properties

0

0: number

Index for red component

1

1: number

Index for green component

2

2: number

Index for blue component

3

3: number

Index for alpha value

a

a: number

Alpha value

b

b: number

Blue component

g

g: number

Green component

r

r: number

Red component

Methods

[Symbol.iterator]

  • [Symbol.iterator](): Iterator<number>

clone

multiply

  • multiply(f: number): Color
  • Multiply element-wise (fr, fg, fb, fa)

    Parameters

    • f: number

    Returns Color

toString

  • toString(): string
  • Convert to a string in the form '(R=,G=,B=,A=)'

    Returns string

toVector

Static interpolateTo

  • interpolateTo(current: Color, target: Color, deltaTime: number, interpSpeed: number): Color
  • Smoothly interpolate towards a varying target color

    Parameters

    • current: Color

      Current color

    • target: Color

      Target color

    • deltaTime: number

      Time since last tick

    • interpSpeed: number

      Interpolation speed

    Returns Color

Static lerp

  • Linearly interpolate between a and b based on alpha

    Parameters

    • a: Color

      First color

    • b: Color

      Second color

    • alpha: number

      Result is 100% of a when alpha=0 and 100% of b when alpha=1

    Returns Color