Nodes/ComfyUI_DAO_master/Opération Booléenne SVG
ComfyUI Node

Opération Booléenne SVG

SVG union, difference, intersection, XOR

By orion4d·Created about a year ago·Updated 12 months ago· 11
Opération Booléenne SVG
  • svg_a
  • svg_b
  • SVG_TEXT
operation
curve_quality60

Illustrator has the Pathfinder panel for this. Inkscape has boolean paths. ComfyUI - usually - has nothing, because ComfyUI is pixel land. SVG Boolean is the exception: it takes two SVG shapes and performs real geometry boolean operations on them - union, difference, intersection, XOR - and returns a clean combined SVG path. If you've ever wanted to punch a hole through a generated shape, merge two logos into one outline, or intersect a design with a boundary, this is the node.

How it works

The node converts each input SVG's paths into polygons using a curve_quality-controlled flattening (higher = finer sampling of curves, more vertices). The two polygon sets are fed to the pyclipper library - the same polygon clipping engine behind many vector editors - which computes the operation and returns the resulting outline(s). Those are converted back into an SVG path d attribute, and the output viewBox is computed from the union of the two inputs' view boxes (or falls back to 0 0 512 512 if it can't be determined).

The four operations:

  • union - both shapes merged into one outline.
  • difference - shape B is subtracted from shape A (that's the "punch a hole" one).
  • intersection - only the overlapping region survives.
  • xor - everything except the overlap.

Inputs that matter

  • svg_a, svg_b - the two source SVG_TEXT inputs. Order matters for difference (A minus B).
  • operation - the four-way choice above.
  • curve_quality (default 60, range 10–400) - how finely curves are approximated as polygons before clipping. Crank it up if you see faceted curves in the output; the cost is bigger, slower geometry.

Outputs

A single SVG_TEXT output containing a <path> with the boolean result. Feed it to SVG Style to color it, SVG Preview to rasterize, or SVG Save to write the file.

How to install

Part of the orion4d/ComfyUI_DAO_master pack:

cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/ComfyUI_DAO_master.git
pip install lxml pyclipper

Restart ComfyUI. No models.

Common issues

The node throws a clear error if svg_a is empty ("Le SVG 'A' est vide"), and requires svg_b for everything except union - so a missing input is easy to diagnose. The viewBox fallback of 512x512 can make the result render oddly if the inputs lack view boxes; using SVG Load (which ensures a viewBox) upstream avoids that. And if you're wondering why curves look polygonal, that's curve_quality - 60 is a middle ground, but for large or highly-curved shapes you may want 100+. One more: this produces geometry, not styling - the result comes out as bare paths, so you'll almost always want a SVG Style right after.

CategoryDAO_master/SVG

Inputs (4)

NameTypeDefaultDescription
svg_aSVG_TEXT
svg_bSVG_TEXT
operationCOMBO4 options: union, difference, intersection, xor
curve_qualityINT6010–400

Outputs (1)

NameTypeDescription
SVG_TEXTSVG_TEXT