Nodes/BrainDead Nodes/BD Draw Rect
ComfyUI Node

BD Draw Rect

A rectangle node that's secretly a channel-pack swiss army knife

By BizaNator·Created 8 months ago·Updated 3 days ago· 15
BD Draw Rect
  • mask
  • image
  • packed_image
  • image
  • mask
  • packed_out
mask_from_packednone
pack_channelnone
x_center0.500
y_center0.500
rect_width0.200
rect_height0.100
corner_radius0
feather0
fill_r128
fill_g128
fill_b128
opacity1.00
canvas_width512
canvas_height512

A "draw a rectangle" node sounds like the least interesting thing in the pack, but BD Draw Rect earns its keep in two ways. First, it draws a flat-color rectangle with rounded corners and feathered edges - useful for compositing, UI masks, or just stamping a clean color region. Second - and this is the part people miss - the shape source isn't just geometry. Give it any ComfyUI mask and it will use that as the shape instead, feather it, and write it into a specific channel of a packed RGBA image. It's a color-compositor and a channel-packer in one box.

How it picks its shape

Three sources, in priority order:

  1. mask input - any MASK you wire wins; geometry is skipped entirely.
  2. mask_from_packed - extract one R/G/B/A channel from a packed_image and use that as the shape (handy when a packed RGBA already holds a useful mask in one channel).
  3. geometry - the rectangle from x_center / y_center (normalized 0–1) and rect_width / rect_height (fractions of the canvas, can exceed 1.0), with corner_radius (pixels, clamped to half the shortest side) for rounded corners.

feather applies to whichever source is active: positive expands outward (interior stays fully opaque), negative bleeds inward, 0 is a hard edge. fill_r/g/b pick the color, opacity blends it over the base image (default 1.0 = fully opaque).

Outputs: image (the fill composited onto the base image, or onto a blank canvas_width × canvas_height canvas if no image is wired), mask (the feathered shape itself), and packed_out - the packed_image with your mask written into pack_channel (R/G/B overwrite, or A appended if the image has no alpha).

Installing

It ships in ComfyUI-BrainDead:

cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt

or ComfyUI Manager → search "BrainDead" → install, then restart. No models, no extra deps.

Where people get burned

Almost nowhere - this is a small, well-scoped node - but two things trip people: forgetting that a wired mask beats your carefully-set geometry values (disconnect it to use the rect), and expecting feather to soften a shape in place when it actually expands outward by default. If the soft edge is eating into the area you wanted, flip the sign.

Category🧠BrainDead/Segmentation

Inputs (17)

NameTypeDefaultDescription
mask_from_packedCOMBOnoneExtract a channel from packed_image and use it as the shape mask. Ignored when mask is connected. none = fall through to geometry.
pack_channelCOMBOnoneWrite the final feathered mask into this channel of packed_image. none = pass packed_image through unchanged. R/G/B = overwrite that colour channel. A = overwrite alpha (appended if image has no alpha).
x_centerFLOAT0.5000–1Horizontal center (0=left, 1=right). Ignored when mask is connected.
y_centerFLOAT0.5000–1Vertical center (0=top, 1=bottom).
rect_widthFLOAT0.2000–2Width as fraction of image width. >1.0 extends beyond the edge.
rect_heightFLOAT0.1000–2Height as fraction of image height.
corner_radiusINT00–400Rounded corner radius in pixels. 0 = sharp corners. Clamped to half the shortest side.
featherINT0-200–200Edge feather in pixels (applied to any shape source). Positive: expands OUTWARD — interior stays fully opaque. Negative: bleeds INWARD — fill fades toward its edge. 0 = hard binary edge.
fill_rINT1280–255Fill red. Default 128 = mid-grey.
fill_gINT1280–255Fill green.
fill_bINT1280–255Fill blue.
opacityFLOAT1.000–1Blend strength over the base image. 1.0 = fully opaque.
maskoptMASKShape mask. When connected, skips rect geometry and uses this mask directly (feather still applies). Priority: mask > mask_from_packed > geometry.
imageoptIMAGEBase image to composite onto. If not connected, a blank canvas (canvas_width × canvas_height) is used.
packed_imageoptIMAGEExisting packed RGBA image. pack_channel: write the final mask into this channel. mask_from_packed: extract a channel as the shape source. Typical use: u_image3 RGBA pack for skin_shader.glsl.
canvas_widthoptINT5121–8192Canvas width when no image is connected.
canvas_heightoptINT5121–8192Canvas height when no image is connected.

Outputs (3)

NameTypeDescription
imageIMAGEShape composited over image (or blank canvas).
maskMASKFinal feathered shape mask (1.0 inside, 0.0 outside).
packed_outIMAGEpacked_image with mask written into pack_channel. Pass-through (or blank) when pack_channel='none'.