render/retro/retro_key_face library
Retro hardware keycaps (motion brief §2.3 "Retro hardware"; docs/m4-design.md §B), drawn in-house.
Geometry for a key box of w × h and travel d (2–3 dp, seeded):
- the skirt (the keycap's darker side, the palette
edge) fills the box below the cap, so at rest a band of height d shows under the face; - the cap is the rounded rectangle (0, d·p, w, h − d + d·p): it travels down by d as the key goes in and covers the skirt band;
- a soft contact shadow under the key shrinks as it travels;
- the bevel: a highlight band along the cap's top edge and a shade band along its bottom edge. On touch-down they swap (discrete, in frame 1 — the key reads as pushed in) and swap back once the release passes p < 0.5. The swap keys on the tint channel, which the press recognizer snaps to 1 in the touch-down frame: hardPress is only at p ≈ 0.5 after one 60 Hz frame (0.2 at 120 Hz), so a p ≥ 0.5 trigger would land a frame or two late.
No state-layer tint (the swap is the cue); the label rides on the cap. Reduce Motion: the cap sits at its pressed position with the bevel swapped, no frames between.
Classes
- RetroKeyFace
- Retro keycap renderer for one theme. A same-family theme change lerps travel, corners, skirt tones and bevel strengths (LerpableKeyFace).
- RetroKeyPainter
- Paints one Retro keycap: contact shadow, skirt, cap with its bevel (swapped while pressed), the desktop hover layer, an optional outline and the long-press bar. Repaints from the motion channels only.