|
| 1 | +# Architecture |
| 2 | + |
| 3 | +PaintCan is a small, typed Python package for HSBA color values and deterministic |
| 4 | +color-scheme generation. The intended shape is deliberately simple: |
| 5 | + |
| 6 | +1. `HSBAColor` is the core immutable value object. |
| 7 | +2. `ColorScheme` is an immutable sequence wrapper around generated colors. |
| 8 | +3. The terminal demo renders colors for human inspection but does not own domain |
| 9 | + behavior. |
| 10 | + |
| 11 | +## Layers |
| 12 | + |
| 13 | +### Domain Values |
| 14 | + |
| 15 | +`src/paintcan/hsba_color.py` owns all HSBA component invariants: |
| 16 | + |
| 17 | +- hue, saturation, brightness, and alpha are floats in `0.0 <= value <= 1.0`; |
| 18 | +- hue adjustment wraps cyclically; |
| 19 | +- saturation and brightness can clamp or overflow within caller-provided bounds; |
| 20 | +- alpha always clamps and never overflows; |
| 21 | +- random color ranges are validated before any color is constructed. |
| 22 | + |
| 23 | +Code outside this module should not reimplement component bounds. It should rely |
| 24 | +on `HSBAColor` construction and adjustment methods. |
| 25 | + |
| 26 | +### Scheme Generation |
| 27 | + |
| 28 | +`src/paintcan/color_scheme.py` owns all palette factory methods. Every factory: |
| 29 | + |
| 30 | +- returns exactly five colors; |
| 31 | +- preserves the first color as `theme_color`; |
| 32 | +- returns a read-only `ColorScheme`; |
| 33 | +- keeps every generated HSBA component inside `0.0..1.0`. |
| 34 | + |
| 35 | +Scheme generation is intentionally algorithmic and local. If more schemes are |
| 36 | +added, keep the scheme rules readable in this module until repeated operations |
| 37 | +make a small internal helper clearly worthwhile. |
| 38 | + |
| 39 | +### Demo Entrypoint |
| 40 | + |
| 41 | +`src/paintcan/__main__.py` is a visual terminal demo. It may convert HSBA to RGB |
| 42 | +for ANSI output, but library callers should import from `paintcan` instead of |
| 43 | +depending on demo helpers. |
| 44 | + |
| 45 | +## Dependency Direction |
| 46 | + |
| 47 | +- `paintcan.__init__` re-exports the public API. |
| 48 | +- `color_scheme` may depend on `hsba_color`. |
| 49 | +- `hsba_color` must not depend on scheme or demo code. |
| 50 | +- `__main__` may depend on both public domain modules. |
| 51 | +- Tests may import the public package and inspect internals only for repo |
| 52 | + structure checks. |
0 commit comments