Please sign in to access this page

cm-colors

cm-colors Used AI

14 devlogs
64h 32m
•  Ship certified
Created by Lalitha A R

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

Timeline

Ship 2

0 payouts of shell 0 shells

Lalitha A R

7 days ago

Lalitha A R Covers 4 devlogs and 7h 13m

And it's donee people!! Finally stable version is up for release and now it takes any hex or rgb strings too!!

Update attachment

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!!

Update attachment

Who knew math would come to help so much in here

Update attachment

Let's goo refactor and stablise the public API

Update attachment

Ship 1

1 payout of shell 638.0 shells

Lalitha A R

18 days ago

Lalitha A R Covers 10 devlogs and 57h 19m

Ready for release
Sarvam shri krishna sankalpam <33

Update attachment

Released v0.0.3 - will work on polishing it up now

Update attachment

will work on cli now

Update attachment

Core tools are done, yet to create cli and finish docs

Update attachment

Please work and count devlog time!!! :(

Update attachment

Please work and count devlog time!!! :(

Update attachment

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?

Update attachment

CM-Colors v0.0.1 - Initial Public Release

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.

✨ New Features

  • Mathematically Rigorous Color Science Core:

    • Delta E 2000: Full implementation for accurate perceptual color difference calculations.
    • OKLCH Color Space: Core for perceptually uniform color adjustments, offering more natural-feeling changes.
    • WCAG 2.1 Compliance: Accurate gamma correction and luminance calculations ensure adherence to web accessibility standards.
    • Research-Grade Precision: Implementations of color science standards built for high accuracy.
  • Smart Accessibility Improvement Algorithms:

    • Automated Accessibility Correction: CMColors().ensure_accessible_colors() and CMColors().find_accessible_text_color() automatically adjust colors to meet WCAG AAA standards.
    • Brand-Conscious Approach: Algorithms prioritize minimal visual impact (targeting Delta E ≤ 2.0 when possible) to preserve original brand identity.
    • Hierarchical Optimization: Utilizes a combination of Binary Search on Lightness for fast convergence and Gradient Descent in OKLCH for fine-tuning lightness and chroma, finding optimal results efficiently.
    • Smart Fallbacks: Guarantees WCAG compliance when physically possible, even for challenging color pairs.
  • 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.

🚀 Quick Start & Usage Examples

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

🙏 Acknowledgments

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.

Update attachment

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💙

Update attachment

Okay base helpers are done, will polish it, write docs and publish it to pypi

Update attachment