Nodes/Dream Painter/β—― Shape of N-Polygon
ComfyUI Node

β—― Shape of N-Polygon

One node for every polygon, from triangle to 'just call it a circle'

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

    Need a triangle for a composition? A hexagon for a "futuristic tech UI" ControlNet pass? Or something with 200 edges that reads as a soft ellipse? Shape of N-Polygon [DPaint] is the one node in the Dream Painter pack that covers all of those, because the polygon's edge count is just a slider. It's from alt-key-project/comfyui-dream-painter, the MIT-licensed kit for drawing simple geometry that guides image generation rather than being the final art - the README calls it "quick-and-dirty," and that's the whole point: you're building the structure map, not the artwork.

    What it actually does

    The node computes N points around a center using plain sine and cosine - one vertex per edge, laid out on an ellipse defined by width and height - and returns them as a single filled polygon shape. Set edges to 3 and you get a triangle; 5, a pentagon; 28, something that only squints at being round; up to 1000, a perfect circle. The docstring calls it a "rounded polygon," but don't read anything fancy into that - it's a regular polygon whose corners sit on an ellipse, not a polygon with filleted corners.

    The inputs you actually set:

    • edges - 3 to 1000. The whole point of the node. 3 for a triangle, 5–6 for classic shapes, 50+ for a disc. This is the only input you'll touch most of the time.
    • shape_width / shape_height - the ellipse the vertices ride on. Equal values give a regular polygon; stretch them apart and you get a squashed, lens-shaped one. Defaults are 0.75/0.75, in the normalized 0–1 space Dream Painter uses.
    • center_x / center_y - where the polygon sits. Default 0.5/0.5 is dead center of the frame.

    Everything outputs through a single SHAPE socket. The node renders nothing on its own - a shape is just a list of vector points until you draw it. Feed the SHAPE into Draw Shape As Bitmap [DPaint] to rasterize it, then Bitmap To Image & Mask [DPaint] turns that bitmap into an IMAGE and a MASK. The IMAGE can go straight into a ControlNet as a structure condition (it pairs naturally with the scribble/canny-style conditions - rough geometry in, the model fills in the surface); the MASK is handy if you want a masked region shaped like a polygon for inpainting or a detail pass.

    Installing it

    It ships with the whole pack, so the install is the same as every other Dream Painter node:

    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. Restart ComfyUI afterward. No model files, no keys, nothing heavy - just Pillow, scipy, numpy (pinned <2.0.0), and a few small helpers. That numpy pin is the one dependency gotcha: pip may downgrade a numpy 2 environment, which can upset other packs.

    Common gotchas

    Two things to keep in mind. First, the edge count grows visually fast: 12 edges already looks roundish at small sizes, so if you want something that reads as a polygon, stay in the 3–8 range. Second, remember the fill setting on Draw Shape As Bitmap - a polygon with fill: no renders as a stroked outline, which is a very different ControlNet condition than the solid version. Render to a bitmap and preview before wiring it into the sampler; with a shape this cheap to regenerate, iteration is basically free.

    CategoryπŸ–Œ DPaint/β–’ shape

    Inputs (5)

    NameTypeDefaultDescription
    shape_widthFLOAT0.75β€”
    shape_heightFLOAT0.75β€”
    center_xFLOAT0.50β€”
    center_yFLOAT0.50β€”
    edgesINT123–1000β€”

    Outputs (1)

    NameTypeDescription
    SHAPESHAPEβ€”