Deterministic Base24 color scheme generator. Given a wallpaper image, produces a 24-color YAML palette.
- Analyze — sub-sample the image, profile lightness distribution and hue content via coarse (8×45°) and fine (36×10°) histograms in OKLCh
- Tone ramp — build 10 background/foreground shades with image-derived tinting, contrast-optimized via binary search
- Accents — extract dominant hue peaks from the fine histogram, assign them to the 8 semantic accent slots (red, orange, yellow, green, cyan, blue, purple, brown) by proximity; assigned slots get image-derived hue at boosted chroma, unassigned slots keep canonical hue at muted chroma
- Bright variants — derive 6 brighter accents for terminal bold colors, contrast-checked against all background tones
- Gamut clip — binary search on chroma to bring every color into sRGB
Auto-detects dark/light mode from the image's median lightness. See DESIGN.md for the full algorithm and rationale.
Requires Zig 0.15+.
zig buildnix buildbase24-gen [options] <image>| Flag | Description |
|---|---|
--mode dark|light |
Force dark or light mode (default: auto-detect) |
--name NAME |
Scheme name (default: image filename) |
--author AUTHOR |
Author field (default: base24-gen) |
--output FILE |
Write YAML to file (default: stdout) |
--preview |
Print ANSI color swatches to stderr |
--terminal |
Emit OSC 4/10/11 escape sequences to retheme the terminal in-place |
base24-gen --preview wallpaper.png > scheme.yaml
base24-gen --terminal wallpaper.png # live-preview in current terminalsrc/
main.zig CLI entry point, argument parsing, YAML/terminal output
color.zig sRGB/OKLab/OKLCh conversions, gamut clipping, contrast
image.zig stb_image wrapper for image loading
analysis.zig image profiling (lightness, hue weights, chroma stats)
peaks.zig hue peak extraction, image hue sampling
palette.zig tone ramp, accent solver, bright variants
devtui.zig interactive TUI for accent solver visualization
vendor/
stb_image.h vendored stb_image v2.29
MIT.