hexToRgb
Parses a hex color string (#rgb, #rgba, #rrggbb, #rrggbbaa — the
leading # is optional) into its RGB(A) channels.
Available since next
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
hex | string | The hex color string to parse |
Returns
Section titled “Returns”RgbColor | null — The parsed color, or null if hex is not a valid hex color
Examples
Section titled “Examples”Parse a hex color into RGB channels
Section titled “Parse a hex color into RGB channels”The leading # is optional; shorthand 3/4-digit forms are also supported.
Returns null for an invalid color
Section titled “Returns null for an invalid color”Lets you branch on parse failure instead of getting a garbage color.
