ComfyUI Node

Grow Panel

Push one edge of a panel out, leave the rest alone

By bmad4ever·Created 12 months ago·Updated 2 months ago· 41
Grow Panel
  • polygon
  • POLYGON
cardinalsN
along_normalfalse
distance256.0

In comic workflows you constantly want "this panel, but a bit bigger" - a panel that bleeds off the page edge, a panel that eats into its neighbor for a dramatic close-up, or one that just needs a little breathing room. A plain scale operation won't do that: it grows the whole shape from its center. Grow Panel grows specific sides of a polygon, which is a completely different gesture and the one you actually want for panel layout.

You give it a polygon, tell it which cardinal directions to grow (N, S, E, W - the letters map to up/down/left/right), and a distance in pixels. Negative distance shrinks instead. So "E" with distance 128 pushes the right edge of the panel out 128 pixels; "NS" grows it top and bottom.

How it works

This is the most mathematically interesting node in the pack, and it's worth knowing roughly what it's doing because it affects results. The algorithm clusters the polygon's vertices into four corner groups using cv2.kmeans, identifies the four edges, then moves only the vertices that belong to the edges you selected. The along_normal toggle changes how those vertices move: along the edge's own normal (best for slanted or angled panel borders, so the new edge stays parallel) versus along the pure cardinal direction (grid-aligned movement, what you want for rectangular panels on a standard page).

One thing the "4-sided" name implies: it assumes a roughly four-sided shape. Feed it a wildly irregular recovered polygon and the kmeans corner-clustering is doing its best guess, not geometry you fully control.

The inputs that matter

  • polygon - the panel to grow.
  • cardinals - a string of N, S, E, W in any combination, like "NE". Case doesn't matter; it's uppercased internally.
  • distance - pixels to move, float, default 256, and negative values shrink. The range goes from −512 to 2048, so a shrink is fully supported.
  • along_normal - the mode switch described above; leave it off for rectangular grid panels.

One POLYGON output, ready to feed the next transform or a Panel to Mask.

Installing it

Part of comfyui-panels - Manager, search "comfyui-panels", or:

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_panels

Restart, install deps (shapely, matplotlib, opencv-python - yes, opencv is here just for kmeans), no models.

Where people get burned

Two things. First, GrowPanel and Canvas Panel disagree on coordinate origin - the pack uses image-style Y-down coordinates, so N (up) moves toward the top edge; that's intuitive enough, just don't flip it in your head. Second, if you want to grow a whole panel uniformly, this is the wrong tool - use Scale/Offset nodes instead. And when you're using the helper strings, the pack ships tiny nodes that make life easier: Invert Cardinals and Complementary Cardinals both live in this pack for exactly this workflow, so you can wire growth directions dynamically rather than typing them by hand.

CategoryBmad/Panels

Inputs (4)

NameTypeDefaultDescription
polygonPOLYGON
cardinalsSTRINGNA combination of the letters N, S, E, and W, indicating in which cardinal directions the shape will grow.
along_normalBOOLEANfalseIf True, move along edge normal; if False, move along cardinal direction.
distanceFLOAT256.0-512–2048

Outputs (1)

NameTypeDescription
POLYGONPOLYGON