hbutils.color.base

CSS3 color name and hexadecimal conversion utilities.

This module provides the core mappings for CSS3 named colors and a helper function for converting a CSS3 color name into its hexadecimal representation. The mappings are based on the standard CSS3 color set of 147 named colors.

The module contains:

  • A mapping of CSS3 color names to hexadecimal values.

  • A reverse mapping of hexadecimal values to CSS3 color names.

Note

This module exposes an internal helper for name-to-hex conversion. The helper performs case-insensitive lookups and raises ValueError for unknown names.

Example:

>>> _name_to_hex("red")
'#ff0000'
>>> _name_to_hex("AliceBlue")
'#f0f8ff'