hex_to_rgba
Convert hex color code to RGBA string format.
Converts a hexadecimal color string (with or without ‘#’ prefix) to an RGBA formatted string. Supports both shorthand (#ddd) and full (#888888) hex notation.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| hex_color | str | Hexadecimal color string. Accepts formats: ‘#rrggbb’, ‘rrggbb’, ‘#rgb’, or ‘rgb’ where r, g, b are hex digits. | required |
| opacity | float or None | Opacity value between 0.0 (transparent) and 1.0 (opaque). If None, defaults to 1.0. | None |
Returns
| Name | Type | Description |
|---|---|---|
| str | RGBA formatted string in the form ‘rgba(r, g, b, a)’ where r, g, b are integers 0-255 and a is the opacity. |
Examples
Notes
Shorthand hex notation (e.g., ‘#ddd’) is automatically expanded to full notation (‘#dddddd’) before conversion.