Options
All
  • Public
  • Public/Protected
  • All
Menu

A mutable type representing a color through its RGB components.

Hierarchy

  • Coords
    • Color

Implements

Index

Constructors

constructor

  • new Color(r: number, g: number, b: number): Color

Properties

Static black

black: Color

Static blue

blue: Color

Static blueviolet

blueviolet: Color

Static chartreuse

chartreuse: Color

Static cobalt

cobalt: Color

Static cyan

cyan: Color

Static gray

gray: Color

Static green

green: Color

Static hotpink

hotpink: Color

Static lime

lime: Color

Static magenta

magenta: Color

Static red

red: Color

Static slateblue

slateblue: Color

Static springgreen

springgreen: Color

Static teal

teal: Color

Static white

white: Color

Static yellow

yellow: Color

Accessors

b

  • get b(): number
  • set b(b: number): void
  • The blue coordinate (component) of this color. The value is clamped to the range [0,1].

    Returns number

  • The blue coordinate (component) of this color. The value is clamped to the range [0,1].

    Parameters

    • b: number

    Returns void

blue

  • get blue(): number
  • set blue(blue: number): void

coords

  • get coords(): number[]
  • set coords(data: number[]): void

g

  • get g(): number
  • set g(g: number): void
  • The green coordinate (component) of this color. The value is clamped to the range [0,1].

    Returns number

  • The green coordinate (component) of this color. The value is clamped to the range [0,1].

    Parameters

    • g: number

    Returns void

green

  • get green(): number
  • set green(green: number): void

length

  • get length(): number

luminance

  • get luminance(): number

modified

  • get modified(): boolean
  • set modified(modified: boolean): void

r

  • get r(): number
  • set r(r: number): void
  • The red coordinate (component) of this color. The value is clamped to the range [0,1].

    Returns number

  • The red coordinate (component) of this color. The value is clamped to the range [0,1].

    Parameters

    • r: number

    Returns void

red

  • get red(): number
  • set red(red: number): void

Methods

approx

  • approx(n: number): Color
  • Returns a color in which any rgb component whose absolute value is less than pow(10, -n) times the absolute value of the largest coordinate is zero.

    Parameters

    • n: number

      The exponent used to determine which components are set to zero.

    Returns Color

    approx(this)

clone

copy

  • copy(color: { b: number; g: number; r: number }): this
  • Copies the specified color into this Color instance.

    Parameters

    • color: { b: number; g: number; r: number }

      The color to be copied.

      • b: number
      • g: number
      • r: number

    Returns this

equals

  • equals(other: any): boolean

getComponent

  • getComponent(index: number): number

isLocked

  • isLocked(): boolean

lerp

  • lerp(target: { b: number; g: number; r: number }, α: number): Color
  • Linearly interpolates from this color to the specified color.

    Parameters

    • target: { b: number; g: number; r: number }

      The color returned when α = 1.

      • b: number
      • g: number
      • r: number
    • α: number

      The parameter that determines the composition of the color.

    Returns Color

    this + (target - this) * α

lock

  • lock(): number

pop

  • pop(): number

push

  • push(value: number): number

scale

  • scale(α: number): Color

setComponent

  • setComponent(index: number, value: number): void

toArray

  • toArray(array?: number[], offset?: number): number[]
  • Parameters

    • Default value array: number[] = []
    • Default value offset: number = 0

    Returns number[]

toExponential

  • toExponential(fractionDigits?: number): string

toFixed

  • toFixed(fractionDigits?: number): string

toLocaleString

  • toLocaleString(): string

toPrecision

  • toPrecision(precision?: number): string

toString

  • toString(radix?: number): string
  • Parameters

    • Optional radix: number

    Returns string

    A string representation of this color.

unlock

  • unlock(token: number): void

Static copy

  • copy(color: { b: number; g: number; r: number }): Color
  • Parameters

    • color: { b: number; g: number; r: number }

      The color to be copied.

      • b: number
      • g: number
      • r: number

    Returns Color

    A mutable copy of the specified color.

Static fromHSL

  • fromHSL(H: number, S: number, L: number): Color
  • Converts an angle, radius, height to a color on a color wheel.

    Parameters

    • H: number
    • S: number
    • L: number

    Returns Color

Static fromRGB

  • fromRGB(r: number, g: number, b: number): Color
  • Constructs a new mutable instance of Color from the rgb components. The components are clamped to the range [0, 1].

    Parameters

    • r: number

      The red component.

    • g: number

      The green component.

    • b: number

      The blue component.

    Returns Color

Static lerp

  • lerp(a: { b: number; g: number; r: number }, b: { b: number; g: number; r: number }, α: number): Color
  • Parameters

    • a: { b: number; g: number; r: number }
      • b: number
      • g: number
      • r: number
    • b: { b: number; g: number; r: number }
      • b: number
      • g: number
      • r: number
    • α: number

    Returns Color

Static luminance

  • luminance(r: number, g: number, b: number): number

Static mustBe

Static random

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Property
  • Method
  • Protected property
  • Protected method
  • Static property
  • Static method

Generated using TypeDoc