Preserve brightest channel when clamping foreground chroma#16
Merged
Conversation
`readableForeground` was desaturating high-chroma foregrounds in HSL at constant lightness, which dims peak-channel colors. Cyberpunk Umbra's #00ff9c (V=1, perceived Y=0.84) collapsed to #5f9f86 (Y=0.54) — readable in isolation but with poor contrast against the theme's dark base01 background. The chat input box, which uses theme.text on inputBackground, became hard to read while typing. Switch the rebuild path to HSV desaturation: pull each channel toward max(r,g,b) by the same factor we'd pull saturation. Keeps V fixed, so perceived luminance is preserved and the result on dark themes is a pastel that contrasts cleanly with the background. #00ff9c now becomes #bfffe6 (Y=0.91). Built-in themes still hit the early-return path (chroma ≤ 0.25), so they're untouched. Drops the now-unused hslToRGB / hueToRGB helpers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#00ff9c(perceived Y=0.84) collapsed to#5f9f86(Y=0.54) — readable in isolation, but contrast against the theme's darkbase01was low enough that the chat input box became hard to read while typing.max(r,g,b)bymaxChroma / chroma.Vstays fixed, perceived luminance is preserved, and the result on dark themes is a pastel that contrasts cleanly with the background.#00ff9cnow resolves to#bfffe6(Y=0.91).chroma ≤ 0.25) and are unchanged.hslToRGB/hueToRGBhelpers.Test plan
swift buildclean#00ff9c→#bfffe6, base04#7877b3unchanged (already under cap)