Interface HCLColor

An HCL (CIELCH) color object.

interface HCLColor {
    c: number;
    h: number;
    l: number;
    opacity: number;
    brighter(k?): HCLColor;
    copy(values?): HCLColor;
    darker(k?): HCLColor;
    displayable(): boolean;
    formatHex(): string;
    formatHex8(): string;
    formatHsl(): string;
    formatRgb(): string;
    hex(): string;
    rgb(): RGBColor;
    toString(): string;
}

Hierarchy

Methods

  • Returns a brighter copy of this color. If k is specified, it controls how much brighter the returned color should be. If k is not specified, it defaults to 1.

    Parameters

    • Optional k: number

      A color space dependent number to determine, how much brighter the returned color should be.

    Returns HCLColor

  • Returns a copy of this color.

    Parameters

    • Optional values: {
          c?: number;
          h?: number;
          l?: number;
          opacity?: number;
      }

      If values is specified, any enumerable own properties of values are assigned to the new returned color.

      • Optional c?: number
      • Optional h?: number
      • Optional l?: number
      • Optional opacity?: number

    Returns HCLColor

  • Returns a darker copy of this color. If k is specified, it controls how much darker the returned color should be. If k is not specified, it defaults to 1.

    Parameters

    • Optional k: number

      A color space dependent number to determine, how much darker the returned color should be.

    Returns HCLColor

  • Returns true if and only if the color is displayable on standard hardware. For example, this returns false for an RGB color if any channel value is less than zero or greater than 255, or if the opacity is not in the range [0, 1].

    Returns boolean

  • Returns a hexadecimal string representing this color in RGB space, such as #f7eaba. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255.

    Returns string

  • Returns a hexadecimal string representing this color in RGBA space, such as #f7eaba90. If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255.

    Returns string

  • Returns a string representing this color according to the CSS Color Module Level 3 specification, such as hsl(257, 50%, 80%) or hsla(257, 50%, 80%, 0.2). If this color is not displayable, a suitable displayable color is returned instead by clamping S and L channel values to the interval [0, 100].

    Returns string

  • Returns a string representing this color according to the CSS Object Model specification, such as rgb(247, 234, 186) or rgba(247, 234, 186, 0.2). If this color is not displayable, a suitable displayable color is returned instead by clamping RGB channel values to the interval [0, 255].

    Returns string

  • Returns string

    Deprecated

    Use color.formatHex.

  • Returns a string representing this color according to the CSS Object Model specification, such as rgb(247, 234, 186) or rgba(247, 234, 186, 0.2). If this color is not displayable, a suitable displayable color is returned instead. For example, RGB channel values greater than 255 are clamped to 255.

    Returns string

Properties

c: number

Chroma channel value typically in [0, 230].

h: number

Hue channel value typically in [0, 360).

l: number

Luminance channel value typically in the range [0, 100].

opacity: number

Opacity value