HexToRGB
Color
stable
Convert a hexadecimal colour string to an sRGB object. Accepts 3-, 4-, 6- and 8-character hex values, with or without a leading "#".
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- hexrequiredTHex
- Hexadecimal colour string. Short forms (3 or 4 chars) are expanded by doubling each digit.
API
Return value
The value returned by this util.
- sRGB colour object with r, g, b in [0, 255]. Alpha is provided as a decimal in [0, 1] when the hex string contains an alpha channel, otherwise undefined.
Usage
Examples
Ready-to-paste usage snippets.
Parse a 6-digit hex colour