颜色相关函数。
- Source:
Methods
(static) darkenColor(color, level) → {String}
颜色变深
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
String
|
颜色:Rgb, Hex, Rgba |
level |
Number
|
变深程度:[0, 1] |
Returns:
- Type:
-
String
Rgb 颜色
Example
darkenColor('rgb(40, 40, 40)', 0.2)
// rgb(32, 32, 32)
(static) HexToRgb(str) → {String}
Hex颜色转Rgb
- Source:
Parameters:
Name | Type | Description |
---|---|---|
str |
String
|
Hex 颜色(6位) |
Returns:
- Type:
-
String
Rgb 颜色
Example
HexToRgb('#fff333')
// rbg(255,243,51)
(static) lightnessColor(color, level) → {String}
颜色变浅
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
String
|
颜色:Rgb, Hex, Rgba |
level |
Number
|
变浅程度:[0, 1] |
Returns:
- Type:
-
String
Rgb 颜色
(static) RgbToHex(rgb) → {String}
Rgb 转 Hex
- Source:
Parameters:
Name | Type | Description |
---|---|---|
rgb |
String
|
rgb 颜色 |
Returns:
- Type:
-
String
hex 颜色
Example
RgbToHex('rgb(255,243,51)')
// #fff333
(static) toRgba(color, opacity) → {String}
Rgb 转 Rgba
- Source:
Parameters:
Name | Type | Description |
---|---|---|
color |
String
|
颜色:Rgb 或 Hex |
opacity |
Number
|
透明度 |
Returns:
- Type:
-
String
Rgba 颜色
Example
toRgba('#fff333', 0.6)
// rgba(255, 243, 51, 0.6)
toRgba('rgb(233, 233, 5)', 0.6)
// rgba(233, 233, 5, 0.6)