Nodes/ComfyUI-Rect/Rect / Fill
ComfyUI Node

Rect / Fill

Paint a box that was never really painted

By jtrue·Created about a year ago·Updated about a year ago· 3
Rect / Fill
  • image
  • rect
  • image
r255
g0
b0
opacity1.00
modefill
thickness4
feather0

Every so often you don't want to generate over a region - you want to cover it. A redaction bar over a face or a license plate. A solid block to mark where a cutout goes. A colored outline to draw attention to a detail for a mockup. Rect / Fill is the node for that: give it a rectangle and a color, and it returns your image with a filled or outlined box composited over the region. It's the pack's answer to "what if I just needed a box drawn."

How it works

Under the hood it's a clean alpha composite rather than a destructive paint. The node builds a per-pixel alpha mask over the rectangle (all ones inside, zeros outside), optionally feathers that mask with a Gaussian blur, scales it by your opacity, and blends: out = alpha * color + (1 - alpha) * image. Because it's a blend, not a write, opacity 0.5 gives you a genuine see-through tint and the original pixels survive untouched underneath. In outline mode it draws the mask as a ring by subtracting an inner rectangle, so thickness controls how fat the border is.

That compositing approach is also what makes it feel safe: it's non-destructive, bounds-clamped (a box hanging off the edge just paints the part that fits), and batch-aware, so it handles a stack of frames without drama.

Inputs that matter

  • image + rect - the image to paint on, and the rectangle (feed it the rect output of the pack's Rect / Select node and you never type coordinates again).
  • r, g, b - the color, 0–255, default a loud red. That default is a clue: it's aimed at obvious redaction bars and callouts, not subtle edits.
  • opacity - 0 to 1. 1.0 fully covers; lower values give a tint that lets the image show through.
  • mode - fill for a solid block, outline for just the border.
  • thickness - outline width in pixels (default 4), ignored in fill mode.
  • feather - softens the edges of the fill, which reads as a gentle glow or a blurred redaction rather than a hard block.

The single output, image, is a normal IMAGE you can preview, save, or keep feeding down the graph.

What you'd actually use it for

  • Redaction. Slap a solid box over a face, a name tag, a plate. opacity = 1 is a real redaction; a low-opacity box is just a privacy tint.
  • Callouts and annotations. An outline box with a bright color marks a region in a way that survives being upscaled - handy for explaining a workflow in a screenshot.
  • Mockups and placeholders. Block out where a UI element or a cutout is supposed to land before you generate into it.

It's a small tool with a small job. That's fine - in a workflow that's otherwise all heavy machinery, a node that reliably draws a colored box is the boring, dependable workhorse.

Install

ComfyUI Manager (search "ComfyUI-Rect") or:

cd ComfyUI/custom_nodes
git clone https://github.com/jtrue/ComfyUI-Rect

Restart. No model files, no requirements.txt - the entire pack is stock PyTorch, so this installs in seconds and breaks nothing.

Gotchas

  • thickness only matters in outline mode. In fill mode it's ignored, so don't wonder why the number does nothing.
  • feather is a blur, not a border tool. It softens the whole fill's edge into a gradient - a subtle glow, not a rounded rectangle. If you want crisp rounded corners, this isn't the tool.
  • The RECT type. As everywhere in this pack, the rectangle has to come from Rect / Select's rect output. Draw the box once, reuse it across Crop, Mask, and Fill.

For anything that is "put a box of color over this region," Rect / Fill is the shortest path from idea to done in ComfyUI, and it doesn't ask you to install a single dependency for the privilege.

CategoryRect

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
rectRECT
rINT2550–255
gINT00–255
bINT00–255
opacityFLOAT1.000–1
modeSTRINGfill
thicknessINT41–1024
featherINT00–256

Outputs (1)

NameTypeDescription
imageIMAGE