Nodes/TJ_PolkaDot/Advanced Shape Placement
ComfyUI Node

Advanced Shape Placement

Advanced shape placement with region control and metadata output. Places multiple instances of a shape mask within a region mask, with control over count, scale, rotation, and overlap. Outputs both the composite mask and JSON metadata for each placement.

By TJ16th·Created 9 months ago·Updated 9 months ago· 2
Advanced Shape Placement
  • shape_mask
  • region_mask
  • base_mask
  • exclusion_mask
  • MASK (all)
  • MASK (new)
  • JSON
count30
scale_min0.060
scale_max0.150
rotation_min-30
rotation_max30
overlap_ratio0.50
coverage_min0.00
exclusion_tolerance0.00
out_of_bounds_tolerance0.00
max_consecutive_fails100
seed0
debug_mode0
CategoryTJ_PolkaDot

Inputs (16)

NameTypeDefaultDescription
shape_maskMASKBase shape mask to place multiple times
countINT301–200Number of shapes to place
scale_minFLOAT0.0600.005–5Minimum scale factor
scale_maxFLOAT0.1500.005–5Maximum scale factor
rotation_minFLOAT-30-180–180Minimum rotation angle in degrees
rotation_maxFLOAT30-180–180Maximum rotation angle in degrees
overlap_ratioFLOAT0.500–1Maximum overlap ratio with existing shapes (0=no overlap, 1=full overlap allowed)
coverage_minFLOAT0.000–1Minimum coverage ratio in region mask (0.0=any overlap OK, 1.0=must be fully inside region)
exclusion_toleranceFLOAT0.000–1Maximum allowed intrusion ratio into exclusion zones (0=strict prohibition, 1=full intrusion allowed)
out_of_bounds_toleranceFLOAT0.000–1Maximum allowed out-of-bounds ratio (0=shapes must be fully inside canvas, 1=shapes can be completely outside)
max_consecutive_failsINT10010–1000Maximum consecutive failures before early termination (10-1000)
seedINT00–4294967295Random seed for reproducibility
debug_modeINT00–1Enable detailed debug output (0=off, 1=on)
region_maskoptMASKOptional region mask defining where shapes can be placed (if not provided, uses full canvas)
base_maskoptMASKOptional base mask to combine with (for chaining multiple placements)
exclusion_maskoptMASKOptional exclusion zone mask where shapes should not be placed

Outputs (3)

NameTypeDescription
MASK (all)MASKCombined mask with all placed shapes (includes base_mask if provided)
MASK (new)MASKOnly the newly added shapes (excludes base_mask)
JSONSTRINGJSON array with position, scale, rotation for each shape