from colorspace import check_hex_colors
check_hex_colors("#ff003311")['#FF003311']
Documentation built with Python 3.11.10, pyp2qmd 0.1.1 and quarto 1.5.57 on GitHub.
Valid hex colors are three digit hex colors (e.g., #F00), six digit hex colors (e.g., #FF00FF), or six digit colors with additional transparency (eight digit representation) or None. If the inputs do not match one of these hex representations matplotlib.color.to_hex will be called. This allows to also convert standard colors such as "0", "black", or "magenta" into their corresponding hex representation.
check_hex_colors(colors)
colorsstr, list, numpy.ndarray
numpy.ndarray it will be flattened to 1-dimensional if needed.
list: Returns a list (length 1 or more) in case all values provided are valid hex colors or None. Three digit colors will be expanded to six digit colors, all upper case. Else the function will raise a ValueError.
['#FF00FF', '#0000FF', '#00FFFF', '#FF003311']
['#FFFFFF', '#000000', '#000000', '#0000FF', '#FF00FF']
ValueError: In case colors is a list but does not only contain strnigs.
TypeError: If colors is neither str or list of str.
ValueError: If at least one of the colors is an invalid hex color.