Skip to main content

layout_regions

Function layout_regions 

Source
pub fn layout_regions(
    surface: &Surface,
    regions: &[Region],
    cards: &[Card],
    previous: Option<&RegionLayout>,
) -> RegionLayout
Expand description

Lays cards out in regions on and around surface.

Pass the previous result for the same regions as previous to keep each region’s choices (column count, forms, orientations) while its room stays within half a unit of a threshold. The result has one placement per region and per card, in input order. This function never panics.

Regions go by priority, highest first (the first given on a tie): each takes the room at its anchor less the blocks of the regions before it (and the gap), cutting the side that keeps the most room. Its cards fill from its anchor outwards: in a corner the first card is in the corner, along a centred edge they go in reading order. Of two regions at one anchor, the second gets no room once the first placed a card: its cards fold.