values: derive the named-colour views from one table - #289
Merged
Conversation
samoht
force-pushed
the
values-color-tables
branch
from
August 2, 2026 05:15
d728b35 to
8970454
Compare
The seven six-letter names never fold back from their six-digit hex, grey reads as Gray, and read_color_name takes 21 of the 148 names pp_color_name prints. Under --lossless the canonical projection also reads color(srgb 1 0 0) and rgb(255 0 0) as a difference.
The five hand-maintained tables had drifted: the hex inversion was a copied subset missing the seven colours whose name is no longer than their hex, so #ffe4c4 stayed hex where #f0ffff folded to azure, and read_color_name took 21 of the 148 names and mapped grey onto Gray. One (constructor, name, hex) list now feeds all five, with the name-versus-hex length rule written once and canonical_color_of_hex returning the constructor instead of re-parsing a name.
--lossless keeps whichever colour function the author wrote, so the canonical projection read color(srgb 1 0 0) and rgb(255 0 0) as a difference when they are one colour in two spellings. The projection now folds a color(srgb ...) whose channels land on whole bytes; the fold is exact-only, and a declaration is left as it came in unless the colour actually moved, so emission is untouched and display-p3 red stays a difference.
samoht
force-pushed
the
values-color-tables
branch
from
August 2, 2026 05:36
8970454 to
88c2e6b
Compare
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.
Five hand-maintained named-colour tables had drifted twice over: named_for_hex was a hand-copied subset missing exactly the seven colours whose name is shorter than their hex (bisque, indigo, orchid, salmon, sienna, tomato, violet - the minifier never took those folds), and read_color_name accepted 21 of 148 names, mapping grey to Gray. One (constructor, name, hex) table now derives all five views, with a not-called exhaustive match making a new color_name constructor a build error beside the table, and the shortest-spelling predicate written once and read by both the fold and its inversion. A 444-declaration sweep confirms exactly the seven spellings changed. Separately, the lossless canonical projection keys an exact color(srgb 1 0 0) onto rgb(255,0,0) - same colour, different function - closing a projection gap; display-p3 and inexact channels stay distinct.