Color
Defined in: src/color/Color.ts:17
Color common color operations
Tutorial
Section titled “Tutorial”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Color(
color?
):Color
Defined in: src/color/Color.ts:25
Parameters
Section titled “Parameters”color?
Section titled “color?”optional in hex or rgb(a) or hsl format or from known color list
Returns
Section titled “Returns”Color
Properties
Section titled “Properties”isUnrecognised
Section titled “isUnrecognised”isUnrecognised:
boolean
=false
Defined in: src/color/Color.ts:19
Methods
Section titled “Methods”getAlpha()
Section titled “getAlpha()”getAlpha():
number
Defined in: src/color/Color.ts:133
Gets value of alpha channel for this color
Returns
Section titled “Returns”number
0-1
getSource()
Section titled “getSource()”getSource():
TRGBAColorSource
Defined in: src/color/Color.ts:64
Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
Returns
Section titled “Returns”overlayWith()
Section titled “overlayWith()”overlayWith(
otherColor
):Color
Defined in: src/color/Color.ts:173
Overlays color with another color
Parameters
Section titled “Parameters”otherColor
Section titled “otherColor”string
| Color
Returns
Section titled “Returns”Color
thisArg
setAlpha()
Section titled “setAlpha()”setAlpha(
alpha
):Color
Defined in: src/color/Color.ts:142
Sets value of alpha channel for this color
Parameters
Section titled “Parameters”number
Alpha value 0-1
Returns
Section titled “Returns”Color
thisArg
setSource()
Section titled “setSource()”setSource(
source
):void
Defined in: src/color/Color.ts:72
Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
Parameters
Section titled “Parameters”source
Section titled “source”Returns
Section titled “Returns”void
toBlackWhite()
Section titled “toBlackWhite()”toBlackWhite(
threshold
):Color
Defined in: src/color/Color.ts:161
Transforms color to its black and white representation
Parameters
Section titled “Parameters”threshold
Section titled “threshold”number
Returns
Section titled “Returns”Color
thisArg
toGrayscale()
Section titled “toGrayscale()”toGrayscale():
Color
Defined in: src/color/Color.ts:151
Transforms color to its grayscale representation
Returns
Section titled “Returns”Color
thisArg
toHex()
Section titled “toHex()”toHex():
string
Defined in: src/color/Color.ts:115
Returns color representation in HEX format
Returns
Section titled “Returns”string
ex: FF5555
toHexa()
Section titled “toHexa()”toHexa():
string
Defined in: src/color/Color.ts:124
Returns color representation in HEXA format
Returns
Section titled “Returns”string
ex: FF5555CC
toHsl()
Section titled “toHsl()”toHsl():
string
Defined in: src/color/Color.ts:97
Returns color representation in HSL format
Returns
Section titled “Returns”string
ex: hsl(0-360,0%-100%,0%-100%)
toHsla()
Section titled “toHsla()”toHsla():
string
Defined in: src/color/Color.ts:106
Returns color representation in HSLA format
Returns
Section titled “Returns”string
ex: hsla(0-360,0%-100%,0%-100%,0-1)
toRgb()
Section titled “toRgb()”toRgb():
string
Defined in: src/color/Color.ts:80
Returns color representation in RGB format
Returns
Section titled “Returns”string
ex: rgb(0-255,0-255,0-255)
toRgba()
Section titled “toRgba()”toRgba():
string
Defined in: src/color/Color.ts:89
Returns color representation in RGBA format
Returns
Section titled “Returns”string
ex: rgba(0-255,0-255,0-255,0-1)
fromHex()
Section titled “fromHex()”
static
fromHex(color
):Color
Defined in: src/color/Color.ts:298
Returns new color object, when given a color in HEX format
Parameters
Section titled “Parameters”string
Color value ex: FF5555
Returns
Section titled “Returns”Color
Static
Section titled “Static”Member Of
Section titled “Member Of”Color
fromHsl()
Section titled “fromHsl()”
static
fromHsl(color
):Color
Defined in: src/color/Color.ts:236
Returns new color object, when given a color in HSL format
Parameters
Section titled “Parameters”string
Color value ex: hsl(0-260,0%-100%,0%-100%)
Returns
Section titled “Returns”Color
Member Of
Section titled “Member Of”Color
fromHsla()
Section titled “fromHsla()”
static
fromHsla(color
):Color
Defined in: src/color/Color.ts:248
Function
Returns new color object, when given a color in HSLA format
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Color
Static
Section titled “Static”Member Of
Section titled “Member Of”Color
fromRgb()
Section titled “fromRgb()”
static
fromRgb(color
):Color
Defined in: src/color/Color.ts:195
Returns new color object, when given a color in RGB format
Parameters
Section titled “Parameters”string
Color value ex: rgb(0-255,0-255,0-255)
Returns
Section titled “Returns”Color
Member Of
Section titled “Member Of”Color
fromRgba()
Section titled “fromRgba()”
static
fromRgba(color
):Color
Defined in: src/color/Color.ts:207
Function
Returns new color object, when given a color in RGBA format
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Color
Static
Section titled “Static”Member Of
Section titled “Member Of”Color
parseAngletoDegrees()
Section titled “parseAngletoDegrees()”
static
parseAngletoDegrees(value
):number
Defined in: src/color/Color.ts:334
Converts a string that could be any angle notation (50deg, 0.5turn, 2rad) into degrees without the ‘deg’ suffix
Parameters
Section titled “Parameters”string
ex: 0deg, 0.5turn, 2rad
Returns
Section titled “Returns”number
number in degrees or NaN if inputs are invalid
Static
Section titled “Static”Member Of
Section titled “Member Of”Color
sourceFromHex()
Section titled “sourceFromHex()”
static
sourceFromHex(color
):undefined
|TRGBAColorSource
Defined in: src/color/Color.ts:309
Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in HEX format
Parameters
Section titled “Parameters”string
ex: FF5555 or FF5544CC (RGBa)
Returns
Section titled “Returns”undefined
| TRGBAColorSource
source
Static
Section titled “Static”Member Of
Section titled “Member Of”Color
sourceFromHsl()
Section titled “sourceFromHsl()”
static
sourceFromHsl(color
):undefined
|TRGBAColorSource
Defined in: src/color/Color.ts:260
Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in HSL or HSLA format. Adapted from https://github.com/mjijackson
Parameters
Section titled “Parameters”string
Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
Returns
Section titled “Returns”undefined
| TRGBAColorSource
source
Member Of
Section titled “Member Of”Color
http://http://www.w3.org/TR/css3-color/#hsl-color
sourceFromRgb()
Section titled “sourceFromRgb()”
static
sourceFromRgb(color
):undefined
|TRGBAColorSource
Defined in: src/color/Color.ts:217
Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in RGB or RGBA format
Parameters
Section titled “Parameters”string
Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
Returns
Section titled “Returns”undefined
| TRGBAColorSource
source
Member Of
Section titled “Member Of”Color