Class Color

This class holds a color for computer graphics defined via four components (Red, Green, Blue, Alpha). Alpha is opacity (0.0 = completely transparent, 1.0 = completely opaque). All components range from 0.0 to 1.0 in floating point.

Hierarchy

  • Color

Constructors

  • Constructor for creating a Color object

    Parameters

    • r: number = 0

      The red component of the Color object

    • g: number = 0

      The green component of the Color object

    • b: number = 0

      The blue component of the Color object

    • a: number = 1

      The alpha component of the Color object

    Returns Color

Properties

a: number
b: number
g: number
r: number
BLACK: Color = ...
BLUE: Color = ...
CYAN: Color = ...
GREEN: Color = ...
PURPLE: Color = ...
RED: Color = ...
WHITE: Color = ...

Static properties representing standard colors

YELLOW: Color = ...

Methods

  • Create a clone of the Color object

    Returns

    A new Color object that is an exact copy of the original

    Returns Color

  • Copy the components of a given Color object

    Parameters

    • color: Color

      The Color object to copy

    Returns void

  • Divide the current Color object by another one

    Parameters

    • c: Color

      The Color object to divide by

    Returns void

  • Method that divides a Color object by a scalar

    Parameters

    • n: number

      The scalar to divide the Color object by

    Returns void

  • Interpolate between two Color objects

    Parameters

    • c1: Color

      The first Color object

    • c2: Color

      The second Color object

    • alpha: number

      The interpolation factor between the two objects

    Returns void

  • Multiply the current Color object by another one

    Parameters

    • c: Color

      The Color object to multiply by

    Returns void

  • Multiply the current Color object by a scalar

    Parameters

    • n: number

      The scalar to multiply by

    Returns void

  • Set the components of the Color object

    Parameters

    • r: number = 0

      The red component

    • g: number = 0

      The green component

    • b: number = 0

      The blue component

    • a: number = 1

      The alpha component (optional, defaults to 1)

    Returns void

  • Set the components of the Color object from a hex string

    Parameters

    • color: string

      The hex string to convert to a Color object

    Returns void

  • Subtract another Color object from the current one

    Parameters

    • c: Color

      The Color object to subtract

    Returns void

  • Static method to create a copy of the given Color object

    Returns

    A copy of the given Color object

    Parameters

    • color: Color

      The Color object to copy

    Returns Color

  • Static method to create a Color object from a hex string

    Returns

    A new Color object created from the given hex string

    Parameters

    • color: string

      The hex string to convert to a Color object

    Returns Color

  • Static method that calculates the result of dividing a Color by a scalar

    Returns

    The result of the division

    Parameters

    • v: Color

      The Color object to be divided

    • n: number

      The scalar to divide the Color by

    Returns Color

  • Static method to interpolate between two Color objects

    Returns

    The interpolated Color object

    Parameters

    • c1: Color

      The first Color object

    • c2: Color

      The second Color object

    • alpha: number

      The interpolation factor between the two objects

    Returns Color

  • Static method to multiply a Color object by a scalar

    Returns

    The product of the Color object and the scalar

    Parameters

    • v: Color

      The Color object to multiply

    • n: number

      The scalar to multiply by

    Returns Color

  • Static method to subtract two Color objects

    Returns

    The difference between the two Color objects

    Parameters

    • c1: Color

      The first Color object

    • c2: Color

      The second Color object

    Returns Color

Generated using TypeDoc