gdstk.slice

gdstk.slice(polygons, position, axis, precision=1e-3) list

Slice polygons along x and y axes.

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

  • position (number or sequence) – Cut positions.

  • axis (str) – One of “x” or “y”. Indicated the axis where positions are specified. The cut direction is orthogonal to this axis.

  • precision – Desired precision for rounding vertex coordinates.

Returns:

List with N + 1 elements, where N is the number of cut positions. Each element is a list of polygons obtained between cuts.

Examples

>>> triangle = gdstk.regular_polygon((-10, 0), 8, 3)
>>> ring = gdstk.ellipse((10, 0), 8, 5, layer=1)
>>> result = gdstk.slice([triangle, ring], (-10, -5, 0, 6, 14), "x")
>>> print(len(result))
6
>>> print([len(polys) for polys in result])
[1, 1, 0, 1, 2, 1]
../_images/slice.svg

Notes

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