Color
Color common color operations
Tutorial
Constructors
new Color()
new Color(
color
?):Color
Parameters
• color?: TColorArg
optional in hex or rgb(a) or hsl format or from known color list
Returns
Defined in
Properties
isUnrecognised
isUnrecognised:
boolean
=false
Defined in
Methods
getAlpha()
getAlpha():
number
Gets value of alpha channel for this color
Returns
number
0-1
Defined in
getSource()
getSource():
TRGBAColorSource
Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
Returns
Defined in
overlayWith()
overlayWith(
otherColor
):Color
Overlays color with another color
Parameters
• otherColor: string
| Color
Returns
thisArg
Defined in
setAlpha()
setAlpha(
alpha
):Color
Sets value of alpha channel for this color
Parameters
• alpha: number
Alpha value 0-1
Returns
thisArg
Defined in
setSource()
setSource(
source
):void
Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
Parameters
• source: TRGBAColorSource
Returns
void
Defined in
toBlackWhite()
toBlackWhite(
threshold
):Color
Transforms color to its black and white representation
Parameters
• threshold: number
Returns
thisArg
Defined in
toGrayscale()
toGrayscale():
Color
Transforms color to its grayscale representation
Returns
thisArg
Defined in
toHex()
toHex():
string
Returns color representation in HEX format
Returns
string
ex: FF5555
Defined in
toHexa()
toHexa():
string
Returns color representation in HEXA format
Returns
string
ex: FF5555CC
Defined in
toHsl()
toHsl():
string
Returns color representation in HSL format
Returns
string
ex: hsl(0-360,0%-100%,0%-100%)
Defined in
toHsla()
toHsla():
string
Returns color representation in HSLA format
Returns
string
ex: hsla(0-360,0%-100%,0%-100%,0-1)
Defined in
toRgb()
toRgb():
string
Returns color representation in RGB format
Returns
string
ex: rgb(0-255,0-255,0-255)
Defined in
toRgba()
toRgba():
string
Returns color representation in RGBA format
Returns
string
ex: rgba(0-255,0-255,0-255,0-1)
Defined in
fromHex()
static
fromHex(color
):Color
Returns new color object, when given a color in HEX format
Parameters
• color: string
Color value ex: FF5555
Returns
Static
Member Of
Color
Defined in
fromHsl()
static
fromHsl(color
):Color
Returns new color object, when given a color in HSL format
Parameters
• color: string
Color value ex: hsl(0-260,0%-100%,0%-100%)
Returns
Member Of
Color
Defined in
fromHsla()
static
fromHsla(color
):Color
Returns new color object, when given a color in HSLA format
Parameters
• color: string
Returns
Static
Function
Member Of
Color
Defined in
fromRgb()
static
fromRgb(color
):Color
Returns new color object, when given a color in RGB format
Parameters
• color: string
Color value ex: rgb(0-255,0-255,0-255)
Returns
Member Of
Color
Defined in
fromRgba()
static
fromRgba(color
):Color
Returns new color object, when given a color in RGBA format
Parameters
• color: string
Returns
Static
Function
Member Of
Color
Defined in
parseAngletoDegrees()
static
parseAngletoDegrees(value
):number
Converts a string that could be any angle notation (50deg, 0.5turn, 2rad) into degrees without the ‘deg’ suffix
Parameters
• value: string
ex: 0deg, 0.5turn, 2rad
Returns
number
number in degrees or NaN if inputs are invalid
Static
Member Of
Color
Defined in
sourceFromHex()
static
sourceFromHex(color
):undefined
|TRGBAColorSource
Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in HEX format
Parameters
• color: string
ex: FF5555 or FF5544CC (RGBa)
Returns
undefined
| TRGBAColorSource
source
Static
Member Of
Color
Defined in
sourceFromHsl()
static
sourceFromHsl(color
):undefined
|TRGBAColorSource
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
• color: string
Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
Returns
undefined
| TRGBAColorSource
source
Member Of
Color
See
http://http://www.w3.org/TR/css3-color/#hsl-color
Defined in
sourceFromRgb()
static
sourceFromRgb(color
):undefined
|TRGBAColorSource
Returns array representation (ex: [100, 100, 200, 1]) of a color that’s in RGB or RGBA format
Parameters
• color: string
Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
Returns
undefined
| TRGBAColorSource
source
Member Of
Color