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.

To use ColorManager, you must first initialize it before use:

color_manager = ColorManager()


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.

Closest color name

Finds the closest named color to the given hex value.

Get color by name

Returns the hex and RGB values of a color based on its name.

Last updated

Was this helpful?