new Color(color) → {fabric.Color}
颜色类
织物的用途。色彩是对常见色彩操作的抽象和封装;
织物。Color是一个构造函数,创建fabric的实例。颜色对象。
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 可选的十六进制或rgb(a)或HSL格式或从已知的颜色列表 |
- Source:
- Tutorials:
Returns:
thisArg
- Type
- fabric.Color
Members
(static) colorNameMap
地图的148个颜色名称与十六进制代码
(static) reHex
HEX格式的正则匹配颜色(例如:#FF5544CC, #FF5555, 010155, aff)
(static) reHSLa
HSL或HSLA格式的正则表达式匹配颜色(例如:HSL (200,80%, 10%), HSLA (300,50%, 80%, 0.5), HSLA (300,50%, 80%, 0.5))
(static) reRGBa
RGB或RGBA格式的正则表达式匹配颜色(例如: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))
Methods
(static) fromHex(color) → {fabric.Color}
当以HEX格式给出颜色时,返回新的颜色对象
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 颜色值例如:FF5555 |
Returns:
- Type
- fabric.Color
(static) fromHsl(color) → {fabric.Color}
当给定HSL格式的颜色时,返回新的颜色对象
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 颜色值ex: hsl(0- 26,0% -100%,0%-100%) |
Returns:
- Type
- fabric.Color
(static) fromHsla(color) → {fabric.Color}
当给定HSLA格式的颜色时,返回新的颜色对象
Parameters:
Name | Type | Description |
---|---|---|
color |
String |
Returns:
- Type
- fabric.Color
(static) fromRgb(color) → {fabric.Color}
当给定RGB格式的颜色时,返回新的颜色对象
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 颜色值ex: rgb(0-255,0-255,0-255) |
Returns:
- Type
- fabric.Color
(static) fromRgba(color) → {fabric.Color}
当给定RGBA格式的颜色时,返回新的颜色对象
Parameters:
Name | Type | Description |
---|---|---|
color |
String |
Returns:
- Type
- fabric.Color
(static) fromSource(source) → {fabric.Color}
当以数组形式给出颜色时,返回新的颜色对象(例如:[200,100,100,0.5])
Parameters:
Name | Type | Description |
---|---|---|
source |
Array |
Returns:
- Type
- fabric.Color
(static) sourceFromHex(color) → {Array}
返回HEX格式颜色的数组表示形式(例如:[100,100,200,1])
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 例:FF5555或FF5544CC (RGBa) |
Returns:
source
- Type
- Array
(static) sourceFromHsl(color) → {Array}
返回HSL或HSLA格式的颜色的数组表示(例如:[100,100,200,1])。
改编自https://github.com/mjijackson
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 颜色值例:高速逻辑(0 - 360,0% - -100%,0% - -100%)或hsla (0 - 360, 0% - -100%, 0% - -100%, 0 - 1) |
Returns:
source
- Type
- Array
(static) sourceFromRgb(color) → {Array}
返回RGB或RGBA格式的颜色的数组表示(例如:[100,100,200,1])
Parameters:
Name | Type | Description |
---|---|---|
color |
String | 颜色值的前女友:rgb (0 - 255 0 - 255 0 - 255), rgb (0% -100% 0% -100% 0% -100%) |
Returns:
source
- Type
- Array
getAlpha() → {Number}
获取此颜色的alpha通道的值
Returns:
0-1
- Type
- Number
getSource() → {Array}
返回该颜色的source(其中source是数组表示;例:[200,200,100,1])
Returns:
- Type
- Array
overlayWith(otherColor) → {fabric.Color}
用另一种颜色叠加颜色
Parameters:
Name | Type | Description |
---|---|---|
otherColor |
String | fabric.Color |
Returns:
thisArg
- Type
- fabric.Color
setAlpha(alpha) → {fabric.Color}
为这个颜色设置alpha通道的值
Parameters:
Name | Type | Description |
---|---|---|
alpha |
Number | Alpha值0-1 |
Returns:
thisArg
- Type
- fabric.Color
setSource(source)
设置该颜色的source(其中source是一个数组表示;例:[200,200,100,1])
Parameters:
Name | Type | Description |
---|---|---|
source |
Array |
toBlackWhite(threshold) → {fabric.Color}
将颜色转换为其黑白表示
Parameters:
Name | Type | Description |
---|---|---|
threshold |
Number |
Returns:
thisArg
- Type
- fabric.Color
toGrayscale() → {fabric.Color}
将颜色转换为其灰度表示
Returns:
thisArg
- Type
- fabric.Color
toHex() → {String}
以HEX格式返回颜色表示
Returns:
ex: FF5555
- Type
- String
toHexa() → {String}
返回HEXA格式的颜色表示
Returns:
ex: FF5555CC
- Type
- String
toHsl() → {String}
返回HSL格式的颜色表示
Returns:
ex: hsl(0-360,0%-100%,0%-100%)
- Type
- String
toHsla() → {String}
返回HSLA格式的颜色表示
Returns:
ex: hsla(0-360,0%-100%,0%-100%,0-1)
- Type
- String
toRgb() → {String}
返回RGB格式的颜色表示
Returns:
ex: rgb(0-255,0-255,0-255)
- Type
- String
toRgba() → {String}
返回RGBA格式的颜色表示
Returns:
ex: rgba(0-255,0-255,0-255,0-1)
- Type
- String