Construct Mask
Rectangle, ellipse, or triangle, positioned and rotated
- MASK
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, ortriangle.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
strength0 = black mask. A strength of exactly 0 short-circuits to an all-black mask. It's the documented "nothing" value, not a bug.x/yis the center, not the corner. The most common mispositioning - the shape is centered onx/y, so don't expect top-left coordinates.- Negative
x/ymeans 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.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
| shape | COMBO | rectangle | 3 options: rectangle, ellipse, triangle |
| shape_width | INT | 2561–8192 | — |
| shape_height | INT | 2561–8192 | — |
| x | INT | 256-8192–8192 | — |
| y | INT | 256-8192–8192 | — |
| angle | FLOAT | 0.0-360–360 | — |
| border_radius | INT | 00–2048 | — |
| blur | INT | 00–2048 | — |
| strength | FLOAT | 1.000–1 | — |
| antialiasing | INT | 21–4 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |