Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color

Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range.

Hierarchy

  • Color

Index

Constructors

constructor

  • new Color(knownColor: string): Color
  • new Color(hex: string): Color
  • new Color(argb: number): Color
  • new Color(alpha: number, red: number, green: number, blue: number): Color

Properties

a

a: number

Gets the Alpha component (in the [0, 255] range) of this color. This is a read-only property.

android

android: number

Gets the android-specific integer value representation. Same as the Argb one. This is a read-only property.

argb

argb: number

Gets the Argb Number representation of this color where each 8 bits represent a single color component. This is a read-only property.

b

b: number

Gets the Blue component (in the [0, 255] range) of this color. This is a read-only property.

g

g: number

Gets the Green component (in the [0, 255] range) of this color. This is a read-only property.

hex

hex: string

Gets the Hexadecimal string representation of this color. This is a read-only property.

ios

ios: any

Gets the iOS-specific UIColor value representation. This is a read-only property.

name

name: string

Gets the known name of this instance. Defined only if it has been constructed from a known color name - e.g. "red". This is a read-only property.

r

r: number

Gets the Red component (in the [0, 255] range) of this color. This is a read-only property.

Methods

brighten

  • brighten(amount: number): Color
  • Brighten the color a given amount, from 0 to 100.

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

complement

darken

  • darken(amount: number): Color
  • Darken the color a given amount, from 0 to 100. Providing 100 will always return black.

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

desaturate

  • desaturate(amount: number): Color
  • Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale.

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

equals

  • equals(value: Color): boolean
  • Specifies whether this Color is equal to the Color parameter.

    Parameters

    • value: Color

      The Color to test.

    Returns boolean

getBrightness

  • getBrightness(): number

getLuminance

  • getLuminance(): number

greyscale

  • Completely desaturates a color into greyscale. Same as calling desaturate(100).

    Returns Color

isDark

  • isDark(): boolean

isLight

  • isLight(): boolean

lighten

  • lighten(amount: number): Color
  • Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

    olor : Color

saturate

  • saturate(amount: number): Color
  • Saturate the color a given amount, from 0 to 100.

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

setAlpha

  • setAlpha(a: number): Color
  • Return this color (as a new Color instance) with the provided alpha

    Parameters

    • a: number

    Returns Color

spin

  • spin(amount: number): Color
  • Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).

    Parameters

    • amount: number

      (between 0 and 100)

    Returns Color

toHsl

  • toHsl(): object
  • return the hsl representation of the color

    Returns object

    • a: number
    • h: number
    • l: number
    • s: number

toHslString

  • toHslString(): string

toHsv

  • toHsv(): object
  • return the hsv representation of the color

    Returns object

    • a: number
    • h: number
    • s: number
    • v: number

toHsvString

  • toHsvString(): string

toRgbString

  • toRgbString(): string

Static equals

  • Compares two Color instances.

    Parameters

    • value1: Color

      A Color to compare.

    • value2: Color

      A Color to compare.

    Returns boolean

Static fromIosColor

  • fromIosColor(value: any): Color
  • Creates color from iOS-specific UIColor value representation.

    Parameters

    • value: any

    Returns Color

Static isValid

  • isValid(value: any): boolean
  • Validates if a value can be converted to color.

    Parameters

    • value: any

      Input string.

    Returns boolean

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method