Color

Sass's color type.

Hierarchy

  • Color

Constructors

Methods

Constructors

  • Creates a new Sass color with the given red, green, blue, and alpha channels. The red, green, and blue channels must be integers between 0 and 255 (inclusive), and alpha must be between 0 and 1 (inclusive).

    Example

    new sass.types.Color(107, 113, 127); // #6b717f
    new sass.types.Color(0, 0, 0, 0); // rgba(0, 0, 0, 0)

    Parameters

    • r: number
    • g: number
    • b: number
    • Optional a: number

    Returns Color

  • Creates a new Sass color with alpha, red, green, and blue channels taken from respective two-byte chunks of a hexidecimal number.

    Example

    new sass.types.Color(0xff6b717f); // #6b717f
    new sass.types.Color(0x00000000); // rgba(0, 0, 0, 0)

    Parameters

    • argb: number

    Returns Color

Methods

  • Returns the alpha channel of the color as a number from 0 to 1.

    Example

    // color is `#6b717f`.
    color.getA(); // 1

    // color is `transparent`.
    color.getA(); // 0

    Returns number

  • Returns the blue channel of the color as an integer from 0 to 255.

    Example

    // color is `#6b717f`.
    color.getB(); // 127

    // color is `#b37399`.
    color.getB(); // 153

    Returns number

  • Returns the green channel of the color as an integer from 0 to 255.

    Example

    // color is `#6b717f`.
    color.getG(); // 113

    // color is `#b37399`.
    color.getG(); // 115

    Returns number

  • Returns the red channel of the color as an integer from 0 to 255.

    Example

    // color is `#6b717f`.
    color.getR(); // 107

    // color is `#b37399`.
    color.getR(); // 179

    Returns number

  • Sets the alpha channel of the color. The value must be between 0 and 1 (inclusive).

    Deprecated

    Use constructor instead.

    Parameters

    • value: number

    Returns void

  • Sets the blue channel of the color. The value must be an integer between 0 and 255 (inclusive).

    Deprecated

    Use constructor instead.

    Parameters

    • value: number

    Returns void

  • Sets the green channel of the color. The value must be an integer between 0 and 255 (inclusive).

    Deprecated

    Use constructor instead.

    Parameters

    • value: number

    Returns void

  • Sets the red channel of the color. The value must be an integer between 0 and 255 (inclusive).

    Deprecated

    Use constructor instead.

    Parameters

    • value: number

    Returns void