Repository navigation
feat(core): selectable gamut mapping method - #209
Merged
Merged
Conversation
This was referenced Oct 6, 2026
Owner
Author
This was referenced Oct 6, 2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Oct 6, 2026
|
This was referenced Oct 6, 2026
This was referenced Oct 7, 2026
pbroom
force-pushed
the
feat/core-gamut-map-method
branch
from
October 7, 2026 23:28
5242bfc to
ef170b6
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Oct 8, 2026
Owner
Author
pbroom
changed the base branch from
fix/core-contrast-precision
to
graphite-base/209
October 10, 2026 19:03
toSrgbGamut/toP3Gamut only reduce OKLCH chroma at fixed L and h, which
under-shoots what CSS (and colorjs.io) produce: oklch(0.7 0.35 150) maps
to C=0.193 instead of the CSS Color 4 result C=0.210.
- Add GamutMapOptions { method?: 'chroma-reduction' | 'css' } to
toSrgbGamut, toP3Gamut, toSrgbGamutInto and toP3GamutInto (types
GamutMapMethod/GamutMapOptions exported). 'css' implements the CSS
Color 4 binary search with local MINDE (deltaE OK JND 0.02, epsilon
1e-4, clip in the target gamut) allocation-free on scratch objects; it
matches colorjs.io toGamut({ method: 'css' }) to ~1e-15 dE_OK for both
sRGB and P3.
- Default stays 'chroma-reduction': the CSS method shifts L and h, while
contrast regions, plane geometry, slider tracks and the driver's
displayed state rely on L/h being preserved, so it is not strictly
better for existing tests or callers. Both methods return colors that
pass inSrgbGamut/inP3Gamut (with GAMUT_EPSILON slack) unchanged and
snap the lightness endpoints, so membership and mapping stay
consistent.
- toSrgbGamut/toP3Gamut get a one-argument overload so passing them
straight to Array.prototype.map keeps type-checking (the index
argument is ignored at runtime).
- driver: mapDisplayedColors(requested, { gamutMapMethod }) and
CreateColorStateOptions.gamutMapMethod forward the method; the default
is unchanged.
- maxChromaAt reuses one scratch probe instead of allocating a Color per
bisection step.
- The gamut-region solver's search-gap handling (oklchChromaField) is
about maxChromaAt's bisection bracket, not the mapping method, so it
is left as is.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
useColor's setRequested and the multi-color model dropped meta.gamutMapMethod, so updates reverted to chroma reduction. Co-Authored-By: Claude Opus 5.5 <[email protected]>
pbroom
force-pushed
the
feat/core-gamut-map-method
branch
from
October 10, 2026 19:05
ef170b6 to
218d614
Compare
This branch was successfully deployed
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.

toSrgbGamut/toP3Gamut only reduce OKLCH chroma at fixed L and h, which
under-shoots what CSS (and colorjs.io) produce: oklch(0.7 0.35 150) maps
to C=0.193 instead of the CSS Color 4 result C=0.210.
toSrgbGamut, toP3Gamut, toSrgbGamutInto and toP3GamutInto (types
GamutMapMethod/GamutMapOptions exported). 'css' implements the CSS
Color 4 binary search with local MINDE (deltaE OK JND 0.02, epsilon
1e-4, clip in the target gamut) allocation-free on scratch objects; it
matches colorjs.io toGamut({ method: 'css' }) to ~1e-15 dE_OK for both
sRGB and P3.
contrast regions, plane geometry, slider tracks and the driver's
displayed state rely on L/h being preserved, so it is not strictly
better for existing tests or callers. Both methods return colors that
pass inSrgbGamut/inP3Gamut (with GAMUT_EPSILON slack) unchanged and
snap the lightness endpoints, so membership and mapping stay
consistent.
straight to Array.prototype.map keeps type-checking (the index
argument is ignored at runtime).
CreateColorStateOptions.gamutMapMethod forward the method; the default
is unchanged.
bisection step.
about maxChromaAt's bisection bracket, not the mapping method, so it
is left as is.
Part of a stacked set of PRs (#204 → #221) from the color-kit assessment. Validated per branch with
pnpm buildandpnpm test; lint, format, typecheck, size, artifact, preprod and agents checks pass at the top of the stack.🤖 Generated with Claude Code