layout
Pure screen-layout helpers in UI points, with no UI calls. `largestFree(bounds, obstacles, opts)` finds the biggest rect that touches none of the obstacles; the gallery uses it to sit beside the HUD rather than on top of it. `evenRows(spans, cols)` deals cards into rows that hold…
layout
Pure screen-layout helpers in UI points, with no UI calls. largestFree(bounds, obstacles, opts) finds the biggest rect that touches none of the obstacles; the gallery uses it to sit beside the HUD rather than on top of it. evenRows(spans, cols) deals cards into rows that hold as nearly the same number of columns as they can, and rowWidths(spans, avail, gap) stretches each row to the full width.
packLines(widths, avail, gap) counts the lines a row of chips wraps into. fitGrid(items, availW, availH, opts) sizes a card grid so every item is shown at once inside the height: it tries each column count, shares the height evenly between the rows, and keeps the grid that draws the items largest without starving the smallest. It returns { fits, cols, rows, spans, cellH, bodyH, scales, minScale }, with fits = false (the best try) when nothing fits at the minimum card size.
Scoped to this part · feeds back into the world's score.