Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color

Color representation with support for hex, RBG, arithmetic RBG, HSL, and integer colors

author

osbornb

Hierarchy

  • Color

Index

Methods

copy

getAlpha

  • getAlpha(): number
  • Get the alpha color as an integer

    Returns number

    alpha integer color inclusively between 0 and 255

getAlphaArithmetic

  • getAlphaArithmetic(): number
  • Get the alpha color as an arithmetic float

    Returns number

    alpha float color inclusively between 0.0 and 1.0

getAlphaHex

  • getAlphaHex(): string
  • Get the alpha color in hex

    Returns string

    alpha hex color in format AA

getAlphaHexShorthand

  • getAlphaHexShorthand(): string
  • Get the alpha color in hex, shorthand when possible

    Returns string

    alpha hex color in format A or AA

getBlue

  • getBlue(): number
  • Get the blue color as an integer

    Returns number

    blue integer color inclusively between 0 and 255

getBlueArithmetic

  • getBlueArithmetic(): number
  • Get the blue color as an arithmetic float

    Returns number

    blue float color inclusively between 0.0 and 1.0

getBlueHex

  • getBlueHex(): string
  • Get the blue color in hex

    Returns string

    blue hex color in format BB

getBlueHexShorthand

  • getBlueHexShorthand(): string
  • Get the blue color in hex, shorthand when possible

    Returns string

    blue hex color in format B or BB

getColor

  • getColor(): number
  • Get the color as an integer

    Returns number

    integer color

getColorHex

  • getColorHex(): string
  • Get the color as a hex string

    Returns string

    hex color in the format #RRGGBB

getColorHexShorthand

  • getColorHexShorthand(): string
  • Get the color as a hex string, shorthanded when possible

    Returns string

    hex color in the format #RGB or #RRGGBB

getColorHexShorthandWithAlpha

  • getColorHexShorthandWithAlpha(): string
  • Get the color as a hex string with alpha, shorthanded when possible

    Returns string

    hex color in the format #ARGB or #AARRGGBB

getColorHexWithAlpha

  • getColorHexWithAlpha(): string
  • Get the color as a hex string with alpha

    Returns string

    hex color in the format #AARRGGBB

getColorWithAlpha

  • getColorWithAlpha(): number
  • Get the color as an integer including the alpha

    Returns number

    integer color

getGreen

  • getGreen(): number
  • Get the green color as an integer

    Returns number

    green integer color inclusively between 0 and 255

getGreenArithmetic

  • getGreenArithmetic(): number
  • Get the green color as an arithmetic float

    Returns number

    green float color inclusively between 0.0 and 1.0

getGreenHex

  • getGreenHex(): string
  • Get the green color in hex

    Returns string

    green hex color in format GG

getGreenHexShorthand

  • getGreenHexShorthand(): string
  • Get the green color in hex, shorthand when possible

    Returns string

    green hex color in format G or GG

getHSL

  • getHSL(): number[]
  • Get the HSL (hue, saturation, lightness) values

    Returns number[]

    HSL array where: 0 = hue, 1 = saturation, 2 = lightness

getHue

  • getHue(): number

getLightness

  • getLightness(): number
  • Get the HSL lightness value

    Returns number

    lightness value

getOpacity

  • getOpacity(): number
  • Get the opacity as an arithmetic float

    Returns number

    opacity float inclusively between 0.0 and 1.0

getRed

  • getRed(): number
  • Get the red color as an integer

    Returns number

    red integer color inclusively between 0 and 255

getRedArithmetic

  • getRedArithmetic(): number
  • Get the red color as an arithmetic float

    Returns number

    red float color inclusively between 0.0 and 1.0

getRedHex

  • getRedHex(): string
  • Get the red color in hex

    Returns string

    red hex color in format RR

getRedHexShorthand

  • getRedHexShorthand(): string
  • Get the red color in hex, shorthand when possible

    Returns string

    red hex color in format R or RR

getSaturation

  • getSaturation(): number
  • Get the HSL saturation value

    Returns number

    saturation value

isOpaque

  • isOpaque(): boolean
  • Check if the color is opaque (opacity or alpha of 1.0, 255, or x00)

    Returns boolean

    true if opaque

setAlpha

  • setAlpha(alpha: string | number): void
  • Set the alpha color as an arithmetic float or hex

    Parameters

    • alpha: string | number
             alpha float color inclusively between 0.0 and 1.0 or hex color in format AA or A

    Returns void

setBlue

  • setBlue(blue: string | number): void
  • Set the blue color as an integer or hex

    Parameters

    • blue: string | number
             blue integer color inclusively between 0 and 255 or in format BB or B

    Returns void

setColor

  • setColor(color: string | number | string): void
  • Set the color as a single integer or Set the color in hex

    Parameters

    • color: string | number | string
             color integer or hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB,
             AARRGGBB, #ARGB, or ARGB

    Returns void

setColorByHSL

  • setColorByHSL(hue: number, saturation: number, lightness: number, alpha?: undefined | number): void
  • Set the color with HSLA (hue, saturation, lightness, alpha) values

    Parameters

    • hue: number
             hue value inclusively between 0.0 and 360.0
    • saturation: number
             saturation inclusively between 0.0 and 1.0
    • lightness: number
             lightness inclusively between 0.0 and 1.0
    • Optional alpha: undefined | number
             alpha inclusively between 0.0 and 1.0

    Returns void

setGreen

  • setGreen(green: string | number): void
  • Set the green color as an integer orr hex

    Parameters

    • green: string | number
             green integer color inclusively between 0 and 255 or in format GG or G

    Returns void

setOpacity

  • setOpacity(opacity: number): void
  • Set the opacity as an arithmetic float

    Parameters

    • opacity: number
             opacity float color inclusively between 0.0 and 1.0

    Returns void

setRGB

  • setRGB(red: any, green: any, blue: any, alpha?: any): void
  • Parameters

    • red: any
    • green: any
    • blue: any
    • Optional alpha: any

    Returns void

setRed

  • setRed(red: string | number): void
  • Set the red color as an integer or hex

    Parameters

    • red: string | number
             red integer color inclusively between 0 and 255 or red hex color in format RR or R

    Returns void

Static black

Static blue

Static brown

Static color

  • color(color: string): Color
  • Create the color in hex

    Parameters

    • color: string
             hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB,
             AARRGGBB, #ARGB, or ARGB

    Returns Color

    color

Static cyan

Static darkGray

Static gray

Static green

Static lightGray

Static magenta

Static orange

Static pink

Static purple

Static red

Static violet

Static white

Static yellow

Generated using TypeDoc