Nodes/comfyui_dygen/DY Adaptive Color Rectangles
ComfyUI Node

DY Adaptive Color Rectangles

Mosaic tiles that rotate, stretch, and borrow image colors

By dymokomi·Created 2 years ago·Updated 2 years ago· 1
DY Adaptive Color Rectangles
  • image
  • IMAGE
num_rectangles10
min_size20
max_size100
aspect_ratio1.0
aspect_variance0.5
rotation0
alpha128
alpha_deviation20
outline_thickness0

DY Adaptive Color Rectangles is the most configurable member of the pack's "adaptive color" trio - the one with the most knobs and the most personality. It scatters random rectangles over your image, each filled with the color sampled from its own center point, and it's the only one of the three that lets you control shape, rotation, and outline. If the lines node makes hatching and the circles node makes dots, this one makes a genuine mosaic.

The adaptive-color core is the same as its siblings: a rectangle's fill is sampled from the pixel at the rectangle's center, so tiles over the sky become sky-colored and tiles over the subject become subject-colored. But the extra controls change the character completely. Crank the rotation and you get a Mondrian-by-way-of-dice collage; set the aspect_ratio wide and the tiles stretch into bricks; add an outline and every tile turns into a hard-edged sticker. It's the node you'd grab for architectural, collage, or low-poly-styled effects.

How it works

Each rectangle starts as a square of random size between min_size and max_size, then gets its aspect ratio perturbed around aspect_ratio by aspect_variance (a value of 1 stays square, 2 is twice as wide as tall). If rotation is above 0, the corner points are rotated by a random angle anywhere in ±rotation degrees. Then the color is sampled at the center, alpha is jittered around alpha, and the polygon is drawn on a transparent overlay and composited back. outline_thickness above 0 adds a full-opacity outline in the same sampled color.

The inputs that matter:

  • num_rectangles (1–100000) - density. 10 is sparse, 1000 is a full mosaic.
  • min_size / max_size - tile size range.
  • aspect_ratio (0.1–10) / aspect_variance - tile shape and how much it wanders.
  • rotation (0–180) - max tilt; 0 keeps everything axis-aligned.
  • alpha (default 128) / alpha_deviation - opacity. Half-transparent tiles blend; opaque tiles stack.
  • outline_thickness (0–50, default 0) - 0 = soft tiles, >0 = bordered ones.

The gotchas

Same family traits: no seed, so runs aren't reproducible; only the first image of a batch is processed; and a temp PNG preview thumbnail is returned on the node. Rotation is implemented with simple corner math (rotate the four points, no anti-aliasing), so heavily rotated tiles can look slightly jagged at the edges - fine for a collage aesthetic, less fine if you wanted buttery vector-clean shapes. And like the others, very high counts and high alpha will bury the source image under the tiles.

Install

Part of dymokomi/comfyui_dygen by Dy Mokomi. ComfyUI Manager → search "comfyui_dygen", or:

cd ComfyUI/custom_nodes
git clone https://github.com/dymokomi/comfyui_dygen

Restart. No extra deps, no models.

Bottom line

Between the three adaptive nodes, pick rectangles when you want structure - this is the one that can actually build a composition instead of just adding grain. Start square (aspect 1, rotation 0, no outline) to see the mosaic effect, then turn the knobs one at a time. It's fiddly, but it's the most expressive of the family.

CategoryDyGen/effects

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
num_rectanglesINT101–100000
min_sizeINT201–500
max_sizeINT1001–1000
aspect_ratioFLOAT1.00.1–10
aspect_varianceFLOAT0.50–5
rotationINT00–180
alphaINT1280–255
alpha_deviationINT200–255
outline_thicknessINT00–50

Outputs (1)

NameTypeDescription
IMAGEIMAGE