Class Color

Sass's color type.

Hierarchy

  • Color

Index

Constructors

constructor

  • new Color(r: number, g: number, b: number, a?: number): Color
  • 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

constructor

  • new Color(argb: number): 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

getA

  • getA(): number
  • 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

getB

  • getB(): 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

getG

  • getG(): 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

getR

  • getR(): 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

setA

  • setA(value: number): void

setB

  • setB(value: number): void

setG

  • setG(value: number): void

setR

  • setR(value: number): void