Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_end=0)
cell.add(gdspy.Polygon(c.get_points(), layer=3))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_start=0, curl_end=0)
cell.add(gdspy.Polygon(c.get_points(), layer=4))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i(
[(1, 2), (2, 1), (3, 2), (4, 0)],
angles=[numpy.pi / 2, None, None, None, -numpy.pi / 2],
curl_start=0,
curl_end=0,
)
cell.add(gdspy.Polygon(c.get_points(), layer=5))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i(
[(1, 2), (2, 1), (3, 2), (4, 0)],
angles=[None, 0, None, 0, None],
curl_start=0,
curl_end=1,
)
cell.add(gdspy.Polygon(c.get_points(), layer=6))
cell = lib.new_cell("Hobby3")
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)])
cell.add(gdspy.Polygon(c.get_points(), layer=1))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], t_in=2)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, -numpy.pi / 2])
cell.add(gdspy.Polygon(c.get_points(), layer=13))
c = gdspy.Curve(2, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, -numpy.pi, -numpy.pi / 2])
cell.add(gdspy.Polygon(c.get_points(), layer=15))
c = gdspy.Curve(4, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[-numpy.pi / 4, 0, numpy.pi / 2, -numpy.pi])
cell.add(gdspy.Polygon(c.get_points(), layer=17))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(2, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[numpy.pi / 3, None, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=4))
c = gdspy.Curve(4, 0, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[None, None, None, 2 / 3.0 * numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=6))
c = gdspy.Curve(0, 2, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[numpy.pi / 3, None, None, 3 / 4.0 * numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=8))
c = gdspy.Curve(2, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, numpy.pi / 2, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=10))
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[numpy.pi / 3, None, None, 3 / 4.0 * numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=8))
c = gdspy.Curve(2, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, numpy.pi / 2, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=10))
c = gdspy.Curve(4, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=12))
c = gdspy.Curve(0, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, -numpy.pi / 2], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=14))
c = gdspy.Curve(2, 4, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)], angles=[None, 0, -numpy.pi, -numpy.pi / 2], cycle=True
)
cell.add(gdspy.Polygon(c.get_points(), layer=16))
c = gdspy.Curve(4, 4, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[-numpy.pi / 4, 0, numpy.pi / 2, -numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=18))
assertsame(target["Hobby1"], cell)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, -numpy.pi, -numpy.pi / 2])
cell.add(gdspy.Polygon(c.get_points(), layer=15))
c = gdspy.Curve(4, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[-numpy.pi / 4, 0, numpy.pi / 2, -numpy.pi])
cell.add(gdspy.Polygon(c.get_points(), layer=17))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(2, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[numpy.pi / 3, None, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=4))
c = gdspy.Curve(4, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, None, 2 / 3.0 * numpy.pi], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=6))
c = gdspy.Curve(0, 2, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[numpy.pi / 3, None, None, 3 / 4.0 * numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=8))
c = gdspy.Curve(2, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, numpy.pi / 2, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=10))
c = gdspy.Curve(4, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=12))
c = gdspy.Curve(0, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, -numpy.pi / 2], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=14))
c = gdspy.Curve(2, 4, tolerance=1e-3)
def test_hobby2(target):
cell = gdspy.Cell("test", True)
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)])
cell.add(gdspy.Polygon(c.get_points(), layer=1))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_start=0)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_end=0)
cell.add(gdspy.Polygon(c.get_points(), layer=3))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_start=0, curl_end=0)
cell.add(gdspy.Polygon(c.get_points(), layer=4))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i(
[(1, 2), (2, 1), (3, 2), (4, 0)],
angles=[numpy.pi / 2, None, None, None, -numpy.pi / 2],
curl_start=0,
curl_end=0,
)
cell.add(gdspy.Polygon(c.get_points(), layer=5))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i(
[(1, 2), (2, 1), (3, 2), (4, 0)],
angles=[None, 0, None, 0, None],
curl_start=0,
curl_end=1,
)
cell.add(gdspy.Polygon(c.get_points(), layer=6))
assertsame(target["Hobby2"], cell)
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=8))
c = gdspy.Curve(2, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, numpy.pi / 2, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=10))
c = gdspy.Curve(4, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=12))
c = gdspy.Curve(0, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, -numpy.pi / 2], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=14))
c = gdspy.Curve(2, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, -numpy.pi, -numpy.pi / 2], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=16))
c = gdspy.Curve(4, 4, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[-numpy.pi / 4, 0, numpy.pi / 2, -numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=18))
cell = lib.new_cell("Hobby2")
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)])
cell.add(gdspy.Polygon(c.get_points(), layer=1))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 2), (2, 1), (3, 2), (4, 0)], curl_start=0)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, None, numpy.pi / 2, None])
cell.add(gdspy.Polygon(c.get_points(), layer=9))
c = gdspy.Curve(4, 2, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, None])
cell.add(gdspy.Polygon(c.get_points(), layer=11))
c = gdspy.Curve(0, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, None, -numpy.pi / 2])
cell.add(gdspy.Polygon(c.get_points(), layer=13))
c = gdspy.Curve(2, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[None, 0, -numpy.pi, -numpy.pi / 2])
cell.add(gdspy.Polygon(c.get_points(), layer=15))
c = gdspy.Curve(4, 4, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[-numpy.pi / 4, 0, numpy.pi / 2, -numpy.pi])
cell.add(gdspy.Polygon(c.get_points(), layer=17))
c = gdspy.Curve(0, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=2))
c = gdspy.Curve(2, 0, tolerance=1e-3)
c.i([(1, 0), (1, 1), (0, 1)], angles=[numpy.pi / 3, None, None, None], cycle=True)
cell.add(gdspy.Polygon(c.get_points(), layer=4))
c = gdspy.Curve(4, 0, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[None, None, None, 2 / 3.0 * numpy.pi],
cycle=True,
)
cell.add(gdspy.Polygon(c.get_points(), layer=6))
c = gdspy.Curve(0, 2, tolerance=1e-3)
c.i(
[(1, 0), (1, 1), (0, 1)],
angles=[numpy.pi / 3, None, None, 3 / 4.0 * numpy.pi],
# Construct another curve using relative coordinates
c2 = gdspy.Curve(3, 1).l(1, 0, 2, 1, 2, 2, 0, 2)
p2 = gdspy.Polygon(c2.get_points())
draw(gdspy.Cell("curves").add([p1, p2]))
# Curves 1
# Use complex numbers to facilitate writing polar coordinates
c3 = gdspy.Curve(0, 2).l(4 * numpy.exp(1j * numpy.pi / 6))
# Elliptical arcs have syntax similar to gdspy.Round
c3.arc((4, 2), 0.5 * numpy.pi, -0.5 * numpy.pi)
p3 = gdspy.Polygon(c3.get_points())
draw(gdspy.Cell("curves_1").add(p3))
# Curves 2
# Cubic Bezier curves can be easily created with C and c
c4 = gdspy.Curve(0, 0).c(1, 0, 1, 1, 2, 1)
# Smooth continuation with S or s
c4.s(1, 1, 0, 1).S(numpy.exp(1j * numpy.pi / 6), 0, 0)
p4 = gdspy.Polygon(c4.get_points())
# Similarly for quadratic Bezier curves
c5 = gdspy.Curve(5, 3).Q(3, 2, 3, 0, 5, 0, 4.5, 1).T(5, 3)
p5 = gdspy.Polygon(c5.get_points())
# Smooth interpolating curves can be built using I or i, including
# closed shapes
c6 = gdspy.Curve(0, 3).i([(1, 0), (2, 0), (1, -1)], cycle=True)
p6 = gdspy.Polygon(c6.get_points())
draw(gdspy.Cell("curves_2").add([p4, p5, p6]))
# Transformations
poly = gdspy.Rectangle((-2, -2), (2, 2))
ellipse = gdspy.Round((4, 0), [1, 2], tolerance=1e-4)
# Circular arc example
arc = gdspy.Round(
(2, 4),
2,
inner_radius=1,
initial_angle=-0.2 * numpy.pi,
final_angle=1.2 * numpy.pi,
tolerance=0.01,
)
draw(gdspy.Cell("circles").add([circle, ellipse, arc]))
# Curves
# Construct a curve made of a sequence of line segments
c1 = gdspy.Curve(0, 0).L(1, 0, 2, 1, 2, 2, 0, 2)
p1 = gdspy.Polygon(c1.get_points())
# Construct another curve using relative coordinates
c2 = gdspy.Curve(3, 1).l(1, 0, 2, 1, 2, 2, 0, 2)
p2 = gdspy.Polygon(c2.get_points())
draw(gdspy.Cell("curves").add([p1, p2]))
# Curves 1
# Use complex numbers to facilitate writing polar coordinates
c3 = gdspy.Curve(0, 2).l(4 * numpy.exp(1j * numpy.pi / 6))
# Elliptical arcs have syntax similar to gdspy.Round
c3.arc((4, 2), 0.5 * numpy.pi, -0.5 * numpy.pi)
p3 = gdspy.Polygon(c3.get_points())
draw(gdspy.Cell("curves_1").add(p3))
# Curves 2
draw(gdspy.Cell("curves_1").add(p3))
# Curves 2
# Cubic Bezier curves can be easily created with C and c
c4 = gdspy.Curve(0, 0).c(1, 0, 1, 1, 2, 1)
# Smooth continuation with S or s
c4.s(1, 1, 0, 1).S(numpy.exp(1j * numpy.pi / 6), 0, 0)
p4 = gdspy.Polygon(c4.get_points())
# Similarly for quadratic Bezier curves
c5 = gdspy.Curve(5, 3).Q(3, 2, 3, 0, 5, 0, 4.5, 1).T(5, 3)
p5 = gdspy.Polygon(c5.get_points())
# Smooth interpolating curves can be built using I or i, including
# closed shapes
c6 = gdspy.Curve(0, 3).i([(1, 0), (2, 0), (1, -1)], cycle=True)
p6 = gdspy.Polygon(c6.get_points())
draw(gdspy.Cell("curves_2").add([p4, p5, p6]))
# Transformations
poly = gdspy.Rectangle((-2, -2), (2, 2))
poly.rotate(numpy.pi / 4)
poly.scale(1, 0.5)
draw(gdspy.Cell("transformations").add(poly))
# Layer and Datatype
# Layer/datatype definitions for each step in the fabrication
ld_fulletch = {"layer": 1, "datatype": 3}
ld_partetch = {"layer": 2, "datatype": 3}
ld_liftoff = {"layer": 0, "datatype": 7}
p1 = gdspy.Rectangle((-3, -3), (3, 3), **ld_fulletch)