Repository navigation
Fix lch() chroma percentage reference range (100% should be 150, not 125) - #238
Open
amalsaidov wants to merge 2 commits into
Open
amalsaidov wants to merge 2 commits into
amalsaidov wants to merge 2 commits into
Conversation
CSS Color 4 defines the percentage reference range for lch() chroma as 100% = 150, but the parser reused the lab() a/b range (100% = 125), so chroma percentages were parsed ~17% too low (e.g. lch(50% 100% 40) gave a chroma of 125 instead of 150). Pass the correct 1.5 scale for lch() and add a regression test covering the percentage reference ranges of lab(), lch(), oklab() and oklch(). Signed-off-by: karma <inskarma0101@gmail.com>
Signed-off-by: karma <inskarma0101@gmail.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.
While adding some tests around the CSS color parser I noticed that
lch()chroma given as a percentage comes out too low.CSS Color 4 defines the percentage reference ranges per function (§ "lab(), lch(), oklab(), oklch()"):
lab()lch()oklab()oklch()The dispatch in
parse_color_prefixpasses the same scale (1.25) to bothlab()andlch(). That is right forlab()a/b (125), butlch()chroma should use1.5(150). As a result:The
ok*variants are unaffected because oklab a/b and oklch chroma share the same 0.4 reference (0.004).This passes
1.5forlch()and adds a regression test checking the percentage reference range for all four functions.cargo testpasses.Spec: https://www.w3.org/TR/css-color-4/