This is my color utility library. It helps a lot for converting colors.
Who can use my library?
This library is designed for UX designers that do not know how to code and want a quick and easy way to use.
Supported formats:
- Rgb
- Hsl
- Hex
Working on:
- Xyz
npm install
npm run build
npm run test
npm run start
Initialize your RGB color:
const red = RGB(255, 0, 0)
Initialize your hexa color:
const hex = HEX('FF0000')
Initialize your HSL color:
const hsl = HSL(0, 0.5, 1)
Get your color on string format:
const red = RGB(255, 0, 0).toString() //-> "rgb(255, 0, 0)"
const green = HEX('00FF00').toString() //-> "#00FF00"
const blue = HSL(0.666, 1, 0.5).toString() //-> "hsl(0.666, 1, 0.5)"
Get the color value:
const red = RGB(255, 0, 0).get() //-> [255, 0, 0]
const green = HEX('00FF00').get() //-> '00FF00'
const blue = HSL(0.666, 1, 0.5).get() //-> [0.666, 1, 0.5]
Chainable
Set the color value:
const blue = RGB(255, 0, 0).set(0, 0, 255)
const red = HEX('00FF00').set('FF0000')
const green = HSL(0.666, 1, 0.5).set(0.333, 1, 0.5)
Chainable
Get color value to RGB format:
var red = HEX('FF0000').toRgb().get() //-> [255, 0, 0]
Chainable
Get color value to HEX format:
var red = HSL(0, 0.5, 1).toHex().get() //-> 'FF0000'
Chainable
Get color value to HSL format:
var red = RGB(255, 0, 0).toHsl().get() //-> [0, 0.5, 1]
Return the color format property:
const red = RGB(255, 0, 0).format() //-> "rgb"
const green = HEX('00FF00').format() //-> "hex"
const blue = HSL(0.666, 1, 0.5).format() //-> "hsl"