Skip to main content

A brief description of your project.

Project description

ColorCompass

Color Compass Logo


Overview

ColorCompass is a Python library designed to efficiently find the closest named color to a given RGB value by using an efficient Euclidean distance calculation across a range of predefined colors.

How it Works

The Euclidean Distance Calculation

The crux of ColorCompass lies in utilizing the Euclidean Distance formula to find the closest matching color name for a given RGB input. Given an RGB value, the Euclidean Distance between two points (color values, in our context) in a three-dimensional space (R, G, B) is calculated as:

Distance = √(R_2 - R_1)^2 + (G_2 - G_1)^2 + (B_2 - B_1)^2

Here,

  • (R_1, G_1, B_1) and (R_2, G_2, B_2) are the RGB values of the two colors being compared.
  • The formula basically measures the straight-line distance between two points in a 3D space (your two colors, in the RGB color space).

The Algorithmic Approach

  1. Input Color Value: A user inputs an RGB color value that they'd like to map to a named color.

  2. Distance Calculation: For the input color, ColorCompass calculates the Euclidean Distance between the input RGB value and all stored RGB values in the library's color database, effectively identifying which stored color is closest (has the minimal Euclidean Distance) to the provided input.

  3. Return Closest Color: The algorithm identifies the color name associated with the RGB value in the database that has the smallest Euclidean Distance to the input color. This color name is returned to the user as the closest match.

🚀 Installation

You can install ColorCompass using pip:

pip install color-compass

🎨 Basic Usage

To find the closest color name for a given RGB value, simply use the find_closest_color function as follows:

from colorcompass import find_closest_color

# Define your target color as an RGB list
target_color = [152, 251, 152]

# Use the function to find the closest color name
closest_color_name = find_closest_color(target_color)

# Print the found color name
print(closest_color_name)

Full Example

from colorcompass import find_closest_color

def main():
    # Define some target colors
    target_colors = [
        [152, 251, 152],
        [70, 130, 180],
        [255, 0, 0]
    ]
    
    # Find and print the closest color name for each target color
    for color in target_colors:
        print(f"Closest color to RGB{tuple(color)} is {find_closest_color(color)}")

if __name__ == "__main__":
    main()

📄 License

ColorCompass is licensed under the MIT License. See the LICENSE file for more details.

🙌 Contributing

Contributions are welcome! Please read the CONTRIBUTING file for details on our code of conduct and the process for submitting pull requests.

📞 Contact

If you have questions or issues, please open an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colorcompass-0.1.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

colorcompass-0.1.3-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file colorcompass-0.1.3.tar.gz.

File metadata

  • Download URL: colorcompass-0.1.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for colorcompass-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d08a0bc2e28b620684d199c87823bca278f6869e154fbcc992d9413741a0cc3a
MD5 b49a92b9ed257f6f87aedb4310723bce
BLAKE2b-256 7928ba5f6703841f8bcb2a51079c1d203bb7f8f365f3de6650afdbca9bbca047

See more details on using hashes here.

File details

Details for the file colorcompass-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: colorcompass-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for colorcompass-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72e8274ccba21728d5c21ffd4e7930c1c58d56bb3fe2f0af4aabca93c3490c21
MD5 783f9e8745366ee917ba8f160f47eea2
BLAKE2b-256 6e13f1d39030e3e8e153397e2b57f4f3a7b8d1119b9cf7a1b92227ffe54eee67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page