engine/clear_key library
The all-clear (AC) key's own colours: a warm, alert key that stands
apart from the digit, function, operator and = keys of every theme.
Users could not find AC when it wore the function keys' colours, so
KeyRole.clear gets a colour group of its own. It is derived from a
finished ThemeSpec (its palette, family, Accessible lock, steering
chroma and seed) rather than drawn by the generator, so:
- every theme has one, including themes generated by older engine versions, heroes, saved favourites and share codes;
- no ThemeSpec changes:
toJson,stableHashand every golden fixture are exactly as before, and no engine version bump is needed.
The derivation is part of the bit-exact engine: pure Dart, seeded only
through Rng.stream (palette/clear), identical on every platform.
It is frozen for engine versions 1–5 (pinned by
test/engine/fixtures/clear_keys.json). Any change to it must be gated
on a new engine version, like generator changes.
How the colour is chosen:
- The key takes the structure of the family's accent key (its
"template"): the operator, or
=in Neumorphism and Paper & ink, where=is the one filled key. Alpha (Liquid Glass tints), the label's tint and an edge that follows the face (NeoPOP sides, Retro skirts, clay shadows, Bauhaus blocks) carry over; an edge that is the family's ink or rim (Neo-brutalism, Paper & ink, Y2K, glass, Vaporwave, Neumorphism) stays as it is. - Its hue turns to an alert colour: red first, then vermilion, crimson, amber and rose, each jittered by up to ±6° from the theme's seed. Bauhaus picks among its three primaries instead (red, yellow, blue). Chroma is at least the family's floor (muted intents keep a softer floor, Cyberpunk stays neon).
- The first candidate (keeping the template's lightness, then moving
it by up to 0.42) whose label passes the theme's label policy (4.5:1,
7:1 under the Accessible lock), that passes the family's own
guardrails in the template's place, and that differs from the
digit, function, operator and
=faces by clearMinCvdDeltaE under normal, protan, deutan and tritan vision (and from the digit and function faces by clearMinDeltaE in normal vision) wins. Labels keep the family's polarity where the family requires it (Y2K gels carry dark labels). A translucent glass tint goes solid only when no tint passes. - If no candidate passes everything, the most distinct one that keeps the family's rules wins when it reaches clearFallbackScore of the floors, else the most distinct one with a passing label. In practice this only happens in Y2K (its gels must stay in a light lightness band, where some themes leave room for about 0.75 of the floors; the AC gel still differs from the metal digit and function keys by material) and in a few steered themes.
Enums
- ClearTemplate
- The palette slot whose look the AC key takes.
Constants
-
clearAlertHues
→ const List<
double> - Alert hues (OKLCH degrees) in order of preference: red, vermilion, crimson, amber, rose.
-
clearBauhausPrimaries
→ const List<
(double, double, double)> - Bauhaus's primaries (OKLCH lightness, chroma, hue: red, yellow, blue) for its AC block.
- clearFallbackScore → const double
- When no candidate passes everything, the most distinct candidate that keeps the family's rules wins if it reaches this fraction of the distinctness floors; otherwise the most distinct candidate does.
-
clearLightnessSteps
→ const List<
double> - Lightness offsets tried from the template's lightness, in order.
- clearMinCvdDeltaE → const double
-
The AC face's least ΔEOK from the digit, function, operator and
=faces, under normal vision and each simulated colour-vision deficiency. - clearMinDeltaE → const double
- The AC face's least ΔEOK from the digit and function faces under normal vision (the keys users mistook it for).
Properties
- clearKeyTag → String
-
The RNG stream of the AC hue jitter.
final
Functions
-
clearEdgeTracksFace(
ThemeFamily family) → bool -
Whether
family's key edge follows the face (NeoPOP sides, Retro skirts, clay shadows, M3 Expressive outlines, Cyberpunk glows, Bauhaus blocks) and so turns with it; the other families' edge is their ink or rim and stays. -
clearKeyColors(
ThemeSpec spec) → KeyColors -
The AC key's colours for
spec(memoised per spec instance). -
clearKeyDistinctness(
ThemeSpec spec, KeyColors clear) → double -
How far
clearstands apart fromspec's other key faces, as a fraction of the AC floors (clearMinCvdDeltaE, clearMinDeltaE): ≥ 1 meets them all (tests and diagnostics). -
clearKeyViolations(
ThemeSpec spec, KeyColors clear) → List< String> -
The AC rules
clearbreaks forspec(empty: it passes):label(below the theme's label floor on its face),distinct(too close to another key face), orfamily:<rule>(a family guardrail it breaks in its template's place). Tests and diagnostics. -
clearTemplateOf(
ThemeFamily family) → ClearTemplate -
The template slot of
family.