# `Atui.Layout`
[🔗](https://github.com/iboard/atui/blob/v0.3.0/lib/atui/layout.ex#L1)

Splits a rect into non-overlapping rects.

Pure geometry — no screens, no views. Leftover cells that do not divide evenly
go to the first tiles, one each, so the pieces always add up to exactly the
rect they came from and nothing is left unpainted.

# `column_sizes`

How many tiles each column holds, for a grid of `n`.

Columns are the square root of the count, rounded up, and the tiles spread as
evenly as they can. Any remainder goes to the later columns, which keeps the
first column the shortest — with three tiles that makes it a single master
beside a stack of two.

    iex> Atui.Layout.column_sizes(3)
    [1, 2]

    iex> Atui.Layout.column_sizes(6)
    [2, 2, 2]

# `columns`

Splits `rect` into `n` side-by-side columns.

# `neighbour`

The tile next to `index` in `direction`, or `nil` at the edge of the grid.

Moving between columns keeps the row where it can and clamps to the last row
of a shorter column, so a tile always lands somewhere.

    iex> Atui.Layout.neighbour(3, 2, :left)
    0

    iex> Atui.Layout.neighbour(3, 0, :up)
    nil

# `rows`

Splits `rect` into `n` stacked rows.

# `split_bottom`

Cuts `size` cells off the bottom of `rect`, returning `{rest, taken}`.

# `split_top`

Cuts `size` cells off the top of `rect`.

Returns `{taken, rest}` — how a status bar or a header claims its row.

# `tile`

Arranges `n` tiles in a grid, filled column by column.

One tile fills the space, two share it side by side, three put a master on the
left with two stacked beside it, four make a square, and so on — see
`column_sizes/1` for the shape. Tiles come back in the order they fill, which
is the order `column_sizes/1` describes, so an index into the list is a
position in the grid.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
