bibliopixel.colors.names module¶
Convert back and forth between colors and string names.
-
bibliopixel.colors.names.
color_to_name
(color, use_hex=False)[source]¶ Parameters: color (tuple) – an RGB 3-tuple of integer colors Returns: a string name for this color name_to_color(color_to_name(c)) == c
is guaranteed to be true (but the reverse is not true, because name_to_color is a many-to-one function).
-
bibliopixel.colors.names.
name_to_color
(name)[source]¶ Parameters: name (str) – a string identifying a color. It might be a color name from the two lists of color names, juce and classic; or it might be a list of numeric r, g, b values separated by commas. Returns: a color as an RGB 3-tuple
-
bibliopixel.colors.names.
to_color
(c)[source]¶ Try to coerce the argument into a color - a 3-tuple of numbers-
-
bibliopixel.colors.names.
toggle
(s)[source]¶ Toggle back and forth between a name and a tuple representation.
Parameters: s (str) – a string which is either a text name, or a tuple-string: a string with three numbers separated by commas Returns: if the string was a text name, return a tuple. If it’s a tuple-string and it corresponds to a text name, return the text name, else return the original tuple-string.