Class Color

A color manipulation object.

Constructors

  • Parameters

    • Optionalr: number = 0

      red component [0 .. 255]

    • Optionalg: number = 0

      green component [0 .. 255]

    • Optionalb: number = 0

      blue component [0 .. 255]

    • Optionalalpha: number = 1.0

      alpha value [0.0 .. 1.0]

    Returns Color

Properties

glArray: undefined | Float32Array

Accessors

Methods

  • Blend this color with the given one using addition.

    Parameters

    Returns Color

    Reference to this object for method chaining

  • Copy a color object or CSS color into this one.

    Parameters

    Returns Color

    Reference to this object for method chaining

  • Darken this color value by 0..1

    Parameters

    • scale: number

    Returns Color

    Reference to this object for method chaining

  • Return true if the r,g,b,a values of this color are equal with the given one.

    Parameters

    Returns boolean

  • Linearly interpolate between this color and the given one.

    Parameters

    • color: Color
    • alpha: number

      with alpha = 0 being this color, and alpha = 1 being the given one.

    Returns Color

    Reference to this object for method chaining

  • Lighten this color value by 0..1

    Parameters

    • scale: number

    Returns Color

    Reference to this object for method chaining

  • Parse a CSS color string and set this color to the corresponding r,g,b values

    Parameters

    • cssColor: string

    Returns Color

    Reference to this object for method chaining

  • Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to the corresponding r,g,b,a values

    Parameters

    • hexColor: string
    • Optionalargb: boolean = false

      true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)

    Returns Color

    Reference to this object for method chaining

  • Parse an RGB or RGBA CSS color string

    Parameters

    • rgbColor: string

    Returns Color

    Reference to this object for method chaining

  • Generate random r,g,b values for this color object

    Parameters

    • Optionalmin: number = 0

      minimum value for the random range

    • Optionalmax: number = 255

      maxmium value for the random range

    Returns Color

    Reference to this object for method chaining

  • Set this color to the specified value.

    Parameters

    • r: number

      red component [0 .. 255]

    • g: number

      green component [0 .. 255]

    • b: number

      blue component [0 .. 255]

    • Optionalalpha: number = 1.0

      alpha value [0.0 .. 1.0]

    Returns Color

    Reference to this object for method chaining

  • set this color to the specified normalized float values

    Parameters

    • r: number

      red component [0.0 .. 1.0]

    • g: number

      green component [0.0 .. 1.0]

    • b: number

      blue component [0.0 .. 1.0]

    • Optionalalpha: number = 1.0

      alpha value [0.0 .. 1.0]

    Returns Color

    Reference to this object for method chaining

  • set this color to the specified HSL value

    Parameters

    • h: number

      hue (a value from 0 to 1)

    • s: number

      saturation (a value from 0 to 1)

    • l: number

      lightness (a value from 0 to 1)

    Returns Color

    Reference to this object for method chaining

  • set this color to the specified HSV value

    Parameters

    • h: number

      hue (a value from 0 to 1)

    • s: number

      saturation (a value from 0 to 1)

    • v: number

      value (a value from 0 to 1)

    Returns Color

    Reference to this object for method chaining

  • return an Float Array representation of this object

    Returns Float32Array

  • Get the color in "#RRGGBBAA" format

    Parameters

    • alpha: number = ...

    Returns string

  • Get the color in "rgba(R,G,B,A)" format

    Parameters

    • Optionalalpha: number = ...

      alpha value [0.0 .. 1.0]

    Returns string

  • Pack this color RGB components into a Uint32 ARGB representation

    Parameters

    • Optionalalpha: number = 1.0

      alpha value [0.0 .. 1.0]

    Returns number