pyboxbuilder.layout¶
Declarative layout — say how the boxes are arranged, not where they sit (T186).
There is a gap between the two ways of placing boxes. Free-form packing works below roughly 70% fill and gives up above it; explicit coordinates always work but have to be recomputed by hand whenever a box changes size. Real inserts sit in that gap: they are densely packed and highly structured — three columns of stacked trays, not an arbitrary arrangement.
This module lets the structure be written down and the coordinates derived:
project.arrange(columns(
rows( # left column
stack("PlayerBoxBlack", "PlayerBoxYellow"),
stack("PlayerBoxRed", "PlayerBoxBlue"),
),
rows("CardBoxFavor", "CardBoxHero"), # middle column
))
columns runs along X, rows along Y, stack along Z. Groups nest freely, so a stack can end in a pair of rows. Each child starts where the previous one ended; a group is as wide as its widest child on the axes it does not consume.
Classes
The result of resolving a layout tree. |
|
A run of boxes or sub-groups laid end to end along one axis. |
|
A tessellated regular-polygon lattice (e.g., hexagonal honeycomb) of boxes. |
Functions
Resolve a layout tree into a position per box. |
|
Return the labels of boxes the project has but the layout leaves out. |
|
Lay children out left to right along X. |
|
Extent of a node: children sum along its axis and max on the other two. |
|
Lay regular-polygon boxes out in a tessellated honeycomb/triangle/square grid. |
|
Lay children out front to back along Y. |
|
Lay children out bottom to top along Z. |