> For the complete documentation index, see [llms.txt](https://infinitode-docs.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitode-docs.gitbook.io/documentation/package-documentation/hued-package-documentation/hued-reference/analysis-functions.md).

# Analysis Functions

**Available functions:**

* [`get_temperature`](#get-temperature)`(rgb)`: Determine the temperature of a color based on its RGB values.
* [`is_neutral`](#is-neutral)`(rgb)`: Check if a color is neutral.
* [`brightness`](#brightness)`(rgb)`: Calculate the brightness of a color.
* [`is_pastel`](#is-pastel)`(rgb)`: Check if a color is pastel.
* [`is_muted`](#is-muted)`(rgb)`: Check if a color is muted.
* [`is_vibrant`](#is-vibrant)`(rgb)`: Check if a color is vibrant.
* [`rgb_to_linear`](#rgb-to-linear)`(rgb)`: Convert RGB values to linear RGB.
* [`get_luminance`](#get-luminance)`(rgb)`: Calculate the relative luminance of an RGB color.
* [`get_vibrancy`](#get-vibrancy)`(rgb)`: Calculate the vibrancy of an RGB color.
* [`color_contrast`](#color-contrast)`(color1, color2)`: Calculates the contrast ratio between two colors using their RGB values.
* [`get_text_color_from_background`](#get-text-color-from-background)`(background_color)`:  Determines whether the text should be "light" or "dark" based on the background color.
* [`check_color_quality`](#check-color-quality)`(rgb)`: Evaluates if a color is of 'good quality' for UI/text usage.
* [`simulate_color_blindness`](#simulate-color-blindness)`(rgb, blindness_type="protanopia", intensity=1.0)`: Simulates color blindness on a given RGB color.

***

### Get temperature

Determine the temperature of a color based on its RGB values.

<pre><code>Parameters:
    rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
<strong>    str: "Warm" if the color is warm, "Cool" if cool, or "Neutral" if neither.
</strong></code></pre>

### Is neutral

Check if a color is neutral.

<pre><code>Parameters:
<strong>    rgb (tuple): A tuple containing the RGB values (r, g, b).
</strong>
Returns:
    bool: True if the color is neutral, False otherwise.
</code></pre>

### Brightness

Calculate the brightness of a color.

```
Parameters:
    rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
    float: The brightness of the color as a value between 0 and 1.
```

### Is pastel

Check if a color is pastel.

```
Parameters:
    rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
    bool: True if the color is pastel, False otherwise.
```

### Is muted

Check if a color is muted.

```
Parameters:
    rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
    bool: True if the color is muted, False otherwise.
```

### Is vibrant

Check if a color is vibrant.

```
Parameters:
    rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
    bool: True if the color is vibrant, False otherwise.
```

### RGB to linear

Convert RGB values to linear RGB.

<pre data-overflow="wrap"><code>Parameters:
<strong>    rgb (tuple): A tuple of three integers representing the RGB values (r, g, b), each in the range [0, 255].
</strong>
Returns:
    list: A list of three floats representing the linear RGB values.
</code></pre>

### Get luminance

Calculate the relative luminance of an RGB color.

{% code overflow="wrap" %}

```
Parameters:
    rgb (tuple): A tuple of three integers representing the RGB values (r, g, b), each in the range [0, 255].

Returns:
    float: The calculated relative luminance of the RGB color.
```

{% endcode %}

### Get vibrancy

&#x20;Calculate the vibrancy of an RGB color.

{% code overflow="wrap" %}

```
Parameters:
    rgb (tuple): A tuple of three integers representing the RGB values (r, g, b), each in the range [0, 255].

Returns:
    float: The calculated vibrancy of the RGB color.
```

{% endcode %}

### Color contrast

&#x20;Calculate the vibrancy of an RGB color.

{% code overflow="wrap" %}

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

Returns:
    float: The contrast ratio between the two colors.
```

{% endcode %}

### Get text color from background

&#x20;Determines whether the text should be "light" or "dark" based on the background color.

{% code overflow="wrap" %}

```
Parameters:
    background_color (tuple): The background RGB color as a tuple of three integers (R, G, B).

Returns:
    str: "light" if the background is dark and vibrant, "dark" if the background is bright and muted.
```

{% endcode %}

### Check color quality

Evaluates if a color is of 'good quality' for UI/text usage.

This function simulates a color visibility tester by checking the color's\
contrast ratio against standard black and white backgrounds. A color is\
considered 'good quality' if it meets the WCAG AA standard (contrast ratio >= 4.5)\
against at least one of the backgrounds.

{% code overflow="wrap" %}

```
Parameters:
        rgb (tuple): A tuple containing the RGB values (r, g, b).

Returns:
        dict: A dictionary containing:
            - 'contrast_with_black' (float): Contrast ratio with black.
            - 'contrast_with_white' (float): Contrast ratio with white.
            - 'is_good_quality' (bool): True if legible on black or white.
```

{% endcode %}

### Simulate color blindness

Simulates color blindness on a given RGB color.

{% code overflow="wrap" %}

```
Parameters:
        rgb (tuple): A tuple containing the RGB values (r, g, b).
        blindness_type (str): The type of color blindness to simulate.
        Options: 'protanopia', 'deuteranopia', 'tritanopia', 'achromatopsia'. Default is 'protanopia'.
        intensity (float): The intensity of the simulation (0.0 to 1.0). Default is 1.0 (full simulation).

Returns:
        tuple: A tuple representing the simulated RGB values.
```

{% endcode %}
