Constructors

Properties

alpha: number = 1
blue: number
green: number
red: number
BLACK: Color = ...
TRANSPARENT: Color = ...
WHITE: Color = ...

Methods

  • Get the string for this color in RGBA Hex format.

    Parameters

    • Optional allow3: boolean = false

      Allow to generate #rgb instead of #rrggbb

    Returns string

    A string like #ffffff or #ffffffff.

  • Get the string for this color in RGBA format. @param[round=false] All the color values will be rounded to the nearest integer.

    Parameters

    • Optional round: boolean = false

    Returns string

    A string like rgba(r, g, b, a).

  • Generate a color by hue, saturation, lightness components, whith the hue component is between 0 and 360, and the saturation and lightness components are between 0 and 100.

    Parameters

    • hue: number

      The HUE component. (0~360)

    • saturation: number

      The SATURATION component. (0~100)

    • lightness: number

      The LIGHTNESS component. (0~100)

    • Optional alpha: number

      The ALPHA component. (0.~1.)

    Returns Color

    The color.

  • Generate a color by hue, saturation, lightness components,

    Parameters

    • h: number

      The HUE component. (0~360)

    • s: number

      The SATURATION component. (0.~1.)

    • l: number

      The LIGHTNESS component. (0.~1.)

    • a: number

      The ALPHA component. (0.~1.)

    Returns Color

    The color.

  • Generate a color by CSS-like color string.

    Parameters

    • cssInput: string

      CSS-like color string.

    Returns Color

    The color.

    Example

    `hsl(180 55% 25% / 10%)`, `rgb(255 122 111)`, `darkcyan`
    
  • Generate a color by red, green, blue, alpha components, whith color components are between 0 and 255, and the transparent component is between 0 and 1.

    Parameters

    • red: number

      The RED component. (0~255)

    • green: number

      The GREEN component. (0~255)

    • blue: number

      The RED component. (0~255)

    • Optional alpha: number

      The ALPHA component. (0.~1.)

    Returns Color

    The color.

  • Generate a color by red, green and blue components, whith all the components are between 0 and 1.

    Parameters

    • red: number

      The RED component. (0.~1.)

    • green: number

      The GREEN component. (0.~1.)

    • blue: number

      The RED component. (0.~1.)

    • Optional alpha: number

      The ALPHA component. (0.~1.)

    Returns Color

    The color.