def connect_electrical_shortest_path(port1, port2): """connects two ports with a polygon that takes the shortest path""" points = [port1.midpoint, port2.midpoint] name = f"zz_conn_{hash_points(points)}" c = Component(name=name) layer = port1.layer p1x0 = port1.endpoints[0][0] p1y0 = port1.endpoints[0][1] p1x1 = port1.endpoints[1][0] p1y1 = port1.endpoints[1][1] p2x0 = port2.endpoints[0][0] p2y0 = port2.endpoints[0][1] p2x1 = port2.endpoints[1][0] p2y1 = port2.endpoints[1][1] if port1.orientation in [90, 270]: c.add_polygon( ([(p1x1, p1y0), (p1x0, p1y1), (p2x1, p2y1), (p2x0, p2y0)]), layer=layer ) else: c.add_polygon( ([(p1x0, p1y1), (p1x1, p1y0), (p2x1, p2y1), (p2x0, p2y0)]), layer=layer ) return c.ref()
def connect_electrical_shortest_path(port1, port2): """connects two ports with a polygon that takes the shortest path""" c = Component(name="zz_conn_{}".format(uuid.uuid4())) layer = port1.layer p1x0 = port1.endpoints[0][0] p1y0 = port1.endpoints[0][1] p1x1 = port1.endpoints[1][0] p1y1 = port1.endpoints[1][1] p2x0 = port2.endpoints[0][0] p2y0 = port2.endpoints[0][1] p2x1 = port2.endpoints[1][0] p2y1 = port2.endpoints[1][1] if port1.orientation in [90, 270]: c.add_polygon(([(p1x1, p1y0), (p1x0, p1y1), (p2x1, p2y1), (p2x0, p2y0)]), layer=layer) else: c.add_polygon(([(p1x0, p1y1), (p1x1, p1y0), (p2x1, p2y1), (p2x0, p2y0)]), layer=layer) return c.ref()