Nodes/Dream Painter/β–… Shape of Rectangle
ComfyUI Node

β–… Shape of Rectangle

Boring on purpose, and that's its strength

By alt-key-projectΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 2
β–… Shape of Rectangle
    • SHAPE
    β—„shape_width0.75β–Ί
    β—„shape_height0.75β–Ί
    β—„center_x0.50β–Ί
    β—„center_y0.50β–Ί

    Sometimes the most useful node in a drawing kit is the plainest one. Shape of Rectangle [DPaint] makes a rectangle shape - that's it, that's the whole job - and it earns its place because rectangles are the backbone of so much composition: a window, a doorway, a frame-within-a-frame, a "product on a plinth" blockout. It comes from the Dream Painter pack (alt-key-project/comfyui-dream-painter), a small MIT-licensed set of nodes for drawing simple geometry to guide image generation. You're making the map, not the art - the README is explicit that these are "not intended to produce the final artwork."

    In a wider workflow this is the node you reach for when you want a hard rectangular boundary the model has to respect: feed it through Draw Shape As Bitmap [DPaint], then Bitmap To Image & Mask [DPaint], and use the IMAGE as a ControlNet condition (a box edge reads like a structure map, handy for framing or architecture work) or the MASK to fence off a region for inpainting or a separate detail pass.

    What it actually does

    The mechanism could not be simpler. It takes a width and a height, centers them on a point, and returns the four corners as a polygon shape. Rendering it as a bitmap with fill: yes gives you a solid block; fill: no gives you just the outline, which is the one that works best as a ControlNet structure guide - the model gets four clean lines to work with instead of a slab of white.

    The four inputs:

    • shape_width / shape_height - the size of the rectangle in normalized 0–1 coordinates. Defaults 0.75/0.75. Think of 1.0 as the full frame.
    • center_x / center_y - where the rectangle's middle sits. Default 0.5/0.5 puts it dead center.

    Output is a single SHAPE socket. Rectangle is also the natural thing to test the pack with before you get clever: it's the same SHAPE data type every other node in the pack uses, so it's a great first node to drag in, render, and see how the whole shape→bitmap→image pipeline behaves.

    Installing it

    Same install as every node in the pack:

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

    or search "Dream Painter" in ComfyUI Manager and restart. No models, no API keys - just Pillow, scipy, and numpy (pinned <2.0.0, which is the one thing to watch: pip may downgrade numpy 2 environments to satisfy it, and other packs can grumble).

    Common gotchas

    Not much to trip on with a rectangle, which is the point. The two things to remember are the fill setting on Draw Shape As Bitmap (solid block vs. outline produces very different ControlNet conditions) and the normalized coordinate space - a 0.75Γ—0.75 rectangle centered at 0.5 already nearly touches the frame edges, so if your shape looks like it's spilling out of the render bounds, shrink the width/height before you blame the viewport. Preview the bitmap before it hits the sampler; iteration is nearly free at this level of complexity.

    CategoryπŸ–Œ DPaint/β–’ shape

    Inputs (4)

    NameTypeDefaultDescription
    shape_widthFLOAT0.75β€”
    shape_heightFLOAT0.75β€”
    center_xFLOAT0.50β€”
    center_yFLOAT0.50β€”

    Outputs (1)

    NameTypeDescription
    SHAPESHAPEβ€”