Options
All
  • Public
  • Public/Protected
  • All
Menu

For the following methods, unless otherwise specified the operation is performed in RGBA space

Hierarchy

  • IColorMaster

Implemented by

Index

Properties

Readonly alpha

alpha: number

The alpha channel channel value of this RGBA color instance

Readonly blue

blue: number

The blue channel value of this RGBA color instance

Readonly format

format: string

The color format of a RGBA color instance

note

Useful when you are using variables and are not sure what color space the color is from

Readonly green

green: number

The green channel value of this RGBA color instance

Readonly hue

hue: number

The hue channel value from the corresponding HSLA color space

Readonly lightness

lightness: number

The lightness channel value from the corresponding HSLA color space

Readonly red

red: number

The red channel value of this RGBA color instance

Readonly saturation

saturation: number

The saturation channel value from the corresponding HSLA color space

Methods

alphaBy

  • Changes the "alpha" channel value BY a given delta

    note

    delta can be negative

    Parameters

    • delta: number

      When added to current alpha value, range must remain in [0, 1]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

alphaTo

  • Changes the "alpha" channel value TO a given input value

    Parameters

    • value: number

      Must be in range [0, 1] as this is the alpha channel

    Returns IColorMaster

    The instance that was acted upon → for function chaining

darkerBy

  • Removes lightness (tone) of the color in HSLA space

    note

    delta can be negative, but we recommend using lighterBy for clarity

    Parameters

    • delta: number

      When added to current saturation value, range must remain in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

desaturateBy

  • De-saturates (intensity) the color in HSLA space

    note

    delta can be negative, but we recommend using saturateBy for clarity

    Parameters

    • delta: number

      When added to current saturation value, range must remain in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

grayscale

  • Sets the saturation of the color to 0% in HSLA space

    note

    The lightness of the color remains unchanged by this operation

    Returns IColorMaster

    The instance that was acted upon → for function chaining

hexa

  • Converts a RGBA color instance to HEXA color object

    default

    opts = { round: false }

    Parameters

    Returns Ihexa

    A HSLA object containing the respective channel values

hsla

hueBy

  • Changes the "hue" channel value BY a given delta (done in HSLA space and converted back to RGBA space)

    note

    delta can be negative

    Parameters

    • delta: number

      When added to current alpha value, range must remain in [0, 360)

    Returns IColorMaster

    The instance that was acted upon → for function chaining

hueTo

  • Changes the "hue" channel value TO a given input value (done in HSLA space and converted back to RGBA space)

    Parameters

    • value: number | THue

      Must be in range [0, 360) or a CSS/HTML color name

    Returns IColorMaster

    The instance that was acted upon → for function chaining

invert

  • Given an input color, get its inverse value by subtracting current value from the upper bound for each channel

    default

    opts = { alpha: false }

    Parameters

    Returns IColorMaster

    The corresponding inverse color

isValid

  • isValid(): boolean
  • Determines if the current color instance is valid (based on the format returned by the parsers)

    Returns boolean

lighterBy

  • Adds lightness (tone) of the color in HSLA space

    note

    delta can be negative, but we recommend using darkerBy for clarity

    Parameters

    • delta: number

      When added to current lightness value, range must remain in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

lightnessTo

  • Sets the lightness (tone) of a color in HSLA space to a specific value

    Parameters

    • value: number

      The new lightness value, must be in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

rgba

  • Converts a RGBA color instance to RGBA color object

    Returns Irgba

    A HSLA object containing the respective channel values

rotate

  • Rotation changes the hue of a color by value degrees in HSLA space

    note

    Keep in mind that the hue channel has a 360 degree rotational symmetry

    Parameters

    • value: number

    Returns IColorMaster

    The instance that was acted upon → for function chaining

saturateBy

  • Saturates (intensity) the color in HSLA space

    note

    delta can be negative, but we recommend using desaturateBy for clarity

    Parameters

    • delta: number

      When added to current saturation value, range must remain in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

saturationTo

  • Sets the saturation (intensity) of color in HSLA space to a specific value

    Parameters

    • value: number

      New saturation value, must be in [0, 100]

    Returns IColorMaster

    The instance that was acted upon → for function chaining

stringHEX

  • stringHEX(opts?: Omit<IStringOpts, "precision">): string
  • Gives the string representation of an input HEXA color object

    example

    CM({ r: 200, g: 150, b: 100, a: 0.7 }).stringHEX() → "#C89664B3"

    note

    Precision is not relevant for HEXA colorspace since the output will always be an 8-digit hex string

    default

    opts = { alpha: true }

    Parameters

    Returns string

    #RRGGBB[AA]

stringHSL

  • Gives the string representation of an input HSLA color object

    example

    CM({ r: 200, g: 150, b: 100, a: 0.7 }).stringHSL() → "hsla(30, 48%, 59%, 0.7)"

    default

    opts = { alpha: true, precision: [0, 0, 0, 1] }

    Parameters

    Returns string

    hsl[a](H, S, L[, A])

stringRGB

  • Gives the string representation of an input RGBA color object

    example

    CM({ r: 200, g: 150, b: 100, a: 0.7 }).stringRGB() → "rgba(200, 150, 100, 0.7)"

    default

    opts = { alpha: true, precision: [0, 0, 0, 1] }

    Parameters

    Returns string

    rgb[a](R, G, B[, A])