parseHexToHSL(hex: string): null | Array<number>
Attempts to parse a string as a RGB(A) hex color code into a HSL(A) array.
Examples
Parsing a long form RGBA hex code with alpha:
const hex = '#FF000069' // Red const hsl = parseHexToHSL(hex) console.debug(hsl) // [ 0 , 100 , 50 , 69 ]
Parsing a short form RGB hex code without #:
const hex = 'F00' // Red const hsl = parseHexToHSL(hex) console.debug(hsl) // [ 0 , 100 , 50 ]
Parsing an invalid hex color code:
const hex = 'Invalid' const hsl = parseHexToHSL(hex) console.debug(hsl) // null
hex: string
String possibly containing a hex RGB(A) color code.