Build Layout Panels
Where the abstract layout becomes real shapes
- layout
- canvas
- POLYGON
comfyui-panels has a two-stage design, and this is the node where stage one becomes stage two. Stage one is a layout: an abstract tree of cuts describing "split the page here, then split that half again." Stage two is panels: actual shapely polygons with concrete coordinates on a canvas. Build Layout Panels is the hand-off between them.
You'll reach for it immediately after generating or loading a layout - from Grid Panel Layout Generator, Random Panel Layout Generator, or Load Panel Layout. The layout alone is useless until you run it through this node; the output is the list of panel polygons you can then grow, bevel, convert to masks, or draw edges around.
How it works
The node walks the cut tree and applies each cut to the canvas polygon. A cut is either vertical or horizontal, can have a slight angle, and splits a panel at a relative position (midpoint, thirds, golden-ratio-ish positions - the pack hardcodes those split points). The margin input sets the gap between panels created by the first cut, and nested cuts automatically use smaller gaps, which is how the pack creates that classic "nested panels read as grouped" effect. Cut order also determines panel reading order: for a left-to-right layout, a vertical cut puts the left-side panels before the right-side panels in the output list, recursively.
The inputs that matter
layout- thePANEL_LAYOUTcut tree.canvas- the rectangle you're cutting into panels (from Canvas Panel). The layout is proportional; the canvas decides actual pixel coordinates.margin- default 32 pixels between first-cut panels. Set it to 0 for edge-to-edge panels.reading_dir- off means left-to-right, on flips the whole thing for right-to-left (manga) reading. This is a horizontal mirror of the geometry, not just a sort order.
Output is a list of POLYGONs, ordered by reading sequence.
Installing it
Part of comfyui-panels - install via Manager (search "comfyui-panels") or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_panels
Restart, install deps (shapely, matplotlib, opencv-python). No models.
Where people get burned
The margin subtlety trips people up: the margin you type only applies to the first cut, and nested cuts get progressively smaller gaps automatically. If your deeply nested layout has panels touching when you expected gaps, that's the design, not a bug. Also remember the list order is the reading order - if you're doing per-panel generation and your story reads right-to-left, flip reading_dir rather than re-sorting the list afterward.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| layout | PANEL_LAYOUT | Root node of the 'abstract' cut's tree. | |
| canvas | POLYGON | A box shaped polygon representing the area to be cut into the panels. | |
| margin | INT | 320–1000 | The distance (in pixels) between the panels formed by the 1st cut.The distance for nested cuts decreases the higher the depth in the layout hierarchy. |
| reading_dir | BOOLEAN | false | Invert the panel layout horizontally to be read from right to left. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| POLYGON | POLYGON | Panels (Shapely Polygons) |