neoPopFaceFor function

NeoPopKeyFace neoPopFaceFor(
  1. ThemeSpec spec
)

NeoPOP renderer for spec: depth from the motion token (seeded 3–5 dp), side tone = palette edge, bottom tone = the edge darkened by half of edgeShadePermille in OKLCH lightness.

Implementation

NeoPopKeyFace neoPopFaceFor(ThemeSpec spec) {
  final palette = spec.palette;
  final keyStyle = spec.keyStyle;
  final shade =
      (keyStyle.edgeShadePermille > 0 ? keyStyle.edgeShadePermille : 180) /
      2000;
  NeoPopEdges edges(KeyColors c) => NeoPopEdges(
    side: Color(c.edge),
    bottom: Color(darkenArgb(c.edge, shade)),
  );
  NeoPopShape shapeOf(KeyShapeKind kind) => switch (kind) {
    KeyShapeKind.circle || KeyShapeKind.pill => NeoPopShape.round,
    _ => NeoPopShape.roundedRect,
  };
  final depthCdp = spec.motion.depthCdp > 0
      ? spec.motion.depthCdp
      : keyStyle.extrudeDepthCdp;
  final opKind = spec.keyShape.operatorKind;
  return NeoPopKeyFace(
    depth: depthCdp / 100,
    digitEdges: edges(palette.digit),
    operatorEdges: edges(palette.operator),
    equalsEdges: edges(palette.equals),
    functionEdges: edges(palette.function),
    cornerFraction: spec.keyShape.cornerFraction,
    shape: shapeOf(spec.keyShape.kind),
    operatorShape: opKind == null ? null : shapeOf(opKind),
    shadowOffset: keyStyle.shadowOffsetCdp / 100,
    shadowColor: Color(palette.shadow),
    slashedZero: spec.type.slashedZero,
  );
}