Class Color
Defined in: color.class.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Color(color)
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.
|
Field Attributes | Field Name and Description |
---|---|
<static> |
Color.reHex
Regex matching color in HEX format (ex: #FF5555, 010155, aff)
|
<static> |
Color.reRGBa
Regex matching color in RGB or RGBA formats (ex: rgb(0, 0, 0), rgb(255, 100, 10, 0.5), rgb(1,1,1))
|
Method Attributes | Method Name and Description |
---|---|
<static> |
Color.fromHex(color)
Returns new color object, when given a color in HEX format
|
<static> |
Color.fromRgb(color)
Returns new color object, when given a color in RGB format
|
<static> |
Color.fromRgba(color)
Returns new color object, when given a color in RGBA format
|
<static> |
Color.fromSource(source)
Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
|
getAlpha()
Gets value of alpha channel for this color
|
|
Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
|
|
overlayWith(otherColor)
Overlays color with another color
|
|
setAlpha(0-1)
Sets value of alpha channel for this color
|
|
setSource(source)
Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
|
|
<static> |
Color.sourceFromHex(color)
Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format
|
<static> |
Color.sourceFromRgb(color)
Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
|
toBlackWhite(threshold)
Transforms color to its black and white representation
|
|
Transforms color to its grayscale representation
|
|
toHex()
Returns color represenation in HEX format
|
|
toRgb()
Returns color represenation in RGB format
|
|
toRgba()
Returns color represenation in RGBA format
|
Class Detail
Color(color)
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:
- {String} color
- (optional) in hex or rgb(a) format
Field Detail
<static>
Color.reHex
Regex matching color in HEX format (ex: #FF5555, 010155, aff)
<static>
Color.reRGBa
Regex matching color in RGB or RGBA formats (ex: rgb(0, 0, 0), rgb(255, 100, 10, 0.5), rgb(1,1,1))
Method Detail
<static>
{Color}
Color.fromHex(color)
Returns new color object, when given a color in HEX format
- Parameters:
- color
- Returns:
- {Color}
<static>
{Color}
Color.fromRgb(color)
Returns new color object, when given a color in RGB format
- Parameters:
- {String} color
- ex: rgb(0-255,0-255,0-255)
- Returns:
- {Color}
<static>
{Color}
Color.fromRgba(color)
Returns new color object, when given a color in RGBA format
- Parameters:
- {String} color
- Returns:
- {Color}
<static>
{Color}
Color.fromSource(source)
Returns new color object, when given color in array representation (ex: [200, 100, 100, 0.5])
- Parameters:
- source
- Returns:
- {Color}
{Number}
getAlpha()
Gets value of alpha channel for this color
- Returns:
- {Number} 0-1
{Array}
getSource()
Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])
- Returns:
- {Array}
{Color}
overlayWith(otherColor)
Overlays color with another color
- Parameters:
- {String|Color} otherColor
- Returns:
- {Color} thisArg
{Color}
setAlpha(0-1)
Sets value of alpha channel for this color
- Parameters:
- {Number} 0-1
- Returns:
- {Color} thisArg
setSource(source)
Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
- Parameters:
- {Array} source
<static>
{Array}
Color.sourceFromHex(color)
Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in HEX format
- Parameters:
- {String} color
- ex: FF5555
- Returns:
- {Array} source
<static>
{Array}
Color.sourceFromRgb(color)
Returns array represenatation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format
- Parameters:
- {String} color
- ex: rgb(0-255,0-255,0-255)
- Returns:
- {Array} source
{Color}
toBlackWhite(threshold)
Transforms color to its black and white representation
- Parameters:
- threshold
- Returns:
- {Color} thisArg
{Color}
toGrayscale()
Transforms color to its grayscale representation
- Returns:
- {Color} thisArg
{String}
toHex()
Returns color represenation in HEX format
- Returns:
- {String} ex: FF5555
{String}
toRgb()
Returns color represenation in RGB format
- Returns:
- {String} ex: rgb(0-255,0-255,0-255)
{String}
toRgba()
Returns color represenation in RGBA format
- Returns:
- {String} ex: rgba(0-255,0-255,0-255,0-1)