Class: Color

fabric.Color

new Color(color) → {fabric.Color}

Color class The purpose of fabric.Color is to abstract and encapsulate common color operations; fabric.Color is a constructor and creates instances of fabric.Color objects.
Parameters:
Name Type Description
color String optional in hex or rgb(a) or hsl format or from known color list
Source:
Tutorials:
Returns:
thisArg
Type
fabric.Color

Members

(static) colorNameMap

Map of the 148 color names with HEX code
Source:

(static) reHex

Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)
Source:

(static) reHSLa

Regex matching color in HSL or HSLA formats (ex: hsl(200, 80%, 10%), hsla(300, 50%, 80%, 0.5), hsla( 300 , 50% , 80% , 0.5 ))
Source:

(static) reRGBa

Regex matching color in RGB or RGBA formats (ex: rgb(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))
Source:

Methods

(static) fromHex(color) → {fabric.Color}

Returns new color object, when given a color in HEX format
Parameters:
Name Type Description
color String Color value ex: FF5555
Source:
Returns:
Type
fabric.Color

(static) fromHsl(color) → {fabric.Color}

Returns new color object, when given a color in HSL format
Parameters:
Name Type Description
color String Color value ex: hsl(0-260,0%-100%,0%-100%)
Source:
Returns:
Type
fabric.Color

(static) fromHsla(color) → {fabric.Color}

Returns new color object, when given a color in HSLA format
Parameters:
Name Type Description
color String
Source:
Returns:
Type
fabric.Color

(static) fromRgb(color) → {fabric.Color}

Returns new color object, when given a color in RGB format
Parameters:
Name Type Description
color String Color value ex: rgb(0-255,0-255,0-255)
Source:
Returns:
Type
fabric.Color

(static) fromRgba(color) → {fabric.Color}

Returns new color object, when given a color in RGBA format
Parameters:
Name Type Description
color String
Source:
Returns:
Type
fabric.Color

(static) fromSource(source) → {fabric.Color}

Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
Parameters:
Name Type Description
source Array
Source:
Returns:
Type
fabric.Color

(static) sourceFromHex(color) → {Array}

Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format
Parameters:
Name Type Description
color String ex: FF5555 or FF5544CC (RGBa)
Source:
Returns:
source
Type
Array

(static) sourceFromHsl(color) → {Array}

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:
Name Type Description
color String Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)
Source:
See:
Returns:
source
Type
Array

(static) sourceFromRgb(color) → {Array}

Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
Parameters:
Name Type Description
color String Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)
Source:
Returns:
source
Type
Array