Skip to content

No.407 · Stats

Balance Stats

Money in against money out, on a real balance. Coins worth a fixed sum drop into the two pans one at a time; every landing knocks the beam, which swings and settles at the angle the difference asks for, and a needle at the pivot reads it. Change month and coins lift away or fall in.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Paper

Build a two-quantity comparison drawn as a physical balance scale, in SVG (viewBox 520 × 292). Props: months ({ label, left, right }), names (two pan labels), coin (value per coin), currency, title. Drawing: a curved foot and post; a beam (rounded rect, ±168 from the pivot) that rotates about the pivot; a pivot cap; a small dial arc with five ticks behind the pivot and a needle that turns 2.2× the beam angle in the opposite direction. Each pan hangs from a beam end: three chain strings to a shallow dish, with a coloured lip — categorical slot 3 (aqua) for the left pan and slot 2 (orange) for the right — and it is translated (never rotated) to the end's position each frame, so the pans always hang level. Coins: each pan draws every coin it could hold in any month (max(round(value / coin))) as two stacked ellipses (edge and face) arranged as a small pyramid of columns six high. A coin is live when its index is below the pan's current count: live coins sit in place, the others are 90px above and transparent. Falling uses an ease-in curve (300ms, like gravity); leaving uses an ease-out lift (360ms). Filling: once 35% of the panel is in view, counts step toward the month's targets one coin every 85ms, always moving whichever pan is further from done, so the beam rocks as it fills. Switching month (a radiogroup) steps toward the new targets the same way. Beam: target angle = clamp((right − left) / (left + right) × 90°, ±14°), from the coins currently in the pans. A lightly damped spring (k 38, ζ 0.32) with an extra velocity kick of 0.6 × the change each time the target moves, so every coin visibly knocks it; the loop stops once it is at rest. Header: the difference in large tabular figures, green with + for a surplus and red with − for a shortfall (sign and word as well as colour), and "surplus/shortfall in Sep". Legend: each pan's name and exact amount with its colour key, and "1 coin = OMR 500". The SVG has role=img with a sentence summary, plus a hidden table of every month. Paper and Night; reduced motion fills instantly with no swing. Selected variant — Paper (paper): Palette for this theme (Paper): --bal-bg #fbf8f2; --bal-coin #d9a63e; --bal-coin-edge #a87a1f; --bal-dish #e9e1d3; --bal-focus #1f4e8c; --bal-ink #1b1a17; --bal-l #1baf7a; --bal-metal #9b8e7b; --bal-metal-hi #c9bda8; --bal-muted #6f6a62; --bal-neg #b4432f; --bal-pos #137a52; --bal-r #eb6834; --bal-rim rgb(27 26 23 / 0.1). Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "paper". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Scroll in to fill the pans; switch Jul, Aug and Sep to watch coins move and the beam find its new rest. Motion: Coins every 85ms, falling 300ms ease-in, lifting 360ms ease-out; beam on a lightly damped spring (k 38, ζ 0.32) knocked by each coin. Accessibility: The scale is role=img with a one-sentence summary that updates with the month; the months are a radiogroup; a hidden table holds every value. Surplus or shortfall is said in words and with a sign, not just colour. Reduced motion shows the settled scale. Responsive behavior: The SVG scales to its column; the legend reflows into two columns on phones. Touch: Identical on touch — the month switch is the only control. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Scroll in to fill the pans; switch Jul, Aug and Sep to watch coins move and the beam find its new rest.
Motion
Coins every 85ms, falling 300ms ease-in, lifting 360ms ease-out; beam on a lightly damped spring (k 38, ζ 0.32) knocked by each coin.
Accessibility
The scale is role=img with a one-sentence summary that updates with the month; the months are a radiogroup; a hidden table holds every value. Surplus or shortfall is said in words and with a sign, not just colour. Reduced motion shows the settled scale.
Responsive
The SVG scales to its column; the legend reflows into two columns on phones.
On touch
Identical on touch — the month switch is the only control.