A mutable type representing a color through its RGB components.

Hierarchy

  • Coords
    • Color

Constructors

Properties

black: Color
blue: Color
blueviolet: Color
chartreuse: Color
cobalt: Color
cyan: Color
gray: Color
green: Color
hotpink: Color
lime: Color
magenta: Color
red: Color
slateblue: Color
springgreen: Color
teal: Color
white: Color
yellow: Color

Accessors

Methods

  • 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)

  • 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

  • Parameters

    • index: number

    Returns number

  • Determines whether this Lockable is locked. If the Lockable is in the unlocked state then it is mutable. If the Lockable is in the locked state then it is immutable.

    Returns boolean

  • 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) * α

  • Locks this Lockable (preventing any further mutation), and returns a token that may be used to unlock it.

    Returns number

  • Parameters

    • index: number
    • value: number

    Returns void

  • Parameters

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

    Returns number[]

  • Parameters

    • OptionalfractionDigits: number

    Returns string

  • Parameters

    • Optionalradix: number

    Returns string

    A string representation of this color.

  • Unlocks this Lockable (allowing mutation), using a token that was obtained from a preceding lock method call.

    Parameters

    • token: number

    Returns void

  • 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.

  • 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

  • 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