Skip to main content

Crate colorthief_dataset

Crate colorthief_dataset 

Source
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 Color in the xkcd palette.
Family
Color family classification sourced from the upstream color_hierarchy.csv color_family column. Marked #[non_exhaustive] so adding a new upstream value is a non-breaking change for downstream consumers; call Family::as_str to 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.csv color_type column. Marked #[non_exhaustive] so adding a new upstream value is a non-breaking change for downstream consumers; call Kind::as_str to 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.