Expand description
Static xkcd color-hierarchy table for human-vocabulary color naming.
Each entry exposes five hierarchical names (xkcd → design → common →
family → kind), plus the entry’s RGB and a pre-computed CIE LAB triple
used by Color::nearest_to for nearest-neighbor lookup.
§Why LAB is pre-computed at codegen time
The sRGB → LAB pipeline involves a power function (gamma decode) and a
cube root (LAB f-function), both transcendental. Computing those for
all 950 entries on every query would dwarf the actual nearest-neighbor
scan. Pre-computing at cargo xtask codegen time pushes that cost out
of the hot path; the runtime cost of nearest_to is one sRGB→LAB on
the query plus 950 squared-distance comparisons (no sqrt — squared
distance preserves ordering).
§Distance metric
Choose via Algorithm; the default (Algorithm::Ciede2000Exact)
is the modern perceptual gold-standard. Faster alternatives are
available via Color::nearest_to (Delta E 76, ~470 ns NEON) and
Color::nearest_to_cie94 (CIE94, ~620 ns NEON) for throughput-
sensitive callers willing to trade borderline accuracy for speed.
§Attribution
The color hierarchy is sourced from Stitch Fix’s colornamer (Apache
2.0); see THIRD_PARTY_NOTICES.md for the full upstream attribution.
Structs§
- Color
- One named entry in the xkcd color hierarchy.
Enums§
- Algorithm
- Color-difference algorithm used to map an arbitrary RGB query to
its nearest
Colorin the xkcd palette. - Family
- Color family classification sourced from the upstream
color_hierarchy.csvcolor_familycolumn. Marked#[non_exhaustive]so adding a new upstream value is a non-breaking change for downstream consumers; callFamily::as_strto get the original string back when you need to feed it into a search index. - Kind
- Color kind / texture classification sourced from the upstream
color_hierarchy.csvcolor_typecolumn. Marked#[non_exhaustive]so adding a new upstream value is a non-breaking change for downstream consumers; callKind::as_strto get the original string back when you need to feed it into a search index.
Statics§
- COLORS
- All 949 entries in the dataset, in CSV order.