ENGLISH
Color Extension
这是一个提供如下几个方法的颜色插件。
附录
npm安装
$ npm install @jiaminghi/color
使用
import { toHex } from '@jiaminghi/color'
快速体验
<script src="http://lib.jiaminghi.com/color/color.map.js"></script>
<script src="http://lib.jiaminghi.com/color/color.min.js"></script>
<script>
const { darken, lighten } = window.color
</script>
示例
darken
function darken (color, percent) {
}
const before = '#3080E8'
const after = darken(color, 20)
lighten
function lighten (color, percent) {
}
const before = '#3080E8'
const after = lighten(color, 20)
fade
function fade (color, percent) {
}
const before = '#3080E8'
const after = lighten(color, 20)
toHex
function toHex (color) {
}
const before = 'rgb(48,128,232)'
const after = toHex(before)
toRgb
function toRgb (color, opacity) {
}
const before = '#3080E8'
const after1 = toRgb(before)
const after2 = toRgb(before, 0.2)
getOpacity
function getOpacity (color) {
}
const color1 = '#3080E8'
const color2 = 'rgba(48,128,232,0.2)'
const opacity1 = getOpacity(color1)
const opacity2 = getOpacity(color2)
getRgbValue
function getRgbValue (color) {
}
const color = '#3080E8'
const rgbValue = getRgbValue(color)
getRgbaValue
function getRgbaValue (color) {
}
const color1 = '#3080E8'
const color2 = 'rgba(48,128,232,0.2)'
const rgbaValue1 = getRgbaValue(color1)
const rgbaValue2 = getRgbaValue(color2)
getColorFromRgbValue
function getColorFromRgbValue (value) {
}
const value1 = [48, 128, 232]
const value2 = [48, 128, 232, 0.2]
const color1 = getColorFromRgbValue(value1)
const color2 = getColorFromRgbValue(value2)
颜色关键字