Skip to content

Color

Defined in: src/color/Color.ts:18

Color common color operations

colors

new Color(color?): Color

Defined in: src/color/Color.ts:26

TColorArg

optional in hex or rgb(a) or hsl format or from known color list

Color

isUnrecognised: boolean = false

Defined in: src/color/Color.ts:20

getAlpha(): number

Defined in: src/color/Color.ts:134

Gets value of alpha channel for this color

number

0-1


getSource(): TRGBAColorSource

Defined in: src/color/Color.ts:65

Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])

TRGBAColorSource


overlayWith(otherColor): Color

Defined in: src/color/Color.ts:174

Overlays color with another color

string | Color

Color

thisArg


setAlpha(alpha): Color

Defined in: src/color/Color.ts:143

Sets value of alpha channel for this color

number

Alpha value 0-1

Color

thisArg


setSource(source): void

Defined in: src/color/Color.ts:73

Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])

TRGBAColorSource

void


toBlackWhite(threshold): Color

Defined in: src/color/Color.ts:162

Transforms color to its black and white representation

number

Color

thisArg


toGrayscale(): Color

Defined in: src/color/Color.ts:152

Transforms color to its grayscale representation

Color

thisArg


toHex(): string

Defined in: src/color/Color.ts:116

Returns color representation in HEX format

string

ex: FF5555


toHexa(): string

Defined in: src/color/Color.ts:125

Returns color representation in HEXA format

string

ex: FF5555CC


toHsl(): string

Defined in: src/color/Color.ts:98

Returns color representation in HSL format

string

ex: hsl(0-360,0%-100%,0%-100%)


toHsla(): string

Defined in: src/color/Color.ts:107

Returns color representation in HSLA format

string

ex: hsla(0-360,0%-100%,0%-100%,0-1)


toRgb(): string

Defined in: src/color/Color.ts:81

Returns color representation in RGB format

string

ex: rgb(0-255,0-255,0-255)


toRgba(): string

Defined in: src/color/Color.ts:90

Returns color representation in RGBA format

string

ex: rgba(0-255,0-255,0-255,0-1)


static fromHex(color): Color

Defined in: src/color/Color.ts:287

Returns new color object, when given a color in HEX format

string

Color value ex: FF5555

Color


static fromHsl(color): Color

Defined in: src/color/Color.ts:231

Returns new color object, when given a color in HSL format

string

Color value ex: hsl(0-260,0%-100%,0%-100%)

Color


static fromHsla(color): Color

Defined in: src/color/Color.ts:240

Returns new color object, when given a color in HSLA format

string

Color


static fromRgb(color): Color

Defined in: src/color/Color.ts:195

Returns new color object, when given a color in RGB format

string

Color value ex: rgb(0-255,0-255,0-255)

Color


static fromRgba(color): Color

Defined in: src/color/Color.ts:204

Returns new color object, when given a color in RGBA format

string

Color


static parseAngletoDegrees(value): number

Defined in: src/color/Color.ts:319

Converts a string that could be any angle notation (50deg, 0.5turn, 2rad) into degrees without the ‘deg’ suffix

string

ex: 0deg, 0.5turn, 2rad

number

number in degrees or NaN if inputs are invalid


static sourceFromHex(color): undefined | TRGBAColorSource

Defined in: src/color/Color.ts:296

Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in HEX format

string

ex: FF5555 or FF5544CC (RGBa)

undefined | TRGBAColorSource

source


static sourceFromHsl(color): undefined | TRGBAColorSource

Defined in: src/color/Color.ts:251

Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in HSL or HSLA format. Adapted from https://github.com/mjijackson

string

Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)

undefined | TRGBAColorSource

source

http://http://www.w3.org/TR/css3-color/#hsl-color


static sourceFromRgb(color): undefined | TRGBAColorSource

Defined in: src/color/Color.ts:213

Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in RGB or RGBA format

string

Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)

undefined | TRGBAColorSource

source