Color Extension
This plugin provides some extension methods for color.
Install with npm
$ npm install @jiaminghi/color
Examples
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)