Metadata-Version: 2.4
Name: codechu-color
Version: 0.1.0
Summary: Stdlib-only color palettes and format converters — ANSI, hex, RGB, HSL, WCAG contrast, color-blind safe variants.
Author: Codechu
License: MIT License
        
        Copyright (c) 2026 Codechu
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/codechu/color-py
Project-URL: Source, https://github.com/codechu/color-py
Project-URL: Issues, https://github.com/codechu/color-py/issues
Keywords: color,palette,ansi,hex,rgb,wcag,accessibility,color-blind,stdlib
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Terminals
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Dynamic: license-file

# codechu-color

Stdlib-only color palettes and format converters for Python 3.10+.
Zero runtime dependencies.

Solves the cross-surface palette drift problem: CLI tools work in
ANSI escapes, GTK apps work in hex / CSS, JSON exports want flat
dicts. `codechu-color` keeps one source of truth and derives the rest.

## Install

```bash
pip install codechu-color
```

## Quick start

```python
from codechu_color import Color, Palette, RISK, palette_for, to_gtk_css

# Single color in every form
green = Color.from_hex("#1a7f37", name="low")
green.rgb       # (26, 127, 55)
green.ansi_fg   # "\x1b[32m"
green.ansi_bg   # "\x1b[42m"

# Built-in semantic palette (GitHub accessibility-tuned)
RISK.low.hex    # "#1a7f37"
RISK.high.hex   # "#cf222e"

# Color-blind safe variants (Bang & Wong 2011)
pal = palette_for("risk", profile="deuteranopia")
pal.high.hex    # "#d55e00" (vermilion, safe for red-green confusion)

# Export for GTK CSS
css = to_gtk_css(RISK, prefix="risk-")
# .risk-low { color: #1a7f37; } ...

# Flat dict for JSON
RISK.to_dict()  # {"low": "#1a7f37", "medium": "#9a6700", "high": "#cf222e"}
```

## WCAG helpers

```python
from codechu_color import contrast_ratio, pick_text_color

contrast_ratio((255, 255, 255), (0, 0, 0))   # 21.0  (max)
pick_text_color((9, 105, 218))                # (255, 255, 255) — white on blue
```

## Built-in palettes

| name | keys |
|---|---|
| `RISK` | `low`, `medium`, `high` |
| `TERMINAL` | basic ANSI 8 |
| `MATERIAL` | Material Design Primary 500 tones |
| `SOLARIZED_LIGHT` / `SOLARIZED_DARK` | full accent ramp + base tones |

## Vision profiles

`palette_for("risk", profile=...)` accepts:

- `"default"` — GitHub semantic green / amber / red
- `"protanopia"` — safe for protan red-blindness
- `"deuteranopia"` — safe for deutan red-green confusion (most common)
- `"tritanopia"` — safe for tritan blue-yellow confusion

Profiles use the Bang & Wong (2011) qualitative palette
(*Nature Methods* 8: 441).

## License

MIT
