Analysis Functions

Available functions:

  • get_temperature(rgb): Determine the temperature of a color based on its RGB values.

  • is_neutral(rgb): Check if a color is neutral.

  • brightness(rgb): Calculate the brightness of a color.

  • is_pastel(rgb): Check if a color is pastel.

  • is_muted(rgb): Check if a color is muted.

  • is_vibrant(rgb): Check if a color is vibrant.

  • rgb_to_linear(rgb): Convert RGB values to linear RGB.

  • get_luminance(rgb): Calculate the relative luminance of an RGB color.

  • get_vibrancy(rgb): Calculate the vibrancy of an RGB color.

  • color_contrast(color1, color2): Calculates the contrast ratio between two colors using their RGB values.

  • get_text_color_from_background(background_color): Determines whether the text should be "light" or "dark" based on the background color.


Get temperature

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

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

Returns:
    str: "Warm" if the color is warm, "Cool" if cool, or "Neutral" if neither.

Is neutral

Check if a color is neutral.

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

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

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.

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

Returns:
    list: A list of three floats representing the linear RGB values.

Get luminance

Calculate the relative luminance of an RGB color.

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.

Get vibrancy

Calculate the vibrancy of an RGB color.

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.

Color contrast

Calculate the vibrancy of an RGB color.

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.

Get text color from background

Determines whether the text should be "light" or "dark" based on the background color.

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.

Last updated