Combine two shapes as geometry: union, intersection, difference or exclusive-or over their closed rings.
Arguments
- a, b
The operands: a
path_grob(), apolygon_grob(), or a list withx,yand optionallynper(points per ring).- op
One of
"union","intersect","difference"(aminusb), or"xor".- rule
Fill rule for interpreting the inputs:
"nonzero"(default) or"evenodd".- gp, name, vp, role
Passed to the returned
path_grob().
Value
A path_grob() with rule = "winding". An empty result (a
disjoint intersection, say) gives a grob with no points, which draws
nothing.
Why geometry and not a mask
vellum can already clip one shape by another at render time, and for simply
showing an intersection that is often enough. A boolean result is different
in kind: it is an ordinary path, so it can be measured, hit-tested,
simplified, filled with a gradient, stroked, exported as <path> data, and
fed into another boolean. A mask can do none of those, rasterises, and
degrades on some PDF paths.
Rings, holes and the fill rule
rule says how to interpret the inputs — whether a ring inside another
ring is a hole ("evenodd") or a separate island ("nonzero"). It must match
the rule the operands were drawn with, or the answer will be correct for a
shape you did not mean.
The result always uses the non-zero rule: holes come back wound opposite
to their outer ring, which is how the returned path_grob() is set up.
Operands must be in a single coordinate space — one unit, no offsets — since a boolean has to be computed somewhere, and mixed units have no common space.

