Metadata-Version: 2.4
Name: sunasty-color-math
Version: 1.0.0
Summary: Zero-dependency sRGB, HSL, OKLCH color conversion and WCAG 2.1 contrast calculation in Python
Author-email: Bastien Sulyan <contact@sunasty.com>
License: MIT
Project-URL: Homepage, https://sunasty.com/color-picker/
Project-URL: Documentation, https://sunasty.com/dev/
Project-URL: Source, https://github.com/bsulyan/sunasty-color-math
Project-URL: Tracker, https://github.com/bsulyan/sunasty-color-math/issues
Keywords: color,oklch,oklab,wcag,contrast,palette,sunasty
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# sunasty-color-math

Zero-dependency Python utility for sRGB, HSL, and OKLCH color space conversions, relative luminance, and WCAG 2.1 contrast calculation.

Originally developed for the [Sunasty Color Picker](https://sunasty.com/color-picker/) client-side tool and the [Sunasty Developer Toolkit](https://sunasty.com/dev/).

## Features

- **sRGB & OKLCH**: Fast, exact conversions using Björn Ottosson's Oklab matrices.
- **WCAG 2.1 Conformance**: Relative luminance calculation and contrast ratios from `1.0:1` to `21.0:1`.
- **Zero Dependencies**: Pure standard library, compatible with Python 3.8+.

## Installation

```bash
pip install sunasty-color-math
```

## Quick Start

```python
from sunasty_color_math import hex_to_rgb, contrast_ratio, check_wcag, rgb_to_oklch

# Parse colors
teal = hex_to_rgb("#0F766E")
white = (255, 255, 255)

# Calculate WCAG contrast
ratio = contrast_ratio(teal, white)
print(f"Contrast ratio: {ratio}:1")

conformance = check_wcag(ratio)
print(f"Passes AA normal text: {conformance['aa_normal']}")

# Convert to OKLCH
l, c, h = rgb_to_oklch(*teal)
print(f"Lightness: {l}, Chroma: {c}, Hue: {h}°")
```

## Related Tools

- [Sunasty Color Picker & Palette Extractor](https://sunasty.com/color-picker/)
- [Sunasty Developer Utilities](https://sunasty.com/dev/)
- [Sunasty Color Picker Chrome Extension](https://github.com/bsulyan/sunasty-color-picker)

## License

MIT © [Bastien Sulyan](https://ulysan.fr)
