Please sign in to access this page
You do your style, we make it accessible.
Like, have you ever made your site look super aesthetic and then someone’s like “uhh, I can’t read this”? Same.
CM-Colors takes your color combos and makes just-enough tweaks so they still look good, but now it's easier on the eyes to read - aka passes accessibility contrast ratio :>
A mix of math x color science to make it happen ( Think gradient descent, binary search, oklch color space ) - Checkout the Technical README if interested
No followers yet
Once you ship this you can't edit the description of the project, but you'll be able to add more devlogs and re-ship it as you add new features!
And it's donee people!! Finally stable version is up for release and now it takes any hex or rgb strings too!!
Uff finally functional stuff are done for v0.1.0 refactor
The core function tunecolors() takes 2 values - a text color, bg and basically sees if it's readable enough aka is the contrast high enough ?
If yes, just returns the original text color, isaccessible=True
else is where our magic comes in,
At first I was trying to brute force and search the color space of the text color, such that the tuned color isnt too different but just enough for it to be accessible
Now we use binary search x gradient descent
- First try to play with lightness of a color to see if it's enough
- If not, use gradient descent to maximise the contrast and minimise the color difference of tuned text color vs original text color ( measured by deltaE2000 - really cool, look it up )
The result is what you would see in the project's banner image
We already got 4 contributors, can you believe that? omg
Let's go and make the world more accessible!!
Solves: How can I make this color combination accessible with the least possible visual change to preserve brand identity, using the most accurate color science?
Release Date: July 17, 2025
We are thrilled to announce the initial public release of CM-Colors, a powerful Python library designed to revolutionize how developers approach color accessibility. Built with research-grade mathematical precision, CM-Colors helps you improve color contrast while thoughtfully preserving brand identity and minimizing visual impact.
This inaugural release provides a robust set of tools for calculating contrast ratios, performing perceptually uniform color adjustments, and ensuring WCAG 2.1 compliance with a brand-conscious approach.
Mathematically Rigorous Color Science Core:
Smart Accessibility Improvement Algorithms:
CMColors().ensure_accessible_colors()
and CMColors().find_accessible_text_color()
automatically adjust colors to meet WCAG AAA standards.Comprehensive Color Space Conversions:
CMColors().rgb_to_oklch()
: Convert RGB colors to the perceptually uniform OKLCH space for better manipulation.CMColors().oklch_to_rgb()
: Convert OKLCH colors back to RGB.CMColors().rgb_to_lab()
: Convert RGB colors to the CIELAB color space, essential for Delta E calculations.CMColors().calculate_oklch_distance()
: Measure perceptual distance directly in the OKLCH color space.Core WCAG Compliance Utilities:
CMColors().calculate_contrast()
: Calculates WCAG contrast ratio between text and background.CMColors().get_wcag_level()
: Determines WCAG compliance level (AAA, AA, FAIL) for normal and large text.Robust Input Validation: All public methods include validation for RGB (0-255) and OKLCH (L: 0-1, C: >=0, H: 0-360) values, raising ValueError
for invalid inputs.
Get started by installing the library:
pip install cm-colors
from cm_colors import CMColors # Or 'from main import CMColors' if running locally
cm = CMColors()
# Check contrast ratio and WCAG level
ratio = cm.calculate_contrast((100, 100, 100), (255, 255, 255))
print(f"Contrast ratio: {ratio:.2f}")
print(f"WCAG Level: {cm.get_wcag_level(ratio)}")
# Automatically fix accessibility for text color
accessible_text, _ = cm.ensure_accessible_colors((100, 100, 100), (255, 255, 255))
print(f"Improved text color: {accessible_text}")
# Calculate perceptual color difference (Delta E 2000)
delta_e = cm.calculate_delta_e_2000((255, 0, 0), (250, 5, 5))
print(f"Delta E 2000: {delta_e:.2f}") # Small perceptual difference
For more detailed examples, including color space conversions and advanced optimization insights, please refer to the README.md on GitHub or the full documentation.
License
This project is open-source and licensed under the GNU General Public License v3.0 (GPLv3).
Built with mathematical precision based on:
WCAG 2.1 Guidelines
CIE Color Science Standards
Delta E 2000 Specification
OKLCH Color Space Research
Making the web more accessible, one color at a time. 🎨✔️
Built with mathematical precision for practical accessibility improvements.
Gonna ship it yay!! Finally done
CM-Colors 🎨
Mathematically Rigorous Accessible Color Science Library
An open-source Python library for improving color accessibility while preserving brand identity. Built with research-grade mathematical precision and practical accessibility tools.
💙Sarvam shri krishna sankalpam💙