Layout¶
Place ordered units in space. The trivial reading-order layout is below; the walk, spiral, and grid layouts land in later phases.
lexograph.layout.linear.linear_layout(n, *, columns=None, col_width=1.0, line_height=1.0)
¶
Lay n units out on a reading-order grid.
Unit i is placed at column i % columns and row i // columns,
with rows running downward (decreasing y) so the first unit is top-left.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of units to place. |
required |
columns
|
int | None
|
Units per row. |
None
|
col_width
|
float
|
Horizontal spacing between columns. |
1.0
|
line_height
|
float
|
Vertical spacing between rows. |
1.0
|
Returns:
| Type | Description |
|---|---|
Coords
|
An |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Contract
- Returns exactly
nrows. - Coordinates are deterministic in
nand the spacing parameters.
Examples:
>>> linear_layout(3).tolist()
[[0.0, 0.0], [1.0, 0.0], [2.0, 0.0]]
>>> linear_layout(3, columns=2).tolist()
[[0.0, 0.0], [1.0, 0.0], [0.0, -1.0]]