This is a tool for color management.
npm i -s @urpflanze/color
You can convert this format:
hsla(360, 100%, 100%, 1)
stringrgb(255, 255, 255, 1)
string0xFFFFFF
-0xFFFFFFFF
number, number with alpha#FFF
-#FFFFFF
string
import { parseColor } from '@urpflanze/color'
// Or
// const { parseColor } = require('@urpflanze/color')
const color = parseColor('#1fcc9a')
console.log(color)
// Output
// { type: 'rgb', r: 31, g: 204, b: 154, alpha: 1 }
Conversions
import { hslToRgb /* rgbToHsl */ } from '@urpflanze/color'
const { r, g, b } = hslToRgb('hsl(163, 74%, 46%)')
console.log([r, g, b])
// Output
// [31, 204, 154]
Parsing and conversions
import { parseColorAndConvert } from '@urpflanze/color'
const converted = hslToRgb('hsl(163, 74%, 46%)')
console.log(converted)
// Output
// {
// r: 31, g: 204, b: 154
// h: 163, s: 74, l: 46
// alpha: 1
// }