Skip to main content

Module semantic

Module semantic 

Source
Expand description

Case 4 — brand-vs-state collision resolver.

Success / warning / danger are universal conventions. They are not derived from the brand. The only adjustment the engine makes is to push a state color out of the brand’s way when the hues collide, so a red brand doesn’t reduce the “delete” button to noise.

Two guard rails on top of the brief’s algorithm:

  1. Achromatic brand short-circuit. When the brand is grey (chroma ≈ 0) the stored hue is arbitrary and using it as a collision target produces nonsense rotations. The resolver returns the three anchors unchanged in that case.

  2. Bounded rotation. A naive “rotate until gap ≥ 45°” can push success out of the green band (e.g. a neon-green brand sends success all the way to teal). MAX_STATE_ROTATION caps how far a state may move so it always still reads as itself — the brand simply has to coexist with a state when the brand was chosen in that state’s hue family.

Structs§

SemanticPalette
Resolved state colors after collision avoidance.

Constants§

ACHROMATIC_CHROMA
OKLCH chroma below this is treated as achromatic for collision purposes — hue is undefined, so semantic colors stay unshifted.
DANGER_ANCHOR
Fixed anchor hue for “danger”. Red is the universal convention.
MAX_STATE_ROTATION
Hard upper bound on how far the resolver will move a state color to clear the brand. 30° keeps each state inside its conventional hue family (success in green, warning in amber/orange, danger in red/crimson) even when the brand is a near-match. The brief allows up to a 45° rotation, but 45° pushes red→amber and green→teal — losing the state’s identity. The capped value prefers a smaller separation over a wrong-colored state.
MIN_HUE_GAP
Minimum OKLCH hue gap (degrees) a state color tries to keep from the brand. The actual achieved gap may be smaller — see MAX_STATE_ROTATION.
SUCCESS_ANCHOR
Fixed anchor hue for “success”. Green is the universal convention.
WARNING_ANCHOR
Fixed anchor hue for “warning”. Amber is the universal convention.

Functions§

resolve_semantics
Pick state colors, pushing each one away from the brand hue when it sits inside the brand’s collision zone. See the module docs for the two guard rails layered on top of the brief’s algorithm.