gdstk.boolean

gdstk.boolean(operand1, operand2, operation, precision=1e-3, layer=0, datatype=0) list

Execute boolean (clipping) operations between polygons.

Parameters:
  • operand1 (Polygon, FlexPath, RobustPath, Reference, sequence) – First operand. If this is a sequence, each element can be any of the polygonal types or a sequence of points (coordinate pairs or complex).

  • operand2 (Polygon, FlexPath, RobustPath, Reference, sequence) – Second operand.

  • operation (str) – Boolean operation to be executed. One of “or”, “and”, “xor”, or “not”. The “not” operation performs the set difference operand1 - operand2.

  • precision – Desired precision for rounding vertex coordinates.

  • layer – layer number assigned to the resulting polygons.

  • datatype – data type number assigned to the resulting polygons.

Returns:

List of gdstk.Polygon.

Examples

>>> circle = gdstk.ellipse((0, 0), 50)
>>> path = gdstk.FlexPath((-50, 30), [5, 5], 10)
>>> path.interpolation([(20, 15), (0, 0), (-20, -15), (50, -30)],
...                    angles=[0.3, None, None, None, 0.3])
>>> text = gdstk.text("GDSTK", 40, (-2.5 * 40 * 9 / 16, -40 / 2))
>>> result = gdstk.boolean(circle, text + [path], "not")
../_images/boolean.svg

Notes

  1. Repetitions are not applied to any elements, except references and their contents.

  2. All polygons in operand1 are merged during the operation, as well as those in operand2. As such, if, for example, operand2 is an empty list, the result of the operation will be the union of polygons in operand1.