Interface ColorCommonInstance

A helper interface of methods common to color objects (including colors defined outside the d3-color standard module, e.g. in d3-hsv). This interface

interface ColorCommonInstance {
    brighter(k?): ColorCommonInstance;
    darker(k?): ColorCommonInstance;
    displayable(): boolean;
    hex(): string;
    rgb(): RGBColor;
    toString(): string;
}

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. The behavior of this method is dependent on the implementing color space.

    Parameters

    • Optional k: number

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

    Returns ColorCommonInstance

  • 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. The behavior of this method is dependent on the implementing color space.

    Parameters

    • Optional k: number

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

    Returns ColorCommonInstance

  • 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. 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 the RGB equivalent of this color. For RGB colors, that’s "this".

    Returns RGBColor

  • 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