kitty/docs
Jökull Sólberg 64abd87a9e Add wide gamut color support with OKLCH and LAB formats
Implements modern wide gamut color formats with CSS Color Module Level 4
gamut mapping, addressing PR feedback with Go implementation, performance
benchmarks, and reorganized documentation.

Features:
- OKLCH (perceptually uniform color space)
- CIE LAB (device-independent color space)
- CSS Color 4 compliant gamut mapping algorithm
- Inline comment support in color config parsing

Addressing PR Feedback:

1. Go Implementation (tools/utils/style/):
   - Complete OKLCH and LAB parsing with gamut mapping
   - Matches Python implementation structure
   - Comprehensive test suite (all tests passing)
   - Performance benchmarks showing acceptable overhead

2. Performance Benchmarks:
   - OKLCH: ~4.6 µs/op
   - LAB: ~1.5 µs/op
   - 10 mixed colors: ~13 µs total
   - Typical config (50 colors): <0.5ms startup impact

3. Documentation Reorganization:
   - Moved detailed color docs to docs/wide-gamut-colors.rst
   - Configuration docs now link to separate documentation
   - Reduces size of main configuration documentation

Gamut Mapping:
- Binary search chroma reduction from CSS Color Module Level 4
- Preserves lightness and hue while reducing chroma for out-of-gamut colors
- Uses deltaE OK (JND threshold: 0.02) for perceptual difference
- Ensures graceful degradation on sRGB displays

Python Implementation:
- parse_oklch(): OKLCH color parsing with gamut mapping
- parse_lab(): CIE LAB parsing with gamut mapping via OKLCH conversion
- lab_to_oklch(): LAB to OKLCH conversion for consistent gamut mapping
- oklch_to_srgb_gamut_map(): CSS Color 4 gamut mapping algorithm
- srgb_to_oklab(): Reverse conversion for deltaE calculations
- deltaE_ok(): Perceptual color difference in OKLab space

Go Implementation:
- colorspaces.go: All color space conversions and gamut mapping
- wrapper.go: ParseColor() updated to support OKLCH and LAB
- Comprehensive test coverage with benchmarks
- Matches Python implementation behavior

Robustness:
- NaN and infinity validation in all color parsing functions
- Defense-in-depth with validation at parsing and gamut mapping levels
- Returns None/error for invalid input (consistent error handling)
- Validates before clamping operations to prevent NaN propagation

Files changed:
- Python: kitty/rgb.py, kitty_tests/datatypes.py (+250 lines)
- Go: tools/utils/style/colorspaces.go, wrapper.go (+350 lines, tests)
- Docs: docs/wide-gamut-colors.rst (moved from inline)
- Config: kitty/options/definition.py (simplified, links to docs)

References:
- CSS Color Module Level 4: https://www.w3.org/TR/css-color-4/
- OKLCH Color Space: https://bottosson.github.io/posts/oklab/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-27 14:34:34 +00:00
..
_static Oxipng/svgo images to save some 150KB~ 2024-03-25 23:42:56 +01:00
_templates
kittens Update choose files docs 2025-12-24 09:17:24 +05:30
screenshots Update choose files docs 2025-12-24 09:17:24 +05:30
actions.rst
basic.rst Add a default mapping for searching the scrollback 2025-12-01 08:10:07 +05:30
binary.rst Fix #8244 2025-01-22 19:01:55 +05:30
build.rst ... 2025-02-03 11:18:18 +05:30
changelog.rst ... 2025-12-24 12:15:16 +05:30
clipboard.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
color-stack.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
conf.py Document the save_as_session action 2025-08-17 14:44:26 +05:30
conf.rst Allow dynamically generating configuration by running an arbitrary program using the new geninclude directive 2025-01-06 19:00:01 +05:30
deccara.rst
desktop-notifications.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
extract-rst-targets.py
faq.rst add nyancat app icon 2025-12-17 17:10:34 -05:00
file-transfer-protocol.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
glossary.rst Add an env var that can be used to eval an expression at startup of shell 2025-08-16 11:58:30 +05:30
graphics-protocol.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
index.rst Update some docs 2025-10-07 20:20:19 +05:30
installer.sh ... 2024-08-19 10:27:40 +05:30
integrations.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
intro_vid.rst
invocation.rst
keyboard-protocol.rst Clarify behavior of keyboard protocol for pure text events 2025-11-08 16:46:44 +05:30
kittens_intro.rst Update choose files docs 2025-12-24 09:17:24 +05:30
launch.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
layouts.rst Splits layout: Allow setting the bias of the current split using layout_action bias 2025-01-17 08:37:07 +05:30
Makefile
mapping.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
marks.rst
misc-protocol.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
multiple-cursors-protocol.rst Add some footnotes explaining what features native cursors have 2025-09-04 22:02:04 +05:30
notifications.py Add support for controlling the sound played with notifications 2024-08-03 13:46:38 +05:30
open_actions.rst Update docs 2025-07-11 06:53:07 +05:30
overview.rst Fix #9196 2025-11-06 22:59:53 +05:30
performance.rst Fixed typos 2025-05-18 15:16:56 +02:00
pipe.rst
pointer-shapes.rst ... 2025-01-06 21:57:31 +05:30
press-mentions.rst
protocol-extensions.rst Start work on documenting the multi cursor protocol 2025-08-24 20:14:15 +05:30
quake-screenshots.rst Fix #9127 2025-10-20 08:16:48 +05:30
quickstart.rst Fix repology link in quickstart doc 2025-01-10 17:02:52 +08:00
rc_protocol.rst
remote-control.rst Add a more visible note that the payloads for remote control commands are documented in the protocol docs 2025-10-06 10:42:11 +05:30
requirements.txt Fix docs build breakage 2025-12-20 09:13:02 +05:30
sessions.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
shell-integration.rst Improve docs formatting 2025-03-19 14:43:34 +05:30
support.html
support.rst
text-sizing-protocol.rst fix: typos in documentation 2025-12-14 22:42:24 +10:30
underlines.rst
unscroll.rst
wide-gamut-colors.rst Add wide gamut color support with OKLCH and LAB formats 2025-12-27 14:34:34 +00:00