lcdDisplayFaceFor function

LcdDisplayFace? lcdDisplayFaceFor(
  1. ThemeSpec spec
)

Retro's 7-segment panel for spec (only for 7-segment specs: TypeSpec.lcd): panel = surface, ghost segments = lcdGhost, a VFD when the panel is darker than its segments; the bezel is the body a step darker (desk) or lighter (pocket).

Implementation

LcdDisplayFace? lcdDisplayFaceFor(ThemeSpec spec) {
  if (!spec.type.lcd) return null;
  final palette = spec.palette;
  final panel = Color(palette.surface);
  final segment = Color(palette.displayText);
  final vfd = panel.computeLuminance() < segment.computeLuminance();
  final body = palette.background;
  final bodyL = argbToOklch(body).l;
  final bezel = bodyL < 0.5 ? darkenArgb(body, -0.035) : darkenArgb(body, 0.16);
  return LcdDisplayFace(
    panel: panel,
    bezel: Color(bezel | 0xFF000000),
    ghost: switch (palette.lcdGhost) {
      final g? => Color(g),
      null => null,
    },
    vfd: vfd,
    widthPermille: spec.type.widthPermille,
  );
}