# Conversions Functions

**Available functions:**

* [`rgb_to_hex`](#rgb-to-hex)`(r, g, b)`: Converts RGB to HEX.
* [`hex_to_rgb`](#hex-to-rgb)`(hex_value)`: Converts HEX to RGB.
* [`rgb_to_hsl`](#rgb-to-hsl)`(r, g, b)`: Converts RGB to HSL.
* [`hsl_to_rgb`](#hsl-to-rgb)`(h, s, l)`: Converts HSL to RGB.
* [`rgb_to_hsv`](#rgb-to-hsv)`(r, g, b)`: Converts RGB to HSV.
* [`hsv_to_rgb`](#hsv-to-rgb)`(h, s, v)`: Converts HSV to RGB.
* [`rgb_to_cmyk`](#rgb-to-cmyk)`(r, g, b)`: Converts RGB to CMYK.
* [`cmyk_to_rgb`](#cmyk-to-rgb)`(c, m, y, k)`: Converts CMYK to RGB.
* [`hex_to_hsl`](#hex-to-hsl)`(hex_value)`: Converts HEX to HSL.
* [`hex_to_hsv`](#hex-to-hsv)`(hex_value)`: Converts HEX to HSV.
* [`hex_to_cmyk`](#hex-to-cmyk)`(hex_value)`: Converts HEX to CMYK.
* [`hsl_to_hex`](#hsl-to-hex)`(hsl)`: Converts HSL to HEX.
* [`hsl_to_hsv`](#hsl-to-hsv)`(hsl)`: Converts HSL to HSV.
* [`hsl_to_cmyk`](#hsl-to-cmyk)`(hsl)`: Converts HSL to CMYK.
* [`hsv_to_hex`](#hsv-to-hex)`(hsv)`: Converts HSV to HEX.
* [`hsv_to_hsl`](#hsv-to-hsl)`(hsv)`: Converts HSV to HSL.
* [`hsv_to_cmyk`](#hsv-to-cmyk)`(hsv)`: Converts HSV to CMYK.
* [`cmyk_to_hex`](#cmyk-to-hex)`(cmyk)`: Converts CMYK to HEX.
* [`cmyk_to_hsl`](#cmyk-to-hsl)`(cmyk)`: Converts CMYK to HSL.
* [`cmyk_to_hsv`](#cmyk-to-hsv)`(cmyk)`: Converts CMYK to HSV.
* [`rgb_to_xyz`](#rgb-to-xyz)`(r, g, b)`: Converts RGB to XYZ.
* [`xyz_to_rgb`](#xyz-to-rgb)`(x, y, z)`: Converts XYZ to RGB.
* [`xyz_to_cmyk`](#xyz-to-cmyk)`(xyz)`: Converts XYZ to CMYK.
* [`xyz_to_hex`](#xyz-to-hex)`(xyz)`: Converts XYZ to HEX.
* [`xyz_to_hsl`](#xyz-to-hsl)`(xyz)`: Converts XYZ to HSL.
* [`xyz_to_hsv`](#xyz-to-hsv)`(xyz)`: Converts XYZ to HSV.
* [`hex_to_xyz`](#hex-to-xyz)`(hex)`: Converts HEX to XYZ.
* [`hsl_to_xyz`](#hsl-to-xyz)`(hsl)`: Converts HSL to XYZ.
* [`hsv_to_xyz`](#hsv-to-xyz)`(hsv)`: Converts HSV to XYZ.
* [`cmyk_to_xyz`](#cmyk-to-xyz)`(cmyk)`: Converts CMYK to XYZ.
* [`blend_colors`](#blend-colors)`(color1, color2, ratio=0.5)`: Blends two colors in the RGB format using the specified ratio.

***

### RGB to HEX

Converts RGB to HEX

```
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").
```

### HEX to RGB

Converts HEX to RGB

```
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 HSL

Converts RGB to HSL.

```
Parameters:
        r (int): Red value (0-255).
        g (int): Green value (0-255).
        b (int): Blue value (0-255).

Returns:
        tuple: A tuple representing the HSL values (h, s, l) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               l (float) is lightness in the range [0, 1].
```

### HSL to RGB

Converts HSL to RGB.

```
Parameters:
        h (float): Hue in the range [0, 360).
        s (float): Saturation in the range [0, 1].
        l (float): Lightness in the range [0, 1].

Returns:
        tuple: A tuple representing the RGB values (0-255).
```

### RGB to HSV

Converts RGB to HSV.

```
Parameters:
        r (int): Red value (0-255).
        g (int): Green value (0-255).
        b (int): Blue value (0-255).

Returns:
        tuple: A tuple representing the HSV values (h, s, v) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               v (float) is value in the range [0, 1].
```

### HSV to RGB

Converts HSV to RGB.

```
Parameters:
        h (float): Hue in the range [0, 360).
        s (float): Saturation in the range [0, 1].
        v (float): Value in the range [0, 1].

Returns:
        tuple: A tuple representing the RGB values (0-255).
```

### RGB to CMYK

Converts RGB to CMYK.

```
Parameters:
        r (int): Red value (0-255).
        g (int): Green value (0-255).
        b (int): Blue value (0-255).

Returns:
        tuple: A tuple representing the CMYK values (c, m, y, k) where
               c (float) is cyan in the range [0, 1],
               m (float) is magenta in the range [0, 1],
               y (float) is yellow in the range [0, 1],
               k (float) is key/black in the range [0, 1].
```

### CMYK to RGB

Converts CMYK to RGB.

```
Parameters:
        c (float): Cyan in the range [0, 1].
        m (float): Magenta in the range [0, 1].
        y (float): Yellow in the range [0, 1].
        k (float): Key/black in the range [0, 1].

Returns:
        tuple: A tuple representing the RGB values (0-255).
```

### HEX to HSL

Converts HEX to HSL.

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

Returns:
        tuple: A tuple representing the HSL values (h, s, l) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               l (float) is lightness in the range [0, 1].
```

### HEX to HSV

Converts HEX to HSV.

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

Returns:
        tuple: A tuple representing the HSV values (h, s, v) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               v (float) is value in the range [0, 1].
```

### HEX to CMYK

Converts HEX to CMYK.

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

Returns:
        tuple: A tuple representing the CMYK values (c, m, y, k) where
               c (float) is cyan in the range [0, 1],
               m (float) is magenta in the range [0, 1],
               y (float) is yellow in the range [0, 1],
               k (float) is key/black in the range [0, 1].
```

### HSL to HEX

Converts HSL to HEX.

```
Parameters:
        hsl_value (tuple): A tuple representing the HSL values (h, s, l) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           l (float) is lightness in the range [0, 1].

Returns:
        str: A string representing the hex color code (e.g., "#FFFFFF").

Raises:
        ValueError: If the HSL values are out of range.
```

### HSL to HSV

Converts HSL to HSV.

```
Parameters:
        hsl_value (tuple): A tuple representing the HSL values (h, s, l) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           l (float) is lightness in the range [0, 1].

Returns:
        tuple: A tuple representing the HSV values (h, s, v) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               v (float) is value in the range [0, 1].

Raises:
        ValueError: If the HSL values are out of range.
```

### HSL to CMYK

Converts HSL to CMYK.

```
Parameters:
        hsl_value (tuple): A tuple representing the HSL values (h, s, l) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           l (float) is lightness in the range [0, 1].

Returns:
        tuple: A tuple representing the CMYK values (c, m, y, k) where
               c (float) is cyan in the range [0, 1],
               m (float) is magenta in the range [0, 1],
               y (float) is yellow in the range [0, 1],
               k (float) is key/black in the range [0, 1].

Raises:
        ValueError: If the HSL values are out of range.
```

### HSV to HEX

Converts HSV to HEX.

```
Parameters:
        hsv_value (tuple): A tuple representing the HSV values (h, s, v) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           v (float) is value in the range [0, 1].

Returns:
        str: A string representing the hex color code (e.g., "#FFFFFF").

Raises:
        ValueError: If the HSV values are out of range.
```

### HSV to HSL

Converts HSV to HSL.

```
Parameters:
        hsv_value (tuple): A tuple representing the HSV values (h, s, v) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           v (float) is value in the range [0, 1].

Returns:
        tuple: A tuple representing the HSL values (h, s, l) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               l (float) is lightness in the range [0, 1].

Raises:
        ValueError: If the HSV values are out of range.
```

### HSV to CMYK

Converts HSV to CMYK.

```
Parameters:
        hsv_value (tuple): A tuple representing the HSV values (h, s, v) where
                           h (float) is hue in the range [0, 360),
                           s (float) is saturation in the range [0, 1],
                           v (float) is value in the range [0, 1].

Returns:
        tuple: A tuple representing the CMYK values (c, m, y, k) where
               c (float) is cyan in the range [0, 1],
               m (float) is magenta in the range [0, 1],
               y (float) is yellow in the range [0, 1],
               k (float) is key/black in the range [0, 1].

Raises:
        ValueError: If the HSV values are out of range.
```

### CMYK to HSV

Converts CMYK to HSV.

```
Parameters:
        cmyk_value (tuple): A tuple representing the CMYK values (c, m, y, k) where
                            c (float) is cyan in the range [0, 1],
                            m (float) is magenta in the range [0, 1],
                            y (float) is yellow in the range [0, 1],
                            k (float) is key/black in the range [0, 1].

Returns:
        tuple: A tuple representing the HSV values (h, s, v) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               v (float) is value in the range [0, 1].

Raises:
        ValueError: If the CMYK values are out of range.
```

### CMYK to HSL

Converts CMYK to HSL.

```
Parameters:
        cmyk_value (tuple): A tuple representing the CMYK values (c, m, y, k) where
                            c (float) is cyan in the range [0, 1],
                            m (float) is magenta in the range [0, 1],
                            y (float) is yellow in the range [0, 1],
                            k (float) is key/black in the range [0, 1].

Returns:
        tuple: A tuple representing the HSL values (h, s, l) where
               h (float) is hue in the range [0, 360),
               s (float) is saturation in the range [0, 1],
               l (float) is lightness in the range [0, 1].

Raises:
        ValueError: If the CMYK values are out of range.
```

### CMYK to HEX

Converts CMYK to HEX.

```
Parameters:
        cmyk_value (tuple): A tuple representing the CMYK values (c, m, y, k) where
                            c (float) is cyan in the range [0, 1],
                            m (float) is magenta in the range [0, 1],
                            y (float) is yellow in the range [0, 1],
                            k (float) is key/black in the range [0, 1].

Returns:
        str: A string representing the hex color code (e.g., "#FFFFFF").

Raises:
        ValueError: If the CMYK values are out of range.
```

### RGB to XYZ

Converts RGB to XYZ.

```
Parameters:
        r (int): Red component, in the range [0, 255].
        g (int): Green component, in the range [0, 255].
        b (int): Blue component, in the range [0, 255].

Returns:
        tuple: A tuple representing the XYZ values (x, y, z), where:
               x, y, z (float): Correspond to the CIE 1931 color space.

Raises:
        ValueError: If any RGB value is out of range.
```

### XYZ to RGB

Converts XYZ to RGB.

```
Parameters:
        x (float): X component of the XYZ color space.
        y (float): Y component of the XYZ color space.
        z (float): Z component of the XYZ color space.

Returns:
        tuple: A tuple representing the RGB values (r, g, b), where:
               r, g, b (int): Red, Green, and Blue components, each in the range [0, 255].

Raises:
        ValueError: If any resulting RGB values are outside the valid range after conversion.
```

### HEX to XYZ

Converts HEX to XYZ.

```
Parameters:
        hex_value (str): A hexadecimal color code (e.g., '#RRGGBB').

Returns:
        tuple: A tuple representing the XYZ values (x, y, z).
```

### XYZ to HEX

Converts XYZ to HEX.

```
Parameters:
        xyz_value (tuple): A tuple of XYZ values (x, y, z).

Returns:
        str: A hexadecimal color code (e.g., '#RRGGBB').
```

### HSL to XYZ

Converts HSL to XYZ.

```
Parameters:
        hsl_value (tuple): A tuple representing the HSL values (h, s, l).

Returns:
        tuple: A tuple representing the XYZ values (x, y, z).
```

### XYZ to HSL

Converts XYZ to HSL.

```
Parameters:
        xyz_value (tuple): A tuple of XYZ values (x, y, z).

Returns:
        tuple: A tuple representing the HSL values (h, s, l).
```

### HSV to XYZ

Converts HSV to XYZ.

```
Parameters:
        hsv_value (tuple): A tuple representing the HSV values (h, s, v).

Returns:
        tuple: A tuple representing the XYZ values (x, y, z).
```

### XYZ to HSV

Converts XYZ to HSV.

```
Parameters:
        xyz_value (tuple): A tuple of XYZ values (x, y, z).

Returns:
        tuple: A tuple representing the HSV values (h, s, v).
```

### CMYK to XYZ

Converts CMYK to XYZ.

```
Parameters:
        cmyk_value (tuple): A tuple of CMYK values (c, m, y, k).

Returns:
        tuple: A tuple representing the XYZ values (x, y, z).
```

### XYZ to CMYK

Converts XYZ to CMYK.

```
Parameters:
        xyz_value (tuple): A tuple of XYZ values (x, y, z).

Returns:
        tuple: A tuple representing the CMYK values (c, m, y, k).
```

### Blend colors

Blends two colors in the RGB format using the specified ratio.

```
Parameters:
        color1 (tuple): The first RGB color as a tuple of three integers (R, G, B).
        color2 (tuple): The second RGB color as a tuple of three integers (R, G, B).
        ratio (float, optional): The ratio to blend the colors. A value of 0.5 will
                                 blend both colors equally. Values closer to 0 will
                                 give more weight to `color1`, and values closer to
                                 1 will favor `color2`. Default is 0.5.

Returns:
        tuple: The blended color as an RGB tuple of three integers.

Example:
        >>> blend_colors((255, 0, 0), (0, 0, 255), 0.5)
        (127, 0, 127)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitode-docs.gitbook.io/documentation/package-documentation/hued-package-documentation/hued-reference/conversions-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
