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 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 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 (has the minimal Euclidean Distance) to the provided input.

  3. Return 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 colorcompass

🎨 Basic Usage

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

from colorcompass import get_color_name

# Define your target color as an RGB list or a hexadecimal string
target_color_rgb = [152, 251, 152]
target_color_hex = "#98FB98"

# Use the function to find the color name
color_name_rgb = get_color_name(target_color_rgb)
color_name_hex = get_color_name(target_color_hex)

# Print the found color name
print(f"Color to RGB{tuple(target_color_rgb)}: {color_name_rgb}")
print(f"Color to {target_color_hex}: {color_name_hex}")

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

🙏 Acknowledgements

Special thanks to xkcd by Randall Munroe for providing an extensive collection of nearly 1000 color names and their respective codes, which was pivotal in developing this project. Although modifications were made to the original list, it served as a foundational resource in building the ColorCompass library.

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-1.2.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

colorcompass-1.2.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for colorcompass-1.2.1.tar.gz
Algorithm Hash digest
SHA256 38cf6b140a5f9fba0e15359fa9d50dec1648f77aa3fba290793ec489254324cd
MD5 e28d13124fb1e0a2b9a5865db4bd5bba
BLAKE2b-256 981932e062bab3880cccdd001a8cb97ccf6e5bd8ceaa47e29fdf79410b2011a7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for colorcompass-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5177331f30446fdee63c5852ec119ba0ba988bcf5a6776ad9283584e52522237
MD5 b623f31ce2e09639407fad60299d9889
BLAKE2b-256 50bf07971adeed0c0b7b1990f54b036e8e7e1c6aafb763bf4b41a41b7dcb3e09

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