Options
All
  • Public
  • Public/Protected
  • All
Menu

Color class responsible for converting colors between rgb and hex.

since

2.0.0

Hierarchy

  • Color

Implements

Index

Constructors

constructor

  • Create new Color instance. You can use different formats of color: named, rgb or hex. Class will try to parse your provided color, otherwise throws an error.

    example

    Color.create('black'); Color.create('rgb(0, 10, 20)'); Color.create('#AABBCC'); Color.create({r: 0, g: 10, b: 20});

    Parameters

    • color: string | IColor

      String with named color, rgb, hex or object with {r, g, b} properties

    Returns Color

Properties

b

b: number = 0

g

g: number = 0

r

r: number = 0

Methods

getB

  • getB(): number

getG

  • getG(): number

getR

  • getR(): number

setB

  • setB(value: number): Color

setG

  • setG(value: number): Color

setR

  • setR(value: number): Color

toHex

  • toHex(): string

toRgb

Static create

Static fromHex

  • fromHex(hex: string): Color
  • Parse HEX color and return Color instance.

    static

    Parameters

    • hex: string

      HEX color

    Returns Color

Static fromRgb

  • fromRgb(rgb: string): Color
  • Parse RGB color and return Color instance.

    static

    Parameters

    • rgb: string

      RGB color

    Returns Color

Static isHex

  • isHex(hex: string): boolean
  • Check if provided color written in HEX representation.

    static

    Parameters

    • hex: string

      HEX color

    Returns boolean

Static isNamed

  • isNamed(color: string): boolean
  • Check if provided color is named color.

    static

    Parameters

    • color: string

    Returns boolean

Static isRgb

  • isRgb(rgb: string): boolean
  • Check if provided color written in RGB representation.

    static

    Parameters

    • rgb: string

      RGB color

    Returns boolean

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Static method

Generated using TypeDoc