gdsfactory.geometry.offset

Contents

gdsfactory.geometry.offset#

gdsfactory.geometry.offset(elements: Component, distance: float = 0.1, use_union: bool = True, precision: float = 0.0001, join: str = 'miter', tolerance: int = 2, layer: LayerSpec = 'WG') Component[source]#

Returns new Component with polygons eroded or dilated by an offset.

Parameters:
  • elements – Component(/Reference), list of Component(/Reference), or Polygons to offset or Component containing polygons to offset.

  • distance – Distance to offset polygons. Positive values expand, negative shrink.

  • use_union – If True, use union of all polygons to offset. If False, offset

  • precision – Desired precision for rounding vertex coordinates.

  • join – {‘miter’, ‘bevel’, ‘round’} Type of join used to create polygon offset

  • tolerance – For miter joints, this number must be at least 2 represents the maximal distance in multiples of offset between new vertices and their original position before beveling to avoid spikes at acute joints. For round joints, it indicates the curvature resolution in number of points per full circle.

  • layer – Specific layer to put polygon geometry on.

Returns:

Component containing a polygon(s) with the specified offset applied.

import gdsfactory as gf
c = gf.Component()
layer_slab = (2, 0)
c1 = gf.components.coupler_ring(
    cladding_layers=[layer_slab], cladding_offsets=[0.5]
)
d = 0.8
c2 = gf.geometry.offset(c1, distance=+d, layer=layer_slab)
c3 = gf.geometry.offset(c2, distance=-d, layer=layer_slab)

_ = c << c1.extract(layers=("WG",))
_ = c << c3
c.plot_matplotlib()

(Source code)