boolean¶
- photonforge.boolean(operand1, operand2, operation)¶
Compute the boolean operation between 2 sets of polygons.
- Parameters:
operand1 (Rectangle | Circle | Polygon | Path | Component | Reference | Iterable[Rectangle | Circle | Polygon | Path | Component | Reference]) – First operand for the boolean operation. All polygons defined in
operand1
are joined before the operation.operand2 (Rectangle | Circle | Polygon | Path | Component | Reference | Iterable[Rectangle | Circle | Polygon | Path | Component | Reference]) – Second operand for the boolean operation. All polygons defined in
operand2
are joined before the operation.operation (Literal["+", "*", "-", "^"]) – One of “+” (union), “*” (intersection), “-” (difference), or “^” (symmetric difference).
- Returns:
Resulting polygons.
- Return type:
list[Polygon]
Examples
>>> horizontal = Rectangle(center=(0, 0), size=(11, 2)) >>> vertical = Rectangle(center=(0, 0), size=(2, 11)) >>> donut = Circle(5, inner_radius=3) >>> union = boolean(donut, [horizontal, vertical], "+") >>> len(union) 1 >>> difference = boolean(donut, [horizontal, vertical], "-") >>> len(difference) 4