Nodes/Dream Painter/✎ Draw Shape As Bitmap
ComfyUI Node

✎ Draw Shape As Bitmap

Turn a vector shape into pixels you can actually use

By alt-key-projectΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 2
✎ Draw Shape As Bitmap
  • SHAPE
  • BITMAP
β—„fillβ–Ύβ–Ί
β—„draw_modeβ–Ύβ–Ί
β—„shape_bound_x_min0.00β–Ί
β—„shape_bound_y_min0.00β–Ί
β—„shape_bound_x_max1.00β–Ί
β—„shape_bound_y_max1.00β–Ί
β—„bitmap_width512β–Ί
β—„bitmap_height512β–Ί
β—„line_width1β–Ί

Here's where the geometry becomes real. Dream Painter splits its world into two halves: SHAPE objects, which are pure vector data floating in a normalized 0–1 coordinate space, and BITMAPs, which are actual pixels. Draw Shape As Bitmap is the node that crosses that line - it rasterizes a shape onto a canvas and hands you a one-bit bitmap, ready for the converters that push it into the rest of ComfyUI.

If you're following the pack's standard flow, this node sits right after your shape generation and before Bitmap To Image & Mask: shape β†’ Draw Shape As Bitmap β†’ Bitmap To Image & Mask β†’ ControlNet or mask. It's the step every example workflow in the repo runs, because without it a shape is just an invisible bundle of coordinates.

How it works

The shape lives in a normalized viewport - by default the region from (0,0) to (1,1), controlled by the four shape_bound_* inputs. The node scales that viewport onto your canvas (bitmap_width Γ— bitmap_height, default 512Γ—512) and draws the shape's polygons with Pillow.

The parameters that matter:

  • fill - yes draws solid filled polygons; no draws just the outlines (stroke width from line_width).
  • draw_mode - normal paints over the canvas; xor toggles pixels, so overlapping shapes cancel out. The xor mode is how the pack's checkerboard example builds a pattern where every other cell is the "not" of its neighbor.
  • bitmap_width / bitmap_height - the output resolution. Higher = crisper guide, but remember ControlNet likes powers of two in many setups.
  • shape_bound_x_min / y_min / x_max / y_max - the viewport rectangle. Zoom into part of the shape's space by shrinking this box; widen it to fit more.

Inputs and outputs

  • SHAPE, fill, draw_mode, shape_bound_x_min, shape_bound_y_min, shape_bound_x_max, shape_bound_y_max, bitmap_width, bitmap_height, line_width.

Output:

  • BITMAP - the rendered one-bit bitmap.

Installing

From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β†’ Install Custom Nodes β†’ search Dream Painter β†’ install β†’ restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt

No models, no downloads.

Common issues

The most common surprise is the viewport: if your shape's coordinates don't fit the default (0,0)-(1,1) box, you'll render a blank or clipped bitmap. That's what Shape Center & Fit is for - normalize your shape into the 0–1 box before rendering and the default viewport just works. Second: rendering at low resolution then upscaling the bitmap gives chunky edges; render at the resolution you actually want. And if the drawing looks backwards polarity-wise, remember the pack paints white on black by default - flip with Bitmap Invert or recolor at the conversion step.

CategoryπŸ–Œ DPaint/β–© bitmap

Inputs (10)

NameTypeDefaultDescription
SHAPESHAPEβ€”
fillCOMBO2 options: yes, no
draw_modeCOMBO2 options: normal, xor
shape_bound_x_minFLOAT0.00β€”
shape_bound_y_minFLOAT0.00β€”
shape_bound_x_maxFLOAT1.00β€”
shape_bound_y_maxFLOAT1.00β€”
bitmap_widthINT512β€”
bitmap_heightINT512β€”
line_widthINT1β€”

Outputs (1)

NameTypeDescription
BITMAPBITMAPβ€”