Interface RGBColor

An RGB color object.

interface RGBColor {
    b: number;
    g: number;
    opacity: number;
    r: number;
    brighter(k?): RGBColor;
    clamp(): RGBColor;
    copy(values?): RGBColor;
    darker(k?): RGBColor;
    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 RGBColor

  • Returns a new RGB color where the r, g, and b channels are clamped to the range [0, 255] and rounded to the nearest integer value, and the opacity is clamped to the range [0, 1].

    Returns RGBColor

  • Returns a copy of this color.

    Parameters

    • Optional values: {
          b?: number;
          g?: number;
          opacity?: number;
          r?: number;
      }

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

      • Optional b?: number
      • Optional g?: number
      • Optional opacity?: number
      • Optional r?: number

    Returns RGBColor

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

  • 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

b: number

Value of blue channel

g: number

Value of green channel

opacity: number

Opacity value

r: number

Value of red channel