Foundation.Color

RGBA Color definition.


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/utilities/_digest.ts'
  • '/foundation/core/utilities/Actor.ts'

Extends

This type does not extend a base type.

Implements

This type does not implement any interfaces


Public Properties

r

  • Get or set the red component of the color [0-255].

g

  • Get or set the green component of the color [0-255].

b

  • Get or set the blue component of the color [0-255].

a

  • Get or set the alpha component of the color [0-255]. Note: 0-255, not 0-1.

rgbaString

  • Returns a CSS rgba string representation of the color (E.g. rgba(255,255,255,1)).

Public Properties (Static)

red: Color

  • (255, 0, 0)

green: Color

  • (0, 255, 0)

blue: Color

  • (0, 0, 255)

black: Color

  • (0, 0, 0)

white: Color

  • (255, 255, 255)

transparent: Color

  • (0, 0, 0, 0)

yellow: Color

  • (255, 255, 0)

crimson: Color

  • (220, 20, 60)

cornflowerBlue: Color

  • (100, 149, 237)

foundationGrey: Color

  • (14, 35, 46)

Constructors

(r: number = 0, g: number = 0, b: number = 0, a: number = 255)

  • Defaults to black (0, 0, 0, 255).

Instance Methods

setRgba(r: number, g: number, b: number, a: number = 255): Color

  • Set all components in one call.
  • Returns the current color for chaining.

Static Methods

longToShort(long: number): number

  • Converts a value in the range [0, 255] to its range equivalent in [0, 1].

shortToLong(long: number): number

  • Converts a value in the range [0, 1] to its range equivalent in [0, 255].

lerp(a: Color, b: Color, t: number, outColor?: Color): Color

  • Returns the linear interpolation between a and b at time t, where t=0 is a and t=1 is b. t is not clamped.
  • Optionally, an out color can be passed to avoid a new instantiation.