# Colors Functions

**Available functions:**

* `ColorManager.__init__()`: Initializes the ColorManager with a predefined list of colors.
* `ColorManager.`[`hex_to_rgb`](#hex-to-rgb)`(hex_value)`: Converts a hex color code to an RGB tuple.
* `ColorManager.`[`rgb_to_hex`](#rgb-to-hex)`(r, g, b)`: Converts RGB values to a hex color code.
* `ColorManager.`[`closest_color_name`](#closest-color-name)`(hex_value)`: Finds the closest named color to the given hex value.
* `ColorManager.`[`get_color_by_name`](#get-color-by-name)`(name)`: Returns the hex and RGB values of a color based on its name.

{% hint style="info" %}
To use **ColorManager**, you must first initialize it before use:

```python
color_manager = ColorManager()
```

{% endhint %}

***

### Hex to RGB

Converts a hex color code to an RGB tuple.

<pre><code>Parameters:
    hex_value (str): A string representing a hex color code (e.g., "#FFFFFF").

Returns:
<strong>    tuple: A tuple representing the RGB values (e.g., (255, 255, 255)).
</strong></code></pre>

### 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.

<pre><code>Parameters:
    name (str): The name of the color to look up (e.g., "red").

Returns:
    dict: A dictionary containing:
<strong>        - 'Name' (str): The color name in title case.
</strong>        - 'Hex' (str): The uppercase hex value (e.g., "#FF0000").
        - 'RGB' (tuple): The RGB values (e.g., (255, 0, 0)).
</code></pre>
