Layout that learns from a designer's drags

Show the layout what you want with a few drags. The code learns its numbers, and its limits stay exact.

1 A sizing function nobody can quite tune

A designer wants the important cards bigger, and everything to scale with the screen. An engineer wrote three constants. They're wrong, and every round of “a bit wider on tablets?” is another guess.

the layout code runs as a Handwired net

  • cards out of bounds (50 screen widths × 20 cards) 0
  • furthest from your examples –
  • net vs plain JS, max difference –

try it

  1. Drag the right edge of the screen to resize it. Cards follow the code.
  2. Drag a card's grip to the width you'd want at this size. That's a training example.
  3. Or load the designer's three mockups, then press Learn.

0 examples

screen 1280 px wide

drag ⟷

2 Predict

You'll drag cards at one or two screen widths. After learning, at a screen width you never touched, will any card overflow the screen?

3 Drag, then learn

Give examples at two or three screen widths, so it can tell “fixed size” from “grows with the screen”. Press Learn: the error line drops, three constants move in the code, and the screen sweeps through every width to show all cards following. Then drag the screen edge yourself.

4 The foil: a generic model on the same drags

Train a small neural net (2→12→1) on the same drags. It fits them, but it has no idea that “never wider than the screen” is a rule.

Reach for Handwired when a designer can show you what they want faster than they can describe it, and the layout still has hard limits.

The simulated designer drags 4 importance levels at 1280, 900 and 420 px, aiming at hidden constants (BASE 140, PER_LEVEL 70, SHARE 0.16) with ±6 px of hand wobble. The bounds check covers 50 screen widths from 320 to 1440 px with 20 seeded cards each. Widths are float32 in the net and float64 in JavaScript, so they agree to a fraction of a pixel, not bit for bit; the clamp itself is exact. Row packing is ordinary JavaScript.

Loading Handwired…