Nodes/Dream Painter/⌧ Shape Center & Fit
ComfyUI Node

⌧ Shape Center & Fit

Get any shape back into the 0–1 box before you render it

By alt-key-projectΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 2
⌧ Shape Center & Fit
  • SHAPE
  • SHAPE
β—„proportionalβ–Ύβ–Ί
β—„border0.00β–Ί

Shapes in Dream Painter live in a normalized coordinate space - the 0–1 box - but nothing forces them to stay there. Stretch them, copy them, flip them, and suddenly a shape's bounds are somewhere out at (2.3, -0.8) and the renderer's default viewport doesn't see it anymore. Shape Center & Fit is the reset button: it centers a shape and scales it to fit neatly inside the (0,0)–(1,1) box, so the rest of the pipeline behaves.

Think of it as the shape equivalent of pressing "frame to fit" in a vector editor. The pack's own Draw Shape As Bitmap renders using a default viewport of (0,0) to (1,1), so a shape that's drifted outside that box renders as a clipped or invisible mess. Running it through Center & Fit first guarantees it lands fully visible, centered, and at a predictable size - which is why this node shows up as the sanity check before rendering in a lot of workflows.

How it works

The node measures the shape's current bounds, then scales it so its width and height fit inside the target box (minus any border you want as margin), and translates it so its center sits at (0.5, 0.5) - the middle of the normalized space.

  • proportional - yes scales uniformly (aspect ratio preserved), fitting within the box on the tightest axis. no stretches the shape to fill the box exactly, distorting it if the aspect ratios differ. For most geometry you want yes; no is for deliberately filling a rectangle.
  • border - fractional margin around the shape, 0 to 0.49. 0.1 leaves 10% breathing room on each side.

Inputs and outputs

  • SHAPE - the shape to normalize.
  • proportional - yes / no.
  • border - 0.0 to 0.49, default 0.

Output:

  • SHAPE - the centered, fitted shape.

Installing

From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β†’ Install Custom Nodes β†’ search Dream Painter β†’ install β†’ restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt

No models, no downloads.

Common issues

The biggest trap is expecting this node to be a general "scale to any size" tool. It always fits to the unit box - if you want a shape that fills half the canvas, add border, don't try to scale the output afterward (or use Shape Resize, which scales in either global or shape coordinates). Also note it normalizes within the 0–1 space; a shape already inside the box gets recentered and possibly rescaled anyway, so running it twice changes nothing but running it once after a Copycat trail is exactly what you want to tidy the result.

CategoryπŸ–Œ DPaint/β–’ shape

Inputs (3)

NameTypeDefaultDescription
SHAPESHAPEβ€”
proportionalCOMBO2 options: yes, no
borderFLOAT0.000–0.49β€”

Outputs (1)

NameTypeDescription
SHAPESHAPEβ€”