Nodes/ComfyUI Extended/Construct Mask
ComfyUI Node

Construct Mask

Rectangle, ellipse, or triangle, positioned and rotated

By rookiepsi·Created about a year ago·Updated 11 months ago· 9
Construct Mask
    • MASK
    width512
    height512
    shaperectangle
    shape_width256
    shape_height256
    x256
    y256
    angle0.0
    border_radius0
    blur0
    strength1.00
    antialiasing2

    Sometimes you don't want to paint a mask by hand or load one - you want a clean geometric region, exactly placed, exactly sized. Construct Mask builds one from parameters: pick a rectangle, ellipse, or triangle, set its size, position, rotation, corner radius, blur, and strength, and get a proper MASK tensor out. It's the most "all-in-one" node in ComfyUI Extended, added in the pack's 1.2.0 release.

    Think of it as a parameterized stencil. Where it shines: making a circular region for an inpaint test, a rounded rectangle for a UI element you're compositing, or a triangle you'd rather not freehand with the mask editor.

    Inputs that matter

    Mostly defaults, and only a handful you'll actually touch:

    • width / height (INT, up to 8192) - the canvas the mask is drawn on.
    • shape - rectangle, ellipse, or triangle.
    • shape_width / shape_height - the shape's own size on that canvas.
    • x / y (INT, can go negative) - the center of the shape. Off-canvas centers are clipped, which is how you'd build a mask that's deliberately cut by the edge.
    • angle (FLOAT, −360 to 360) - rotation, applied after drawing.
    • border_radius (INT) - rounds rectangle corners; on a triangle it's faked with a blur-and-threshold pass.
    • blur (INT) - a final Gaussian blur for feathering.
    • strength (FLOAT, 0–1) - global opacity of the mask. 0 returns an all-black mask.
    • antialiasing (INT, 1–4) - the supersampling factor used while drawing; higher = cleaner diagonal edges.

    How it works

    Under the hood it draws the shape on a supersampled PIL canvas (that's what antialiasing controls - the shape is rendered at 2×, 3×, or 4× and downsampled with Lanczos), rotates it if needed, pastes it centered at x/y onto a black canvas, then applies blur and strength. Because the drawing happens at a higher resolution first, the diagonal edges on a rotated rectangle come out smooth instead of stairstepped.

    Install

    cd /path/to/your/ComfyUI/custom_nodes
    git clone https://github.com/rookiepsi/comfyui-extended.git
    

    Restart ComfyUI; it's under ComfyUI-Extended/Mask in the menu (yes, that capitalization differs from the pack's other mask nodes - that's how it's registered). Or ComfyUI Manager → "ComfyUI Extended" → install → restart. Zero dependencies.

    Common issues

    • strength 0 = black mask. A strength of exactly 0 short-circuits to an all-black mask. It's the documented "nothing" value, not a bug.
    • x/y is the center, not the corner. The most common mispositioning - the shape is centered on x/y, so don't expect top-left coordinates.
    • Negative x/y means clipped. The shape is pasted relative to center and cropped at the canvas edge. Deliberate, and useful once you know it.
    • Triangle corner radius is approximate. It's a blur-and-threshold approximation, so it won't be as clean as the rectangle's true rounded corners. Don't sweat it.

    The verdict: it's the node for "give me a clean region, right now, no painting." For anyone doing structured inpaint or composite tests, that's worth its weight.

    CategoryComfyUI-Extended/Mask

    Inputs (12)

    NameTypeDefaultDescription
    widthINT5121–8192
    heightINT5121–8192
    shapeCOMBOrectangle3 options: rectangle, ellipse, triangle
    shape_widthINT2561–8192
    shape_heightINT2561–8192
    xINT256-8192–8192
    yINT256-8192–8192
    angleFLOAT0.0-360–360
    border_radiusINT00–2048
    blurINT00–2048
    strengthFLOAT1.000–1
    antialiasingINT21–4

    Outputs (1)

    NameTypeDescription
    MASKMASK