Colors Functions
Available functions:
ColorManager.__init__()
: Initializes the ColorManager with a predefined list of colors.ColorManager.
hex_to_rgb
(hex_value)
: Converts a hex color code to an RGB tuple.ColorManager.
rgb_to_hex
(r, g, b)
: Converts RGB values to a hex color code.ColorManager.
closest_color_name
(hex_value)
: Finds the closest named color to the given hex value.ColorManager.
get_color_by_name
(name)
: Returns the hex and RGB values of a color based on its name.
Hex to RGB
Converts a hex color code to an RGB tuple.
Parameters:
hex_value (str): A string representing a hex color code (e.g., "#FFFFFF").
Returns:
tuple: A tuple representing the RGB values (e.g., (255, 255, 255)).
RGB to hex
Converts RGB values to a hex color code.
Parameters:
r (int): Red value (0-255).
g (int): Green value (0-255).
b (int): Blue value (0-255).
Returns:
str: A string representing the hex color code (e.g., "#FFFFFF").
Closest color name
Finds the closest named color to the given hex value.
Parameters:
hex_value (str): A string representing a hex color code (e.g., "#FFFFFF").
Returns:
str: The name of the closest color from the list.
Get color by name
Returns the hex and RGB values of a color based on its name.
Parameters:
name (str): The name of the color to look up (e.g., "red").
Returns:
dict: A dictionary containing:
- 'Name' (str): The color name in title case.
- 'Hex' (str): The uppercase hex value (e.g., "#FF0000").
- 'RGB' (tuple): The RGB values (e.g., (255, 0, 0)).
Last updated
Was this helpful?