.\" Man page generated from reStructuredText. . .TH "GDSPY" "1" "Mar 21, 2020" "1.4.2" "gdspy" .SH NAME gdspy \- gdspy Documentation . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .sp gdspy is a Python module that allows the creation of GDSII stream files. .sp Most features of the GDSII format are implemented, including support for polygons with any number of vertices. .sp GDSII format references: .INDENT 0.0 .IP \(bu 2 \fI\%http://boolean.klaasholwerda.nl/interface/bnf/gdsformat.html\fP .IP \(bu 2 \fI\%http://www.artwork.com/gdsii/gdsii/\fP .IP \(bu 2 \fI\%http://www.buchanan1.net/stream_description.html\fP .UNINDENT .sp For installation instructions and other information, please check out the \fI\%GitHub\fP repository or the README file included with the source. .SH GETTING STARTED .sp GDSII files contain a hierarchical representation of any polygonal geometry. They are mainly used in the microelectronics industry for the design of mask layouts, but are also employed in other areas. .sp Because it is a hierarchical format, repeated structures, such as identical transistors, can be defined once and referenced multiple times in the layout, reducing the file size. .sp There is one important limitation in the GDSII format: it only supports \fI\%weakly simple polygons\fP, that is, polygons whose segments are allowed to intersect, but not cross. .sp In particular, curves and shapes with holes are \fInot\fP directly supported. Holes can be defined, nonetheless, by connecting their boundary to the boundary of the enclosing shape. In the case of curves, they must be approximated by a polygon. The number of points in the polygonal approximation can be increased to better approximate the original curve up to some acceptable error. .sp The original GDSII format limits the number of vertices in a polygon to 199. Most modern software disregards this limit and allows an arbitrary number of points per polygon. Gdspy follows the modern version of GDSII, but this is an important issue to keep in mind if the generated file is to be used in older systems. .sp The units used to represent shapes in the GDSII format are defined by the user. The default unit in gdspy is 1 µm (10⁻⁶ m), but that can be easily changed by the user. .SS First GDSII .sp Let\(aqs create our first GDSII file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import gdspy # Create the geometry: a single rectangle. rect = gdspy.Rectangle((0, 0), (2, 1)) cell = gdspy.Cell(\(aqFIRST\(aq) cell.add(rect) # Save all created cells in file \(aqfirst.gds\(aq. gdspy.write_gds(\(aqfirst.gds\(aq) # Optionally, display all cells using the internal viewer. gdspy.LayoutViewer() .ft P .fi .UNINDENT .UNINDENT .sp After importing the gdspy module, we create a \fBgdspy.Rectangle\fP with opposing corners at positions (0, 0) and (2, 1). .sp Then a \fBgdspy.Cell\fP is created and the rectangle is added to the cell. All shapes in the GDSII format exist inside cells. A cell can be imagined as a piece of paper where the layout will be defined. Later, the cells can be used to create a hierarchy of geometries, ass we\(aqll see in \fI\%References\fP\&. .sp Finally, the whole structure is saved in a file called "first.gds" in the current directory. By default, all created cells are included in this operation. .sp The GDSII file can be opened in a number of viewers and editors, such as \fI\%KLayout\fP\&. Alternatively, gdspy includes a simple viewer that can also be used: \fBgdspy.LayoutViewer\fP\&. .SS Polygons .sp General polygons can be defined by an ordered list of vertices. The orientation of the vertices (clockwise/counter\-clockwise) is not important. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Create a polygon from a list of vertices points = [(0, 0), (2, 2), (2, 6), (\-6, 6), (\-6, \-6), (\-4, \-4), (\-4, 4), (0, 4)] poly = gdspy.Polygon(points) .ft P .fi .UNINDENT .UNINDENT [image] .SS Holes .sp As mentioned in \fI\%Getting Started\fP, holes have to be connected to the outer boundary of the polygon, as in the following example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Manually connect the hole to the outer boundary cutout = gdspy.Polygon( [(0, 0), (5, 0), (5, 5), (0, 5), (0, 0), (2, 2), (2, 3), (3, 3), (3, 2), (2, 2)] ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Circles .sp The \fBgdspy.Round\fP class creates circles, ellipses, doughnuts, arcs and slices. In all cases, the arguments \fItolerance\fP or \fInumber_of_points\fP will control the number of vertices used to approximate the curved shapes. .sp If the number of vertices in the polygon is larger than \fImax_points\fP (199 by default), it will be fractured in many smaller polygons with at most \fImax_points\fP vertices each. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Circle centered at (0, 0), with radius 2 and tolerance 0.1 circle = gdspy.Round((0, 0), 2, tolerance=0.01) # To create an ellipse, simply pass a list with 2 radii. # Because the tolerance is small (resulting a large number of # vertices), the ellipse is fractured in 2 polygons. 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, ) .ft P .fi .UNINDENT .UNINDENT [image] .SS Curves .sp Constructing complex polygons by manually listing all vertices in \fBgdspy.Polygon\fP can be challenging. The class \fBgdspy.Curve\fP can be used to facilitate the creation of polygons by drawing their shapes step\-by\-step. It uses a syntax similar to the \fI\%SVG path specification\fP\&. .sp A short summary of the available methods is presented below: .TS center; |l|l|. _ T{ Method T} T{ Primitive T} _ T{ L/l T} T{ Line segments T} _ T{ H/h T} T{ Horizontal line segments T} _ T{ V/v T} T{ Vertical line segments T} _ T{ C/c T} T{ Cubic Bezier curve T} _ T{ S/s T} T{ Smooth cubic Bezier curve T} _ T{ Q/q T} T{ Quadratic Bezier curve T} _ T{ T/t T} T{ Smooth quadratic Bezier curve T} _ T{ B/b T} T{ General degree Bezier curve T} _ T{ I/i T} T{ Smooth interpolating curve T} _ T{ arc T} T{ Elliptical arc T} _ .TE .sp The uppercase version of the methods considers that all coordinates are absolute, whereas the lowercase considers that they are relative to the current end point of the curve. Except for \fBgdspy.Curve.I()\fP, \fBgdspy.Curve.i()\fP and \fBgdspy.Curve.arc()\fP, they accept variable numbers of arguments that are used as coordinates to construct the primitive. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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()) .ft P .fi .UNINDENT .UNINDENT [image] .sp Coordinate pairs can be given as a complex number: real and imaginary parts are used as x and y coordinates, respectively. That is useful to define points in polar coordinates. .sp Elliptical arcs have syntax similar to \fBgdspy.Round\fP, but they allow for an extra rotation of the major axis of the ellipse. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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()) .ft P .fi .UNINDENT .UNINDENT [image] .sp Other curves can be constructed as cubic, quadratic and general\-degree Bezier curves. Additionally, a smooth interpolating curve can be calculated with the methods \fBgdspy.Curve.I()\fP and \fBgdspy.Curve.i()\fP, which have a number of arguments to control the shape of the curve. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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()) .ft P .fi .UNINDENT .UNINDENT [image] .SS Transformations .sp All polygons can be transformed trough \fBgdspy.PolygonSet.translate()\fP, \fBgdspy.PolygonSet.rotate()\fP, \fBgdspy.PolygonSet.scale()\fP, and \fBgdspy.PolygonSet.mirror()\fP\&. The transformations are applied in\-place, i.e., no polygons are created. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C poly = gdspy.Rectangle((\-2, \-2), (2, 2)) poly.rotate(numpy.pi / 4) poly.scale(1, 0.5) .ft P .fi .UNINDENT .UNINDENT [image] .SS Layer and Datatype .sp All shapes in the GDSII format are tagged with 2 properties: layer and datatype (or texttype in the case of \fBgdspy.Label\fP). They are always 0 by default, but can be any integer in the range from 0 to 255. .sp These properties have no predefined meaning. It is up to the system using the GDSII file to chose with to do with those tags. For example, in the CMOS fabrication process, each layer could represent a different lithography level. .sp In the example below, a single file stores different fabrication masks in separate layer and datatype configurations. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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) p2 = gdspy.Rectangle((\-5, \-3), (\-3, 3), **ld_partetch) p3 = gdspy.Rectangle((5, \-3), (3, 3), **ld_partetch) p4 = gdspy.Round((0, 0), 2.5, number_of_points=6, **ld_liftoff) .ft P .fi .UNINDENT .UNINDENT [image] .SS References .sp References give the GDSII format its hierarchical features. They work by reusing a cell content in another cell (without actually copying the whole geometry). As a simplistic example, imagine the we are designing a simple electronic circuit that uses hundreds of transistors, but they all have the same shape. We can draw the transistor just once and reference it throughout the circuit, rotating or mirroring each instance as necessary. .sp Besides creating single references with \fBgdspy.CellReference\fP, it is possible to create full 2D arrays with a single entity using \fBgdspy.CellArray\fP\&. Both are exemplified below. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Create a cell with a component that is used repeatedly contact = gdspy.Cell("CONTACT") contact.add([p1, p2, p3, p4]) # Create a cell with the complete device device = gdspy.Cell("DEVICE") device.add(cutout) # Add 2 references to the component changing size and orientation ref1 = gdspy.CellReference(contact, (3.5, 1), magnification=0.25) ref2 = gdspy.CellReference(contact, (1, 3.5), magnification=0.25, rotation=90) device.add([ref1, ref2]) # The final layout has several repetitions of the complete device main = gdspy.Cell("MAIN") main.add(gdspy.CellArray(device, 3, 2, (6, 7))) .ft P .fi .UNINDENT .UNINDENT [image] .SS Paths .sp Besides polygons, the GDSII format defines paths, witch are \fI\%polygonal chains\fP with associated width and end caps. The width is a single number, constant throughout the path, and the end caps can be flush, round, or extended by a custom distance. .sp There is no specification for the joins between adjacent segments, so it is up to the system using the GDSII file to specify those. Usually the joins are straight extensions of the path boundaries up to some beveling limit. Gdspy also uses this specification for the joins. .sp It is possible to circumvent all of the above limitations within gdspy by storing paths as polygons in the GDSII file. The disadvantage of this solution is that other software will not be able to edit the geometry as paths, since that information is lost. .sp The construction of paths (either GDSII paths or polygonal paths) in gdspy is quite rich. There are 3 classes that can be used depending on the requirements of the desired path. .SS Polygonal\-Only Paths .sp The class \fBgdspy.Path\fP is designed to allow the creation of path\-like polygons in a piece\-wise manner. It is the most computationally efficient class between the three because it \fIdoes not\fP calculate joins. That means the user is responsible for designing the joins. The paths can end up with discontinuities if care is not taken when creating them. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Start a path at (0, 0) with width 1 path1 = gdspy.Path(1, (0, 0)) # Add a segment to the path goin in the \(aq+y\(aq direction path1.segment(4, "+y") # Further segments or turns will folow the current path direction # to ensure continuity path1.turn(2, "r") path1.segment(1) path1.turn(3, "rr") .ft P .fi .UNINDENT .UNINDENT [image] .sp Just as with \fI\%Circles\fP, all curved geometry is approximated by line segments. The number of segments is similarly controlled by a \fItolerance\fP or a \fInumber_of_points\fP argument. Curves also include fracturing to limit the number of points in each polygon. .sp More complex paths can be constructed with the methods \fBgdspy.Path.bezier()\fP, \fBgdspy.Path.smooth()\fP, and \fBgdspy.Path.parametric()\fP\&. The example below demonstrates a couple of possibilities. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C path2 = gdspy.Path(0.5, (0, 0)) # Start the path with a smooth Bezier S\-curve path2.bezier([(0, 5), (5, 5), (5, 10)]) # We want to add a spiral curve to the path. The spiral is defined # as a parametric curve. We make sure spiral(0) = (0, 0) so that # the path is continuous. def spiral(u): r = 4 \- 3 * u theta = 5 * u * numpy.pi x = r * numpy.cos(theta) \- 4 y = r * numpy.sin(theta) return (x, y) # It is recommended to also define the derivative of the parametric # curve, otherwise this derivative must be calculated nummerically. # The derivative is used to define the side boundaries of the path, # so, in this case, to ensure continuity with the existing S\-curve, # we make sure the the direction at the start of the spiral is # pointing exactly upwards, as if is radius were constant. # Additionally, the exact magnitude of the derivative is not # important; gdspy only uses its direction. def dspiral_dt(u): theta = 5 * u * numpy.pi dx_dt = \-numpy.sin(theta) dy_dt = numpy.cos(theta) return (dx_dt, dy_dt) # Add the parametric spiral to the path path2.parametric(spiral, dspiral_dt) .ft P .fi .UNINDENT .UNINDENT [image] .sp The width of the path does not have to be constant. Each path component can linearly taper the width of the path by using the \fIfinal_width\fP argument. In the case of a parametric curve, more complex width changes can be created by setting \fIfinal_width\fP to a function. .sp Finally, parallel paths can be created simultaneously with the help of arguments \fInumber_of_paths\fP, \fIdistance\fP, and \fIfinal_distance\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Start 3 parallel paths with center\-to\-center distance of 1.5 path3 = gdspy.Path(0.1, (\-5.5, 3), number_of_paths=3, distance=1.5) # Add a segment tapering the widths up to 0.5 path3.segment(2, "\-y", final_width=0.5) # Add a bezier curve decreasing the distance between paths to 0.75 path3.bezier([(0, \-2), (1, \-3), (3, \-3)], final_distance=0.75) # Add a parametric section to modulate the width with a sinusoidal # shape. Note that the algorithm that determines the number of # evaluations of the parametric curve does not take the width into # consideration, so we have to manually increase this parameter. path3.parametric( lambda u: (5 * u, 0), lambda u: (1, 0), final_width=lambda u: 0.4 + 0.1 * numpy.cos(10 * numpy.pi * u), number_of_evaluations=256, ) # Add a circular turn and a final tapering segment. path3.turn(3, "l") path3.segment(2, final_width=1, final_distance=1.5) .ft P .fi .UNINDENT .UNINDENT [image] .SS Flexible Paths .sp Although very efficient, \fBgdspy.Path\fP is limited in the type of path it can provide. For example, if we simply want a path going through a sequence of points, we need a class that can correctly compute the joins between segments. That\(aqs one of the advantages of class \fBgdspy.FlexPath\fP\&. Other path construction methods are similar to those in \fBgdspy.Path\fP\&. .sp A few features of \fBgdspy.FlexPath\fP are: .INDENT 0.0 .IP \(bu 2 paths can be stored as proper GDSII paths; .IP \(bu 2 end caps and joins can be specified by the user; .IP \(bu 2 each parallel path can have a different width; .IP \(bu 2 spacing between parallel paths is arbitrary; the user specifies the offset of each path individually. .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Path defined by a sequence of points and stored as a GDSII path sp1 = gdspy.FlexPath( [(0, 0), (3, 0), (3, 2), (5, 3), (3, 4), (0, 4)], 1, gdsii_path=True ) # Other construction methods can still be used sp1.smooth([(0, 2), (2, 2), (4, 3), (5, 1)], relative=True) # Multiple parallel paths separated by 0.5 with different widths, # end caps, and joins. Because of the join specification, they # cannot be stared as GDSII paths, only as polygons. sp2 = gdspy.FlexPath( [(12, 0), (8, 0), (8, 3), (10, 2)], [0.3, 0.2, 0.4], 0.5, ends=["extended", "flush", "round"], corners=["bevel", "miter", "round"], ) sp2.arc(2, \-0.5 * numpy.pi, 0.5 * numpy.pi) sp2.arc(1, 0.5 * numpy.pi, 1.5 * numpy.pi) .ft P .fi .UNINDENT .UNINDENT [image] .sp The following example shows other features, such as width tapering, arbitrary offsets, and custom joins and end caps. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Path corners and end caps can be custom functions. # This corner function creates \(aqbroken\(aq joins. def broken(p0, v0, p1, v1, p2, w): # Calculate intersection point p between lines defined by # p0 + u0 * v0 (for all u0) and p1 + u1 * v1 (for all u1) den = v1[1] * v0[0] \- v1[0] * v0[1] lim = 1e\-12 * (v0[0] ** 2 + v0[1] ** 2) * (v1[0] ** 2 + v1[1] ** 2) if den ** 2 < lim: # Lines are parallel: use mid\-point u0 = u1 = 0 p = 0.5 * (p0 + p1) else: dx = p1[0] \- p0[0] dy = p1[1] \- p0[1] u0 = (v1[1] * dx \- v1[0] * dy) / den u1 = (v0[1] * dx \- v0[0] * dy) / den p = 0.5 * (p0 + v0 * u0 + p1 + v1 * u1) if u0 <= 0 and u1 >= 0: # Inner corner return [p] # Outer corner return [p0, p2, p1] # This end cap function creates pointy caps. def pointy(p0, v0, p1, v1): r = 0.5 * numpy.sqrt(numpy.sum((p0 \- p1) ** 2)) v0 /= numpy.sqrt(numpy.sum(v0 ** 2)) v1 /= numpy.sqrt(numpy.sum(v1 ** 2)) return [p0, 0.5 * (p0 + p1) + 0.5 * (v0 \- v1) * r, p1] # Paths with arbitrary offsets from the center and multiple layers. sp3 = gdspy.FlexPath( [(0, 0), (0, 1)], [0.1, 0.3, 0.5], offset=[\-0.2, 0, 0.4], layer=[0, 1, 2], corners=broken, ends=pointy, ) sp3.segment((3, 3), offset=[\-0.5, \-0.1, 0.5]) sp3.segment((4, 1), width=[0.2, 0.2, 0.2], offset=[\-0.2, 0, 0.2]) sp3.segment((0, \-1), relative=True) .ft P .fi .UNINDENT .UNINDENT [image] .sp The corner type \(aqcircular bend\(aq (together with the \fIbend_radius\fP argument) can be used to automatically curve the path. This feature is used in Example: Integrated Photonics\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Path created with automatic bends of radius 5 points = [(0, 0), (0, 10), (20, 0), (18, 15), (8, 15)] sp4 = gdspy.FlexPath( points, 0.5, corners="circular bend", bend_radius=5, gdsii_path=True ) # Same path, generated with natural corners, for comparison sp5 = gdspy.FlexPath(points, 0.5, layer=1, gdsii_path=True) .ft P .fi .UNINDENT .UNINDENT [image] .SS Robust Paths .sp In some situations, \fBgdspy.FlexPath\fP is unable to properly calculate all the joins. This often happens when the width or offset of the path is relatively large with respect to the length of the segments being joined. Curves that join other curves or segments at sharp angles are an example of such situation. .sp The class \fBgdspy.RobustPath\fP can be used in such scenarios where robustness is more important than efficiency due to sharp corners or large offsets in the paths. The drawbacks of using \fBgdspy.RobustPath\fP are the loss in computation efficiency (compared to the other 2 classes) and the impossibility of specifying corner shapes. The advantages are, as mentioned earlier, more robustness when generating the final geometry, and freedom to use custom functions to parameterize the widths or offsets of the paths in any construction method. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Create 4 parallel paths in different layers lp = gdspy.RobustPath( (50, 0), [2, 0.5, 1, 1], [0, 0, \-1, 1], ends=["extended", "round", "flush", "flush"], layer=[0, 2, 1, 1], ) lp.segment((45, 0)) lp.segment( (5, 0), width=[lambda u: 2 + 16 * u * (1 \- u), 0.5, 1, 1], offset=[ 0, lambda u: 8 * u * (1 \- u) * numpy.cos(12 * numpy.pi * u), lambda u: \-1 \- 8 * u * (1 \- u), lambda u: 1 + 8 * u * (1 \- u), ], ) lp.segment((0, 0)) lp.smooth( [(5, 10)], angles=[0.5 * numpy.pi, 0], width=0.5, offset=[\-0.25, 0.25, \-0.75, 0.75], ) lp.parametric( lambda u: numpy.array((45 * u, 4 * numpy.sin(6 * numpy.pi * u))), offset=[ lambda u: \-0.25 * numpy.cos(24 * numpy.pi * u), lambda u: 0.25 * numpy.cos(24 * numpy.pi * u), \-0.75, 0.75, ], ) .ft P .fi .UNINDENT .UNINDENT [image] .sp Note that, analogously to \fBgdspy.FlexPath\fP, \fBgdspy.RobustPath\fP can be stored as a GDSII path as long as its width is kept constant. .SS Text .sp In the context of a GDSII file, text is supported in the form of labels, which are ASCII annotations placed somewhere in the geometry of a given cell. Similar to polygons, labels are tagged with layer and texttype values (texttype is the label equivalent of the polygon datatype). They are supported by the class \fBgdspy.Label\fP\&. .sp Additionally, gdspy offers the possibility of creating text as polygons to be included with the geometry. The class \fBgdspy.Text\fP creates polygonal text that can be used in the same way as any other polygons in gdspy. The font used to render the characters contains only horizontal and vertical edges, which is important for some laser writing systems. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Label anchored at (1, 3) by its north\-west corner label = gdspy.Label("Sample label", (1, 3), "nw") # Horizontal text with height 2.25 htext = gdspy.Text("12345", 2.25, (0.25, 6)) # Vertical text with height 1.5 vtext = gdspy.Text("ABC", 1.5, (10.5, 4), horizontal=False) rect = gdspy.Rectangle((0, 0), (10, 6), layer=10) .ft P .fi .UNINDENT .UNINDENT [image] .SS Geometry Operations .sp Gdspy offers a number of functions and methods to modify existing geometry. The most useful operations include \fBgdspy.boolean()\fP, \fBgdspy.slice()\fP, \fBgdspy.offset()\fP, and \fBgdspy.PolygonSet.fillet()\fP\&. .SS Boolean Operations .sp Boolean operations (\fBgdspy.boolean()\fP) can be performed on polygons, paths and whole cells. Four operations are defined: union (\(aqor\(aq), intersection (\(aqand\(aq), subtraction (\(aqnot\(aq), and symmetric subtraction (\(aqxor\(aq). .sp They can be computationally expensive, so it is usually advisable to avoid using boolean operations whenever possible. If they are necessary, keeping the number of vertices is all polygons as low as possible also helps. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Create some text text = gdspy.Text("GDSPY", 4, (0, 0)) # Create a rectangle extending the text\(aqs bounding box by 1 bb = numpy.array(text.get_bounding_box()) rect = gdspy.Rectangle(bb[0] \- 1, bb[1] + 1) # Subtract the text from the rectangle inv = gdspy.boolean(rect, text, "not") .ft P .fi .UNINDENT .UNINDENT [image] .SS Slice Operation .sp As the name indicates, a slice operation subdivides a set of polygons along horizontal or vertical cut lines. .sp In a few cases, a boolean operation can be substituted by one or more slice operations. Because \fBgdspy.slice()\fP is ususally much simpler than \fBgdspy.boolean()\fP, it is a good idea to use the former if possible. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ring1 = gdspy.Round((\-6, 0), 6, inner_radius=4) ring2 = gdspy.Round((0, 0), 6, inner_radius=4) ring3 = gdspy.Round((6, 0), 6, inner_radius=4) # Slice the first ring across x=\-3, the second ring across x=\-3 # and x=3, and the third ring across x=3 slices1 = gdspy.slice(ring1, \-3, axis=0) slices2 = gdspy.slice(ring2, [\-3, 3], axis=0) slices3 = gdspy.slice(ring3, 3, axis=0) slices = gdspy.Cell("SLICES") # Keep only the left side of slices1, the center part of slices2 # and the right side of slices3 slices.add(slices1[0]) slices.add(slices2[1]) slices.add(slices3[1]) .ft P .fi .UNINDENT .UNINDENT [image] .SS Offset Operation .sp The function \fBgdspy.offset()\fP expands or contracts polygons by a fixed amount. It can operate on individual polygons or sets of them, in which case it may make sense to use the argument \fIjoin_first\fP to operate on the whole geometry as if a boolean \(aqor\(aq was executed beforehand. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C rect1 = gdspy.Rectangle((\-4, \-4), (1, 1)) rect2 = gdspy.Rectangle((\-1, \-1), (4, 4)) # Offset both polygons # Because we join them first, a single polygon is created. outer = gdspy.offset([rect1, rect2], 0.5, join_first=True, layer=1) .ft P .fi .UNINDENT .UNINDENT [image] .SS Fillet Operation .sp The method \fBgdspy.PolygonSet.fillet()\fP can be used to round polygon corners. It doesn\(aqt have a \fIjoin_first\fP argument as \fBgdspy.offset()\fP, so if it will be used on a polygon, that polygon should probably not be fractured. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C multi_path = gdspy.Path(2, (\-3, \-2)) multi_path.segment(4, "+x") multi_path.turn(2, "l").turn(2, "r") multi_path.segment(4) # Create a copy with joined polygons and no fracturing joined = gdspy.boolean(multi_path, None, "or", max_points=0) joined.translate(0, \-5) # Fillet applied to each polygon in the path multi_path.fillet(0.5) # Fillet applied to the joined copy joined.fillet(0.5) .ft P .fi .UNINDENT .UNINDENT [image] .SS GDSII Library .sp All the information used to create a GDSII file is kept within an instance of \fBGdsLibrary\fP\&. Besides all the geometric and hierarchical information, this class also holds a name and the units for all entities. The name can be any ASCII string. It is simply stored in the GDSII file and has no other purpose in gdspy. The units require some attention because they can impact the resolution of the polygons in the library when written to a file. .SS Units in GDSII .sp Two values are defined: \fIunit\fP and \fIprecision\fP\&. The value of \fIunit\fP defines the unit size—in meters—for all entities in the library. For example, if \fBunit = 1e\-6\fP (10⁻⁶ m, the default value), a vertex at (1, 2) should be interpreted as a vertex in real world position (1 × 10⁻⁶ m, 2 × 10⁻⁶ m). If \fIunit\fP changes to 0.001, then that same vertex would be located (in real world coordinates) at (0.001 m, 0.002 m), or (1 mm, 2 mm). .sp The value of precision has to do with the type used to store coordinates in the GDSII file: signed 4\-byte integers. Because of that, a finer coordinate grid than 1 \fIunit\fP is usually desired to define coordinates. That grid is defined, in meters, by \fIprecision\fP, which defaults to \fB1e\-9\fP (10⁻⁹ m). When the GDSII file is written, all vertices are snapped to the grid defined by \fIprecision\fP\&. For example, for the default values of \fIunit\fP and \fIprecision\fP, a vertex at (1.0512, 0.0001) represents real world coordinates (1.0512 × 10⁻⁶ m, 0.0001 × 10⁻⁶ m), or (1051.2 × 10⁻⁹ m, 0.1 × 10⁻⁹ m), which will be rounded to integers: (1051 × 10⁻⁹ m, 0 × 10⁻⁹ m), or (1.051 × 10⁻⁶ m, 0 × 10⁻⁶ m). The actual coordinate values written in the GDSII file will be the integers (1051, 0). By reducing the value of \fIprecision\fP from 10⁻⁹ m to 10⁻¹² m, for example, the coordinates will have 3 additional decimal places of precision, so the stored values would be (1051200, 100). .sp The downside of increasing the number of decimal places in the file is reducing the range of coordinates that can be stored (in real world units). That is because the range of coordinate values that can be written in the file are [\-(2³²); 2³¹ \- 1] = [\-2,147,483,648; 2,147,483,647]. For the default \fIprecsision\fP, this range is [\-2.147483648 m; 2.147483647 m]. If \fIprecision\fP is set to 10⁻¹² m, the same range is reduced by 1000 times: [\-2.147483648 mm; 2.147483647 mm]. .SS Saving a GDSII File .sp To save a GDSII file, the easiest way is to use \fBgdspy.write_gds()\fP, as in the \fI\%First GDSII\fP\&. That function accepts arguments \fIunit\fP and \fIprecision\fP to change the default values, as explained in the section above. .sp In reality, it calls the \fBgdspy.GdsLibrary.write_gds()\fP method from a global \fBgdspy.GdsLibrary\fP instance: \fBgdspy.current_library\fP\&. This instance automatically holds all cells created by gdspy unless specifically told not to with the argument \fIexclude_from_current\fP set to True in \fBgdspy.Cell\fP\&. .sp That means that after saving a file, if a new GDSII library is to be started from scratch using the global instance, it is important to reinitialize it with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gdspy.current_library = gdspy.GdsLibrary() .ft P .fi .UNINDENT .UNINDENT .SS Loading a GDSII File .sp To load an existing GDSII file (or to work simultaneously with multiple libraries), a new instance of \fBGdsLibrary\fP can be created or an existing one can be used: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Load a GDSII file into a new library gdsii = gdspy.GdsLibrary(infile=\(aqfilename.gds\(aq) # Use the current global library to load the file gdspy.current_library.read_gds(\(aqfilename.gds\(aq) .ft P .fi .UNINDENT .UNINDENT .sp In either case, care must be taken to merge the units from the library and the file, which is controlled by the argument \fIunits\fP in \fBgdspy.GdsLibrary.read_gds()\fP (keyword argument in \fBgdspy.GdsLibrary\fP). .sp Access to the cells in the loaded library is provided through the dictionary \fBgdspy.GdsLibrary.cell_dict\fP (cells indexed by name). The method \fBgdspy.GdsLibrary.top_level()\fP can be used to find the top\-level cells in the library (cells on the top of the hierarchy, i.e., cell that are not referenced by any other cells) and \fBgdspy.GdsLibrary.extract()\fP can be used to import a given cell and all of its dependencies into \fBgdspy.current_library\fP\&. .SS Examples .SS Integrated Photonics .sp This example demonstrates the use of gdspy primitives to create more complex structures. .sp These structures are commonly used in the field of integrated photonics. .sp \fBphotonics.py\fP .sp \fBphotonics.gds\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ###################################################################### # # # Copyright 2009\-2019 Lucas Heitzmann Gabrielli. # # This file is part of gdspy, distributed under the terms of the # # Boost Software License \- Version 1.0. See the accompanying # # LICENSE file or # # # ###################################################################### import numpy import gdspy def grating(period, number_of_teeth, fill_frac, width, position, direction, lda=1, sin_theta=0, focus_distance=\-1, focus_width=\-1, tolerance=0.001, layer=0, datatype=0): \(aq\(aq\(aq Straight or focusing grating. period : grating period number_of_teeth : number of teeth in the grating fill_frac : filling fraction of the teeth (w.r.t. the period) width : width of the grating position : grating position (feed point) direction : one of {\(aq+x\(aq, \(aq\-x\(aq, \(aq+y\(aq, \(aq\-y\(aq} lda : free\-space wavelength sin_theta : sine of incidence angle focus_distance : focus distance (negative for straight grating) focus_width : if non\-negative, the focusing area is included in the result (usually for negative resists) and this is the width of the waveguide connecting to the grating tolerance : same as in \(gapath.parametric\(ga layer : GDSII layer number datatype : GDSII datatype number Return \(gaPolygonSet\(ga \(aq\(aq\(aq if focus_distance < 0: p = gdspy.L1Path((position[0] \- 0.5 * width, position[1] + 0.5 * (number_of_teeth \- 1 + fill_frac) * period), \(aq+x\(aq, period * fill_frac, [width], [], number_of_teeth, period, layer=layer, datatype=datatype) else: neff = lda / float(period) + sin_theta qmin = int(focus_distance / float(period) + 0.5) p = gdspy.Path(period * fill_frac, position) c3 = neff**2 \- sin_theta**2 w = 0.5 * width for q in range(qmin, qmin + number_of_teeth): c1 = q * lda * sin_theta c2 = (q * lda)**2 p.parametric(lambda t: (width * t \- w, (c1 + neff * numpy.sqrt(c2 \- c3 * (width * t \- w)**2)) / c3), tolerance=tolerance, max_points=0, layer=layer, datatype=datatype) p.x = position[0] p.y = position[1] sz = p.polygons[0].shape[0] // 2 if focus_width == 0: p.polygons[0] = numpy.vstack((p.polygons[0][:sz, :], [position])) elif focus_width > 0: p.polygons[0] = numpy.vstack((p.polygons[0][:sz, :], [(position[0] + 0.5 * focus_width, position[1]), (position[0] \- 0.5 * focus_width, position[1])])) p.fracture() if direction == \(aq\-x\(aq: return p.rotate(0.5 * numpy.pi, position) elif direction == \(aq+x\(aq: return p.rotate(\-0.5 * numpy.pi, position) elif direction == \(aq\-y\(aq: return p.rotate(numpy.pi, position) else: return p if __name__ == \(aq__main__\(aq: # Examples # Negative resist example width = 0.45 bend_radius = 50.0 ring_radius = 20.0 taper_len = 50.0 input_gap = 150.0 io_gap = 500.0 wg_gap = 20.0 ring_gaps = [0.06 + 0.02 * i for i in range(8)] ring = gdspy.Cell(\(aqNRing\(aq) ring.add(gdspy.Round((ring_radius, 0), ring_radius, ring_radius \- width, tolerance=0.001)) grat = gdspy.Cell(\(aqNGrat\(aq) grat.add(grating(0.626, 28, 0.5, 19, (0, 0), \(aq+y\(aq, 1.55, numpy.sin(numpy.pi * 8 / 180), 21.5, width, tolerance=0.001)) taper = gdspy.Cell(\(aqNTaper\(aq) taper.add(gdspy.Path(0.12, (0, 0)).segment(taper_len, \(aq+y\(aq, final_width=width)) c = gdspy.Cell(\(aqNegative\(aq) for i, gap in enumerate(ring_gaps): path = gdspy.FlexPath([(input_gap * i, taper_len)], width=width, corners=\(aqcircular bend\(aq, bend_radius=bend_radius, gdsii_path=True) path.segment((0, 600 \- wg_gap * i), relative=True) path.segment((io_gap, 0), relative=True) path.segment((0, 300 + wg_gap * i), relative=True) c.add(path) c.add(gdspy.CellReference(ring, (input_gap * i + width / 2 + gap, 300))) c.add(gdspy.CellArray(taper, len(ring_gaps), 1, (input_gap, 0), (0, 0))) c.add(gdspy.CellArray(grat, len(ring_gaps), 1, (input_gap, 0), (io_gap, 900 + taper_len))) # Positive resist example width = 0.45 ring_radius = 20.0 big_margin = 10.0 small_margin = 5.0 taper_len = 50.0 bus_len = 400.0 input_gap = 150.0 io_gap = 500.0 wg_gap = 20.0 ring_gaps = [0.06 + 0.02 * i for i in range(8)] ring_margin = gdspy.Rectangle((0, \-ring_radius \- big_margin), (2 * ring_radius + big_margin, ring_radius + big_margin)) ring_hole = gdspy.Round((ring_radius, 0), ring_radius, ring_radius \- width, tolerance=0.001) ring_bus = gdspy.Path(small_margin, (0, taper_len), number_of_paths=2, distance=small_margin + width) ring_bus.segment(bus_len, \(aq+y\(aq) p = gdspy.Path(small_margin, (0, 0), number_of_paths=2, distance=small_margin + width) p.segment(21.5, \(aq+y\(aq, final_distance=small_margin + 19) grat = gdspy.Cell(\(aqPGrat\(aq).add(p) grat.add(grating(0.626, 28, 0.5, 19, (0, 0), \(aq+y\(aq, 1.55, numpy.sin(numpy.pi * 8 / 180), 21.5, tolerance=0.001)) p = gdspy.Path(big_margin, (0, 0), number_of_paths=2, distance=big_margin + 0.12) p.segment(taper_len, \(aq+y\(aq, final_width=small_margin, final_distance=small_margin + width) taper = gdspy.Cell(\(aqPTaper\(aq).add(p) c = gdspy.Cell(\(aqPositive\(aq) for i, gap in enumerate(ring_gaps): path = gdspy.FlexPath([(input_gap * i, taper_len + bus_len)], width=[small_margin, small_margin], offset=small_margin + width, gdsii_path=True) path.segment((0, 600 \- bus_len \- bend_radius \- wg_gap * i), relative=True) path.turn(bend_radius, \(aqr\(aq) path.segment((io_gap \- 2 * bend_radius, 0), relative=True) path.turn(bend_radius, \(aql\(aq) path.segment((0, 300 \- bend_radius + wg_gap * i), relative=True) c.add(path) dx = width / 2 + gap c.add(gdspy.boolean( gdspy.boolean(ring_bus, gdspy.copy(ring_margin, dx, 300), \(aqor\(aq, precision=1e\-4), gdspy.copy(ring_hole, dx, 300), \(aqnot\(aq, precision=1e\-4).translate(input_gap * i, 0)) c.add(gdspy.CellArray(taper, len(ring_gaps), 1, (input_gap, 0), (0, 0))) c.add(gdspy.CellArray(grat, len(ring_gaps), 1, (input_gap, 0), (io_gap, 900 + taper_len))) # Save to a gds file and check out the output gdspy.write_gds(\(aqphotonics.gds\(aq) gdspy.LayoutViewer() .ft P .fi .UNINDENT .UNINDENT .SS Using System Fonts .sp This example uses \fI\%matplotlib\fP to render text using any typeface present in the system. The glyph paths are then transformed into polygon arrays that can be used to create \fIgdspy.PolygonSet\fP objects. .sp \fBfonts.py\fP .sp \fBfonts.gds\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ###################################################################### # # # Copyright 2009\-2019 Lucas Heitzmann Gabrielli. # # This file is part of gdspy, distributed under the terms of the # # Boost Software License \- Version 1.0. See the accompanying # # LICENSE file or # # # ###################################################################### from matplotlib.font_manager import FontProperties from matplotlib.textpath import TextPath import gdspy def render_text(text, size=None, position=(0, 0), font_prop=None, tolerance=0.1): path = TextPath(position, text, size=size, prop=font_prop) polys = [] xmax = position[0] for points, code in path.iter_segments(): if code == path.MOVETO: c = gdspy.Curve(*points, tolerance=tolerance) elif code == path.LINETO: c.L(*points) elif code == path.CURVE3: c.Q(*points) elif code == path.CURVE4: c.C(*points) elif code == path.CLOSEPOLY: poly = c.get_points() if poly.size > 0: if poly[:, 0].min() < xmax: i = len(polys) \- 1 while i >= 0: if gdspy.inside(poly[:1], [polys[i]], precision=0.1 * tolerance)[0]: p = polys.pop(i) poly = gdspy.boolean([p], [poly], \(aqxor\(aq, precision=0.1 * tolerance, max_points=0).polygons[0] break elif gdspy.inside(polys[i][:1], [poly], precision=0.1 * tolerance)[0]: p = polys.pop(i) poly = gdspy.boolean([p], [poly], \(aqxor\(aq, precision=0.1 * tolerance, max_points=0).polygons[0] i \-= 1 xmax = max(xmax, poly[:, 0].max()) polys.append(poly) return polys if __name__ == "__main__": fp = FontProperties(family=\(aqserif\(aq, style=\(aqitalic\(aq) text = gdspy.PolygonSet(render_text(\(aqText rendering\(aq, 10, font_prop=fp), layer=1) gdspy.Cell(\(aqTXT\(aq).add(text) gdspy.write_gds(\(aqfonts.gds\(aq) gdspy.LayoutViewer() .ft P .fi .UNINDENT .UNINDENT .SH API REFERENCE .SS Geometry Construction .SS PolygonSet .INDENT 0.0 .TP .B class gdspy.PolygonSet(polygons, layer=0, datatype=0) Bases: \fBobject\fP .sp Set of polygonal objects. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolygons\fP (\fIiterable of array\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- List containing the coordinates of the vertices of each polygon. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for this element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for this element (between 0 and 255). .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBpolygons\fP (\fIlist of numpy array\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of the vertices of each polygon. .IP \(bu 2 \fBlayers\fP (\fIlist of integer\fP) \-\- The GDSII layer number for each element. .IP \(bu 2 \fBdatatypes\fP (\fIlist of integer\fP) \-\- The GDSII datatype for each element (between 0 and 255). .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The last point should not be equal to the first (polygons are automatically closed). .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS Polygon .INDENT 0.0 .TP .B class gdspy.Polygon(points, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Polygonal geometric object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of the vertices of the polygon. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for this element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for this element (between 0 and 255). .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The last point should not be equal to the first (polygons are automatically closed). .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> triangle_pts = [(0, 40), (15, 40), (10, 50)] >>> triangle = gdspy.Polygon(triangle_pts) >>> myCell.add(triangle) .ft P .fi .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS Rectangle .INDENT 0.0 .TP .B class gdspy.Rectangle(point1, point2, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Rectangular geometric object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoint1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of a corner of the rectangle. .IP \(bu 2 \fBpoint2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of the corner of the rectangle opposite to \fIpoint1\fP\&. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for this element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for this element (between 0 and 255). .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> rectangle = gdspy.Rectangle((0, 0), (10, 20)) >>> myCell.add(rectangle) .ft P .fi .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS Round .INDENT 0.0 .TP .B class gdspy.Round(center, radius, inner_radius=0, initial_angle=0, final_angle=0, tolerance=0.01, number_of_points=None, max_points=199, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Circular geometric object. .sp Represent a circle, ellipse, ring or their sections. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of the center of the circle/ring. .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Radius of the circle/outer radius of the ring. To build an ellipse an array of 2 numbers can be used, representing the radii in the horizontal and vertical directions. .IP \(bu 2 \fBinner_radius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Inner radius of the ring. To build an elliptical hole, an array of 2 numbers can be used, representing the radii in the horizontal and vertical directions. .IP \(bu 2 \fBinitial_angle\fP (\fInumber\fP) \-\- Initial angle of the circular/ring section (in \fIradians\fP). .IP \(bu 2 \fBfinal_angle\fP (\fInumber\fP) \-\- Final angle of the circular/ring section (in \fIradians\fP). .IP \(bu 2 \fBtolerance\fP (\fIfloat\fP) \-\- Approximate curvature resolution. The number of points is automatically calculated. .IP \(bu 2 \fBnumber_of_points\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- Manually define the number of vertices that form the object (polygonal approximation). Overrides \fItolerance\fP\&. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If the number of points in the element is greater than \fImax_points\fP, it will be fractured in smaller polygons with at most \fImax_points\fP each. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for this element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for this element (between 0 and 255). .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> circle = gdspy.Round((30, 5), 8) >>> ell_ring = gdspy.Round((50, 5), (8, 7), inner_radius=(5, 4)) >>> pie_slice = gdspy.Round((30, 25), 8, initial_angle=0, \&... final_angle=\-5.0*numpy.pi/6.0) >>> arc = gdspy.Round((50, 25), 8, inner_radius=5, \&... initial_angle=\-5.0*numpy.pi/6.0, \&... final_angle=0) .ft P .fi .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS Text .INDENT 0.0 .TP .B class gdspy.Text(text, size, position=(0, 0), horizontal=True, angle=0, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Polygonal text object. .sp Each letter is formed by a series of polygons. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP (\fIstring\fP) \-\- The text to be converted in geometric objects. .IP \(bu 2 \fBsize\fP (\fInumber\fP) \-\- Height of the character. The width of a character and the distance between characters are this value multiplied by 5 / 9 and 8 / 9, respectively. For vertical text, the distance is multiplied by 11 / 9. .IP \(bu 2 \fBposition\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Text position (lower left corner). .IP \(bu 2 \fBhorizontal\fP (\fIbool\fP) \-\- If True, the text is written from left to right; if False, from top to bottom. .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation of the text. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for these elements. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for this element (between 0 and 255). .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> text = gdspy.Text(\(aqSample text\(aq, 20, (\-10, \-100)) >>> myCell.add(text) .ft P .fi .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS Path .INDENT 0.0 .TP .B class gdspy.Path(width, initial_point=(0, 0), number_of_paths=1, distance=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Series of geometric objects that form a path or a collection of parallel paths. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBwidth\fP (\fInumber\fP) \-\- The width of each path. .IP \(bu 2 \fBinitial_point\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Starting position of the path. .IP \(bu 2 \fBnumber_of_paths\fP (\fIpositive integer\fP) \-\- Number of parallel paths to create simultaneously. .IP \(bu 2 \fBdistance\fP (\fInumber\fP) \-\- Distance between the centers of adjacent paths. .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBx\fP (\fInumber\fP) \-\- Current position of the path in the x direction. .IP \(bu 2 \fBy\fP (\fInumber\fP) \-\- Current position of the path in the y direction. .IP \(bu 2 \fBw\fP (\fInumber\fP) \-\- \fIHalf\fP\-width of each path. .IP \(bu 2 \fBn\fP (\fIinteger\fP) \-\- Number of parallel paths. .IP \(bu 2 \fBdirection\fP (\fI\(aq+x\(aq\fP\fI, \fP\fI\(aq\-x\(aq\fP\fI, \fP\fI\(aq+y\(aq\fP\fI, \fP\fI\(aq\-y\(aq\fP\fI or \fP\fInumber\fP) \-\- Direction or angle (in \fIradians\fP) the path points to. .IP \(bu 2 \fBdistance\fP (\fInumber\fP) \-\- Distance between the centers of adjacent paths. .IP \(bu 2 \fBlength\fP (\fInumber\fP) \-\- Length of the central path axis. If only one path is created, this is the real length of the path. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The direction of the path is not modified by this method and its width is scaled only by \fIscalex\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B segment(length, direction=None, final_width=None, final_distance=None, axis_offset=0, layer=0, datatype=0) Add a straight section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBlength\fP (\fInumber\fP) \-\- Length of the section to add. .IP \(bu 2 \fBdirection\fP (\fI\(aq+x\(aq\fP\fI, \fP\fI\(aq\-x\(aq\fP\fI, \fP\fI\(aq+y\(aq\fP\fI, \fP\fI\(aq\-y\(aq\fP\fI or \fP\fInumber\fP) \-\- Direction or angle (in \fIradians\fP) of rotation of the segment. .IP \(bu 2 \fBfinal_width\fP (\fInumber\fP) \-\- If set, the paths of this segment will have their widths linearly changed from their current value to this one. .IP \(bu 2 \fBfinal_distance\fP (\fInumber\fP) \-\- If set, the distance between paths is linearly change from its current value to this one along this segment. .IP \(bu 2 \fBaxis_offset\fP (\fInumber\fP) \-\- If set, the paths will be offset from their direction by this amount. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B arc(radius, initial_angle, final_angle, tolerance=0.01, number_of_points=None, max_points=199, final_width=None, final_distance=None, layer=0, datatype=0) Add a curved section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Central radius of the section. .IP \(bu 2 \fBinitial_angle\fP (\fInumber\fP) \-\- Initial angle of the curve (in \fIradians\fP). .IP \(bu 2 \fBfinal_angle\fP (\fInumber\fP) \-\- Final angle of the curve (in \fIradians\fP). .IP \(bu 2 \fBtolerance\fP (\fIfloat\fP) \-\- Approximate curvature resolution. The number of points is automatically calculated. .IP \(bu 2 \fBnumber_of_points\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- Manually define the number of vertices that form the object (polygonal approximation). Overrides \fItolerance\fP\&. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If the number of points in the element is greater than \fImax_points\fP, it will be fractured in smaller polygons with at most \fImax_points\fP each. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBfinal_width\fP (\fInumber\fP) \-\- If set, the paths of this segment will have their widths linearly changed from their current value to this one. .IP \(bu 2 \fBfinal_distance\fP (\fInumber\fP) \-\- If set, the distance between paths is linearly change from its current value to this one along this segment. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B turn(radius, angle, tolerance=0.01, number_of_points=None, max_points=199, final_width=None, final_distance=None, layer=0, datatype=0) Add a curved section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Central radius of the section. .IP \(bu 2 \fBangle\fP (\fI\(aqr\(aq\fP\fI, \fP\fI\(aql\(aq\fP\fI, \fP\fI\(aqrr\(aq\fP\fI, \fP\fI\(aqll\(aq\fP\fI or \fP\fInumber\fP) \-\- Angle (in \fIradians\fP) of rotation of the path. The values \(aqr\(aq and \(aql\(aq represent 90\-degree turns cw and ccw, respectively; the values \(aqrr\(aq and \(aqll\(aq represent analogous 180\-degree turns. .IP \(bu 2 \fBtolerance\fP (\fIfloat\fP) \-\- Approximate curvature resolution. The number of points is automatically calculated. .IP \(bu 2 \fBnumber_of_points\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- Manually define the number of vertices that form the object (polygonal approximation). Overrides \fItolerance\fP\&. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If the number of points in the element is greater than \fImax_points\fP, it will be fractured in smaller polygons with at most \fImax_points\fP each. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBfinal_width\fP (\fInumber\fP) \-\- If set, the paths of this segment will have their widths linearly changed from their current value to this one. .IP \(bu 2 \fBfinal_distance\fP (\fInumber\fP) \-\- If set, the distance between paths is linearly change from its current value to this one along this segment. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B parametric(curve_function, curve_derivative=None, tolerance=0.01, number_of_evaluations=5, max_points=199, final_width=None, final_distance=None, relative=True, layer=0, datatype=0) Add a parametric curve to the path. .sp \fIcurve_function\fP will be evaluated uniformly in the interval [0, 1] at least \fInumber_of_points\fP times. More points will be added to the curve at the midpoint between evaluations if that points presents error larger than \fItolerance\fP\&. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcurve_function\fP (\fIcallable\fP) \-\- Function that defines the curve. Must be a function of one argument (that varies from 0 to 1) that returns a 2\-element array with the coordinates of the curve. .IP \(bu 2 \fBcurve_derivative\fP (\fIcallable\fP) \-\- If set, it should be the derivative of the curve function. Must be a function of one argument (that varies from 0 to 1) that returns a 2\-element array. If None, the derivative will be calculated numerically. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Acceptable tolerance for the approximation of the curve function by a finite number of evaluations. .IP \(bu 2 \fBnumber_of_evaluations\fP (\fIinteger\fP) \-\- Initial number of points where the curve function will be evaluated. According to \fItolerance\fP, more evaluations will be performed. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Elements will be fractured until each polygon has at most \fImax_points\fP\&. If \fImax_points\fP is less than 4, no fracture will occur. .IP \(bu 2 \fBfinal_width\fP (\fInumber\fP\fI or \fP\fIfunction\fP) \-\- If set to a number, the paths of this segment will have their widths linearly changed from their current value to this one. If set to a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. .IP \(bu 2 \fBfinal_distance\fP (\fInumber\fP\fI or \fP\fIfunction\fP) \-\- If set to a number, the distance between paths is linearly change from its current value to this one. If set to a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, the return values of \fIcurve_function\fP are used as offsets from the current path position, i.e., to ensure a continuous path, \fBcurve_function(0)\fP must be (0, 0). Otherwise, they are used as absolute coordinates. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The norm of the vector returned by \fIcurve_derivative\fP is not important. Only the direction is used. .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> def my_parametric_curve(t): \&... return (2**t, t**2) >>> def my_parametric_curve_derivative(t): \&... return (0.69315 * 2**t, 2 * t) >>> my_path.parametric(my_parametric_curve, \&... my_parametric_curve_derivative) .ft P .fi .UNINDENT .INDENT 7.0 .TP .B bezier(points, tolerance=0.01, number_of_evaluations=5, max_points=199, final_width=None, final_distance=None, relative=True, layer=0, datatype=0) Add a Bezier curve to the path. .sp A Bezier curve is added to the path starting from its current position and finishing at the last point in the \fIpoints\fP array. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Control points defining the Bezier curve. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Acceptable tolerance for the approximation of the curve function by a finite number of evaluations. .IP \(bu 2 \fBnumber_of_evaluations\fP (\fIinteger\fP) \-\- Initial number of points where the curve function will be evaluated. According to \fItolerance\fP, more evaluations will be performed. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Elements will be fractured until each polygon has at most \fImax_points\fP\&. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBfinal_width\fP (\fInumber\fP\fI or \fP\fIfunction\fP) \-\- If set to a number, the paths of this segment will have their widths linearly changed from their current value to this one. If set to a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. .IP \(bu 2 \fBfinal_distance\fP (\fInumber\fP\fI or \fP\fIfunction\fP) \-\- If set to a number, the distance between paths is linearly change from its current value to this one. If set to a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed Bezier will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B smooth(points, angles=None, curl_start=1, curl_end=1, t_in=1, t_out=1, cycle=False, tolerance=0.01, number_of_evaluations=5, max_points=199, final_widths=None, final_distances=None, relative=True, layer=0, datatype=0) Add a smooth interpolating curve through the given points. .sp Uses the Hobby algorithm .nf [1]_ .fi to calculate a smooth interpolating curve made of cubic Bezier segments between each pair of points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Vertices in the interpolating curve. .IP \(bu 2 \fBangles\fP (\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI] or \fP\fINone\fP) \-\- Tangent angles at each point (in \fIradians\fP). Any angles defined as None are automatically calculated. .IP \(bu 2 \fBcurl_start\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the first point and at its neighbor. A value of 1 renders the first segment a good approximation for a circular arc. A value of 0 will better approximate a straight segment. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBcurl_end\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the last point and at its neighbor. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBt_in\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when arriving at each point. One value per point or a single value used for all points. .IP \(bu 2 \fBt_out\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when leaving each point. One value per point or a single value used for all points. .IP \(bu 2 \fBcycle\fP (\fIbool\fP) \-\- If True, calculates control points for a closed curve, with an additional segment connecting the first and last points. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Acceptable tolerance for the approximation of the curve function by a finite number of evaluations. .IP \(bu 2 \fBnumber_of_evaluations\fP (\fIinteger\fP) \-\- Initial number of points where the curve function will be evaluated. According to \fItolerance\fP, more evaluations will be performed. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Elements will be fractured until each polygon has at most \fImax_points\fP\&. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBfinal_widths\fP (\fIarray\-like\fP\fI[\fP\fIM\fP\fI]\fP) \-\- Each element corresponds to the final width of a segment in the whole curve. If an element is a number, the paths of this segment will have their widths linearly changed to this value. If a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. The length of the array must be equal to the number of segments in the curve, i.e., M = N \- 1 for an open curve and M = N for a closed one. .IP \(bu 2 \fBfinal_distances\fP (\fIarray\-like\fP\fI[\fP\fIM\fP\fI]\fP) \-\- Each element corresponds to the final distance between paths of a segment in the whole curve. If an element is a number, the distance between paths is linearly change to this value. If a function, it must be a function of one argument (that varies from 0 to 1) and returns the width of the path. The length of the array must be equal to the number of segments in the curve, i.e., M = N \- 1 for an open curve and M = N for a closed one. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed curve will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The original GDSII specification supports only a maximum of 199 vertices per polygon. .UNINDENT .UNINDENT References .IP [1] 5 Hobby, J.D. \fIDiscrete Comput. Geom.\fP (1986) 1: 123. \fI\%DOI: 10.1007/BF02187690\fP .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .UNINDENT .SS PolyPath .INDENT 0.0 .TP .B class gdspy.PolyPath(points, width, number_of_paths=1, distance=0, corners=\(aqmiter\(aq, ends=\(aqflush\(aq, max_points=199, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Series of geometric objects that form a polygonal path or a collection of parallel polygonal paths. .sp Deprecated since version 1.4: \fIPolyPath\fP is deprecated in favor of FlexPath and will be removed in a future version of Gdspy. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Points along the center of the path. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP) \-\- Width of the path. If an array is given, width at each endpoint. .IP \(bu 2 \fBnumber_of_paths\fP (\fIpositive integer\fP) \-\- Number of parallel paths to create simultaneously. .IP \(bu 2 \fBdistance\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP) \-\- Distance between the centers of adjacent paths. If an array is given, distance at each endpoint. .IP \(bu 2 \fBcorners\fP (\fI\(aqmiter\(aq\fP\fI or \fP\fI\(aqbevel\(aq\fP) \-\- Type of joins. .IP \(bu 2 \fBends\fP (\fI\(aqflush\(aq\fP\fI, \fP\fI\(aqround\(aq\fP\fI, \fP\fI\(aqextended\(aq\fP) \-\- Type of end caps for the paths. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- The paths will be fractured in polygons with at most \fImax_points\fP (must be at least 4). If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The bevel join will give strange results if the number of paths is greater than 1. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS L1Path .INDENT 0.0 .TP .B class gdspy.L1Path(initial_point, direction, width, length, turn, number_of_paths=1, distance=0, max_points=199, layer=0, datatype=0) Bases: \fI\%gdspy.PolygonSet\fP .sp Series of geometric objects that form a path or a collection of parallel paths with Manhattan geometry. .sp Deprecated since version 1.4: \fIL1Path\fP is deprecated in favor of FlexPath and will be removed in a future version of Gdspy. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinitial_point\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Starting position of the path. .IP \(bu 2 \fBdirection\fP (\fI\(aq+x\(aq\fP\fI, \fP\fI\(aq+y\(aq\fP\fI, \fP\fI\(aq\-x\(aq\fP\fI, \fP\fI\(aq\-y\(aq\fP) \-\- Starting direction of the path. .IP \(bu 2 \fBwidth\fP (\fInumber\fP) \-\- The initial width of each path. .IP \(bu 2 \fBlength\fP (\fIarray\-like\fP) \-\- Lengths of each section to add. .IP \(bu 2 \fBturn\fP (\fIarray\-like\fP) \-\- Direction to turn before each section. The sign indicate the turn direction (ccw is positive), and the modulus is a multiplicative factor for the path width after each turn. Must have 1 element less then \fIlength\fP\&. .IP \(bu 2 \fBnumber_of_paths\fP (\fIpositive integer\fP) \-\- Number of parallel paths to create simultaneously. .IP \(bu 2 \fBdistance\fP (\fInumber\fP) \-\- Distance between the centers of adjacent paths. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- The paths will be fractured in polygons with at most \fImax_points\fP (must be at least 6). If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBx\fP (\fInumber\fP) \-\- Final position of the path in the x direction. .IP \(bu 2 \fBy\fP (\fInumber\fP) \-\- Final position of the path in the y direction. .IP \(bu 2 \fBdirection\fP (\fI\(aq+x\(aq\fP\fI, \fP\fI\(aq\-x\(aq\fP\fI, \fP\fI\(aq+y\(aq\fP\fI, \fP\fI\(aq\-y\(aq\fP\fI or \fP\fInumber\fP) \-\- Direction or angle (in \fIradians\fP) the path points to. The numerical angle is returned only after a rotation of the object. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> length = [10, 30, 15, 15, 15, 15, 10] >>> turn = [1, \-1, \-1, 3, \-1, 1] >>> l1path = gdspy.L1Path((0, 0), \(aq+x\(aq, 2, length, turn) >>> myCell.add(l1path) .ft P .fi .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIL1Path\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this polygon set. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fillet(radius, points_per_2pi=128, max_points=199, precision=0.001) Round the corners of these polygons and fractures them into polygons with less vertices if necessary. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP) \-\- Radius of the corners. If number: all corners filleted by that amount. If array: specify fillet radii on a per\-polygon basis (length must be equal to the number of polygons in this \fIPolygonSet\fP). Each element in the array can be a number (all corners filleted by the same amount) or another array of numbers, one per polygon vertex. Alternatively, the array can be flattened to have one radius per \fIPolygonSet\fP vertex. .IP \(bu 2 \fBpoints_per_2pi\fP (\fIinteger\fP) \-\- Number of vertices used to approximate a full circle. The number of vertices in each corner of the polygon will be the fraction of this number corresponding to the angle encompassed by that corner with respect to 2 pi. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5, otherwise the resulting polygon is not fractured). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates in case of fracturing. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B fracture(max_points=199, precision=0.001) Slice these polygons in the horizontal and vertical directions so that each resulting piece has at most \fImax_points\fP\&. This operation occurs in place. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- Maximal number of points in each resulting polygon (at least 5 for the fracture to occur). .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box of the polygons. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this polygon in the form [[x_min, y_min], [x_max, y_max]], or None if the polygon is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B mirror(p1, p2=(0, 0)) Mirror the polygons over a line through points 1 and 2 .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBp1\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- first point defining the reflection line .IP \(bu 2 \fBp2\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- second point defining the reflection line .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scalex, scaley=None, center=(0, 0)) Scale this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscalex\fP (\fInumber\fP) \-\- Scaling factor along the first axis. .IP \(bu 2 \fBscaley\fP (\fInumber\fP\fI or \fP\fINone\fP) \-\- Scaling factor along the second axis. If None, same as \fIscalex\fP\&. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this polygon. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIPolygonSet\fP .UNINDENT .UNINDENT .UNINDENT .SS FlexPath .INDENT 0.0 .TP .B class gdspy.FlexPath(points, width, offset=0, corners=\(aqnatural\(aq, ends=\(aqflush\(aq, bend_radius=None, tolerance=0.01, precision=0.001, max_points=199, gdsii_path=False, width_transform=True, layer=0, datatype=0) Bases: \fBobject\fP .sp Path object. .sp This class keeps information about the constructive parameters of the path and calculates its boundaries only upon request. .sp It can be stored as a proper path element in the GDSII format, unlike \fIPath\fP\&. In this case, the width must be constant along the whole path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Points along the center of the path. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- Width of each parallel path being created. The number of parallel paths being created is defined by the length of this list. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- Offsets of each parallel path from the center. If \fIwidth\fP is not a list, the length of this list is used to determine the number of parallel paths being created. Otherwise, offset must be a list with the same length as width, or a number, which is used as distance between adjacent paths. .IP \(bu 2 \fBcorners\fP (\fI\(aqnatural\(aq\fP\fI, \fP\fI\(aqmiter\(aq\fP\fI, \fP\fI\(aqbevel\(aq\fP\fI, \fP\fI\(aqround\(aq\fP\fI, \fP\fI\(aqsmooth\(aq\fP\fI, \fP\fI\(aqcircular bend\(aq\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- Type of joins. A callable must receive 6 arguments (vertex and direction vector from both segments being joined, the center and width of the path) and return a list of vertices that make the join. A list can be used to define the join for each parallel path. .IP \(bu 2 \fBends\fP (\fI\(aqflush\(aq\fP\fI, \fP\fI\(aqextended\(aq\fP\fI, \fP\fI\(aqround\(aq\fP\fI, \fP\fI\(aqsmooth\(aq\fP\fI, \fP\fI2\-tuple\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- Type of end caps for the paths. A 2\-element tuple represents the start and end extensions to the paths. A callable must receive 4 arguments (vertex and direction vectors from both sides of the path and return a list of vertices that make the end cap. A list can be used to define the end type for each parallel path. .IP \(bu 2 \fBbend_radius\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- Bend radii for each path when \fIcorners\fP is \(aqcircular bend\(aq. It has no effect for other corner types. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Tolerance used to draw the paths and calculate joins. .IP \(bu 2 \fBprecision\fP (\fInumber\fP) \-\- Precision for rounding the coordinates of vertices when fracturing the final polygonal boundary. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If the number of points in the polygonal path boundary is greater than \fImax_points\fP, it will be fractured in smaller polygons with at most \fImax_points\fP each. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBgdsii_path\fP (\fIbool\fP) \-\- If True, treat this object as a GDSII path element. Otherwise, it will be converted into polygonal boundaries when required. .IP \(bu 2 \fBwidth_transform\fP (\fIbool\fP) \-\- If \fIgdsii_path\fP is True, this flag indicates whether the width of the path should transform when scaling this object. It has no effect when \fIgdsii_path\fP is False. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The value of \fItolerance\fP should not be smaller than \fIprecision\fP, otherwise there would be wasted computational effort in calculating the paths. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygons(by_spec=False) Calculate the polygonal boundaries described by this path. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the polygons of each individual pair (layer, datatype). .TP .B Returns \fBout\fP \-\- List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if \fIby_spec\fP is True). .TP .B Return type list of array\-like[N][2] or dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_polygonset() Create a \fIPolygonSet\fP representation of this object. .sp The resulting object will be fractured according to the parameter \fImax_points\fP used when instantiating this object. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- A \fIPolygonSet\fP that contains all boundaries for this path. If the path is empty, returns None. .TP .B Return type \fIPolygonSet\fP or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .sp If \fIFlexPath.gdsii_path\fP is True, GDSII path elements are created instead of boundaries. Such paths do not support variable widths, but their memeory footprint is smaller than full polygonal boundaries. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this object. .sp This functions creates a \fIPolgonSet\fP from this object and calculates its area, which means it is computationally expensive. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scale, center=(0, 0)) Scale this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscale\fP (\fInumber\fP) \-\- Scaling factor. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(translation, rotation, scale, x_reflection, array_trans=None) Apply a transform to this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtranslation\fP (\fINumpy array\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Translation vector. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Rotation angle. .IP \(bu 2 \fBscale\fP (\fInumber\fP) \-\- Scaling factor. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- Reflection around the first axis. .IP \(bu 2 \fBarray_trans\fP (\fINumpy aray\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Translation vector before rotation and reflection. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Applies the transformations in the same order as a \fICellReference\fP or a \fICellArray\fP\&. If \fIwidth_transform\fP is False, the widths are not scaled. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B segment(end_point, width=None, offset=None, relative=False) Add a straight section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBend_point\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- End position of the straight segment. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, \fIend_point\fP is used as an offset from the current path position, i.e., if the path is at (1, \-2) and the \fIend_point\fP is (10, 25), the segment will be constructed from (1, \-2) to (1 + 10, \-2 + 25) = (11, 23). Otherwise, \fIend_point\fP is used as an absolute coordinate. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B arc(radius, initial_angle, final_angle, width=None, offset=None) Add a circular arc section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Radius of the circular arc. .IP \(bu 2 \fBinitial_angle\fP (\fInumber\fP) \-\- Initial angle of the arc. .IP \(bu 2 \fBfinal_angle\fP (\fInumber\fP) \-\- Final angle of the arc. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B turn(radius, angle, width=None, offset=None) Add a circular turn to the path. .sp The initial angle of the arc is calculated from the last path segment. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Radius of the circular arc. .IP \(bu 2 \fBangle\fP (\fI\(aqr\(aq\fP\fI, \fP\fI\(aql\(aq\fP\fI, \fP\fI\(aqrr\(aq\fP\fI, \fP\fI\(aqll\(aq\fP\fI or \fP\fInumber\fP) \-\- Angle (in \fIradians\fP) of rotation of the path. The values \(aqr\(aq and \(aql\(aq represent 90\-degree turns cw and ccw, respectively; the values \(aqrr\(aq and \(aqll\(aq represent analogous 180\-degree turns. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B parametric(curve_function, width=None, offset=None, relative=True) Add a parametric curve to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcurve_function\fP (\fIcallable\fP) \-\- Function that defines the curve. Must be a function of one argument (that varies from 0 to 1) that returns a 2\-element Numpy array with the coordinates of the curve. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, the return values of \fIcurve_function\fP are used as offsets from the current path position, i.e., to ensure a continuous path, \fBcurve_function(0)\fP must be (0, 0). Otherwise, they are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B bezier(points, width=None, offset=None, relative=True) Add a Bezier curve to the path. .sp A Bezier curve is added to the path starting from its current position and finishing at the last point in the \fIpoints\fP array. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Control points defining the Bezier curve. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed Bezier will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B smooth(points, angles=None, curl_start=1, curl_end=1, t_in=1, t_out=1, cycle=False, width=None, offset=None, relative=True) Add a smooth interpolating curve through the given points. .sp Uses the Hobby algorithm .nf [1]_ .fi to calculate a smooth interpolating curve made of cubic Bezier segments between each pair of points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Vertices in the interpolating curve. .IP \(bu 2 \fBangles\fP (\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI] or \fP\fINone\fP) \-\- Tangent angles at each point (in \fIradians\fP). Any angles defined as None are automatically calculated. .IP \(bu 2 \fBcurl_start\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the first point and at its neighbor. A value of 1 renders the first segment a good approximation for a circular arc. A value of 0 will better approximate a straight segment. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBcurl_end\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the last point and at its neighbor. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBt_in\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when arriving at each point. One value per point or a single value used for all points. .IP \(bu 2 \fBt_out\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when leaving each point. One value per point or a single value used for all points. .IP \(bu 2 \fBcycle\fP (\fIbool\fP) \-\- If True, calculates control points for a closed curve, with an additional segment connecting the first and last points. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. A list can be used where each element defines the width for one of the parallel paths in this object. This argument has no effect if the path was created with \fIgdsii_path\fP True. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). A list can be used where each element defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed curve will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIFlexPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Arguments \fIwidth\fP and \fIoffset\fP are repeated for \fIeach\fP cubic Bezier that composes this path element. .UNINDENT .UNINDENT References .IP [1] 5 Hobby, J.D. \fIDiscrete Comput. Geom.\fP (1986) 1: 123. \fI\%DOI: 10.1007/BF02187690\fP .UNINDENT .UNINDENT .SS RobustPath .INDENT 0.0 .TP .B class gdspy.RobustPath(initial_point, width, offset=0, ends=\(aqflush\(aq, tolerance=0.01, precision=0.001, max_points=199, max_evals=1000, gdsii_path=False, width_transform=True, layer=0, datatype=0) Bases: \fBobject\fP .sp Path object with lazy evaluation. .sp This class keeps information about the constructive parameters of the path and calculates its boundaries only upon request. The benefits are that joins and path components can be calculated automatically to ensure continuity (except in extreme cases). .sp It can be stored as a proper path element in the GDSII format, unlike \fIPath\fP\&. In this case, the width must be constant along the whole path. .sp The downside of \fIRobustPath\fP is that it is more computationally expensive than the other path classes. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinitial_point\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Starting position of the path. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- Width of each parallel path being created. The number of parallel paths being created is defined by the length of this list. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIlist\fP) \-\- Offsets of each parallel path from the center. If \fIwidth\fP is not a list, the length of this list is used to determine the number of parallel paths being created. Otherwise, offset must be a list with the same length as width, or a number, which is used as distance between adjacent paths. .IP \(bu 2 \fBends\fP (\fI\(aqflush\(aq\fP\fI, \fP\fI\(aqextended\(aq\fP\fI, \fP\fI\(aqround\(aq\fP\fI, \fP\fI\(aqsmooth\(aq\fP\fI, \fP\fI2\-tuple\fP\fI, \fP\fIlist\fP) \-\- Type of end caps for the paths. A 2\-element tuple represents the start and end extensions to the paths. A list can be used to define the end type for each parallel path. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Tolerance used to draw the paths and calculate joins. .IP \(bu 2 \fBprecision\fP (\fInumber\fP) \-\- Precision for rounding the coordinates of vertices when fracturing the final polygonal boundary. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If the number of points in the polygonal path boundary is greater than \fImax_points\fP, it will be fractured in smaller polygons with at most \fImax_points\fP each. If \fImax_points\fP is zero no fracture will occur. .IP \(bu 2 \fBmax_evals\fP (\fIinteger\fP) \-\- Limit to the maximal number of evaluations when calculating each path component. .IP \(bu 2 \fBgdsii_path\fP (\fIbool\fP) \-\- If True, treat this object as a GDSII path element. Otherwise, it will be converted into polygonal boundaries when required. .IP \(bu 2 \fBwidth_transform\fP (\fIbool\fP) \-\- If \fIgdsii_path\fP is True, this flag indicates whether the width of the path should transform when scaling this object. It has no effect when \fIgdsii_path\fP is False. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements of each path. If the number of layers in the list is less than the number of paths, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the elements of each path (between 0 and 255). If the number of datatypes in the list is less than the number of paths, the list is repeated. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The value of \fItolerance\fP should not be smaller than \fIprecision\fP, otherwise there would be wasted computational effort in calculating the paths. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B grad(u, arm=0, side=\(aq\-\(aq) Calculate the direction vector of each parallel path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBu\fP (\fInumber\fP) \-\- Position along the \fIRobustPath\fP to compute. This argument can range from 0 (start of the path) to \fIlen(self)\fP (end of the path). .IP \(bu 2 \fBarm\fP (\fI\-1\fP\fI, \fP\fI0\fP\fI, \fP\fI1\fP) \-\- Wether to calculate one of the path boundaries (\-1 or 1) or its central spine (0). .IP \(bu 2 \fBside\fP (\fI\(aq\-\(aq\fP\fI or \fP\fI\(aq+\(aq\fP) \-\- At path joins, whether to calculate the direction using the component before or after the join. .UNINDENT .TP .B Returns \fBout\fP \-\- Direction vectors for each of the N parallel paths in this object. .TP .B Return type Numpy array[N, 2] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B width(u) Calculate the width of each parallel path. .INDENT 7.0 .TP .B Parameters \fBu\fP (\fInumber\fP) \-\- Position along the \fIRobustPath\fP to compute. This argument can range from 0 (start of the path) to \fIlen(self)\fP (end of the path). .TP .B Returns \fBout\fP \-\- Width for each of the N parallel paths in this object. .TP .B Return type Numpy array[N] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygons(by_spec=False) Calculate the polygonal boundaries described by this path. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the polygons of each individual pair (layer, datatype). .TP .B Returns \fBout\fP \-\- List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if \fIby_spec\fP is True). .TP .B Return type list of array\-like[N][2] or dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_polygonset() Create a \fIPolygonSet\fP representation of this object. .sp The resulting object will be fractured according to the parameter \fImax_points\fP used when instantiating this object. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- A \fIPolygonSet\fP that contains all boundaries for this path. If the path is empty, returns None. .TP .B Return type \fIPolygonSet\fP or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a series of GDSII elements. .sp If \fIRobustPath.gdsii_path\fP is True, GDSII path elements are created instead of boundaries. Such paths do not support variable widths, but their memeory footprint is smaller than full polygonal boundaries. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII elements. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of this object. .sp This functions creates a \fIPolgonSet\fP from this object and calculates its area, which means it is computationally expensive. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with \fB{(layer, datatype): area}\fP\&. .TP .B Returns \fBout\fP \-\- Area of this object. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B rotate(angle, center=(0, 0)) Rotate this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBangle\fP (\fInumber\fP) \-\- The angle of rotation (in \fIradians\fP). .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the rotation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B scale(scale, center=(0, 0)) Scale this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBscale\fP (\fInumber\fP) \-\- Scaling factor. .IP \(bu 2 \fBcenter\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Center point for the scaling operation. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B transform(translation, rotation, scale, x_reflection, array_trans=None) Apply a transform to this path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtranslation\fP (\fINumpy array\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Translation vector. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Rotation angle. .IP \(bu 2 \fBscale\fP (\fInumber\fP) \-\- Scaling factor. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- Reflection around the first axis. .IP \(bu 2 \fBarray_trans\fP (\fINumpy aray\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Translation vector before rotation and reflection. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Applies the transformations in the same order as a \fICellReference\fP or a \fICellArray\fP\&. If \fIwidth_transform\fP is False, the widths are not scaled. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B segment(end_point, width=None, offset=None, relative=False) Add a straight section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBend_point\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- End position of the straight segment. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, \fIend_point\fP is used as an offset from the current path position, i.e., if the path is at (1, \-2) and the \fIend_point\fP is (10, 25), the segment will be constructed from (1, \-2) to (1 + 10, \-2 + 25) = (11, 23). Otherwise, \fIend_point\fP is used as an absolute coordinate. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B arc(radius, initial_angle, final_angle, width=None, offset=None) Add a circular arc section to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Radius of the circular arc. .IP \(bu 2 \fBinitial_angle\fP (\fInumber\fP) \-\- Initial angle of the arc. .IP \(bu 2 \fBfinal_angle\fP (\fInumber\fP) \-\- Final angle of the arc. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B turn(radius, angle, width=None, offset=None) Add a circular turn to the path. .sp The initial angle of the arc is calculated from an average of the current directions of all parallel paths in this object. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP) \-\- Radius of the circular arc. .IP \(bu 2 \fBangle\fP (\fI\(aqr\(aq\fP\fI, \fP\fI\(aql\(aq\fP\fI, \fP\fI\(aqrr\(aq\fP\fI, \fP\fI\(aqll\(aq\fP\fI or \fP\fInumber\fP) \-\- Angle (in \fIradians\fP) of rotation of the path. The values \(aqr\(aq and \(aql\(aq represent 90\-degree turns cw and ccw, respectively; the values \(aqrr\(aq and \(aqll\(aq represent analogous 180\-degree turns. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B parametric(curve_function, curve_derivative=None, width=None, offset=None, relative=True) Add a parametric curve to the path. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcurve_function\fP (\fIcallable\fP) \-\- Function that defines the curve. Must be a function of one argument (that varies from 0 to 1) that returns a 2\-element Numpy array with the coordinates of the curve. .IP \(bu 2 \fBcurve_derivative\fP (\fIcallable\fP) \-\- If set, it should be the derivative of the curve function. Must be a function of one argument (that varies from 0 to 1) that returns a 2\-element Numpy array. If None, the derivative will be calculated numerically. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, the return values of \fIcurve_function\fP are used as offsets from the current path position, i.e., to ensure a continuous path, \fBcurve_function(0)\fP must be (0, 0). Otherwise, they are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B bezier(points, width=None, offset=None, relative=True) Add a Bezier curve to the path. .sp A Bezier curve is added to the path starting from its current position and finishing at the last point in the \fIpoints\fP array. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Control points defining the Bezier curve. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed Bezier will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B smooth(points, angles=None, curl_start=1, curl_end=1, t_in=1, t_out=1, cycle=False, width=None, offset=None, relative=True) Add a smooth interpolating curve through the given points. .sp Uses the Hobby algorithm .nf [1]_ .fi to calculate a smooth interpolating curve made of cubic Bezier segments between each pair of points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Vertices in the interpolating curve. .IP \(bu 2 \fBangles\fP (\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI] or \fP\fINone\fP) \-\- Tangent angles at each point (in \fIradians\fP). Any angles defined as None are automatically calculated. .IP \(bu 2 \fBcurl_start\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the first point and at its neighbor. A value of 1 renders the first segment a good approximation for a circular arc. A value of 0 will better approximate a straight segment. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBcurl_end\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the last point and at its neighbor. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBt_in\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when arriving at each point. One value per point or a single value used for all points. .IP \(bu 2 \fBt_out\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when leaving each point. One value per point or a single value used for all points. .IP \(bu 2 \fBcycle\fP (\fIbool\fP) \-\- If True, calculates control points for a closed curve, with an additional segment connecting the first and last points. .IP \(bu 2 \fBwidth\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths are linearly tapered to this width along the segment. If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the width of the path. A list can be used where each element (number or callable) defines the width for one of the parallel paths in this object. .IP \(bu 2 \fBoffset\fP (\fInumber\fP\fI, \fP\fIcallable\fP\fI, \fP\fIlist\fP) \-\- If a number, all parallel paths offsets are linearly \fIincreased\fP by this amount (which can be negative). If this is callable, it must be a function of one argument (that varies from 0 to 1) that returns the offset \fIincrease\fP\&. A list can be used where each element (number or callable) defines the \fIabsolute\fP offset (not offset increase) for one of the parallel paths in this object. .IP \(bu 2 \fBrelative\fP (\fIbool\fP) \-\- If True, all coordinates in the \fIpoints\fP array are used as offsets from the current path position, i.e., if the path is at (1, \-2) and the last point in the array is (10, 25), the constructed curve will end at (1 + 10, \-2 + 25) = (11, 23). Otherwise, the points are used as absolute coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIRobustPath\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Arguments \fIwidth\fP and \fIoffset\fP are repeated for \fIeach\fP cubic Bezier that composes this path element. .UNINDENT .UNINDENT References .IP [1] 5 Hobby, J.D. \fIDiscrete Comput. Geom.\fP (1986) 1: 123. \fI\%DOI: 10.1007/BF02187690\fP .UNINDENT .UNINDENT .SS Curve .INDENT 0.0 .TP .B class gdspy.Curve(x, y=0, tolerance=0.01) Bases: \fBobject\fP .sp Generation of curves loosely based on SVG paths. .sp Short summary of available methods: .TS center; |l|l|. _ T{ Method T} T{ Primitive T} _ T{ L/l T} T{ Line segments T} _ T{ H/h T} T{ Horizontal line segments T} _ T{ V/v T} T{ Vertical line segments T} _ T{ C/c T} T{ Cubic Bezier curve T} _ T{ S/s T} T{ Smooth cubic Bezier curve T} _ T{ Q/q T} T{ Quadratic Bezier curve T} _ T{ T/t T} T{ Smooth quadratic Bezier curve T} _ T{ B/b T} T{ General degree Bezier curve T} _ T{ I/i T} T{ Smooth interpolating curve T} _ T{ arc T} T{ Elliptical arc T} _ .TE .sp The uppercase version of the methods considers that all coordinates are absolute, whereas the lowercase considers that they are relative to the current end point of the curve. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBx\fP (\fInumber\fP) \-\- X\-coordinate of the starting point of the curve. If this is a complex number, the value of \fIy\fP is ignored and the starting point becomes \fB(x.real, x.imag)\fP\&. .IP \(bu 2 \fBy\fP (\fInumber\fP) \-\- Y\-coordinate of the starting point of the curve. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- Tolerance used to calculate a polygonal approximation to the curve. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp In all methods of this class that accept coordinate pairs, a single complex number can be passed to be split into its real and imaginary parts. This feature can be useful in expressing coordinates in polar form. .sp All commands follow the SVG 2 specification, except for elliptical arcs and smooth interpolating curves, which are inspired by the Metapost syntax. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> curve = gdspy.Curve(3, 4).H(1).q(0.5, 1, 2j).L(2 + 3j, 2, 2) >>> pol = gdspy.Polygon(curve.get_points()) .ft P .fi .INDENT 7.0 .TP .B get_points() Get the polygonal points that approximate this curve. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Vertices of the polygon. .TP .B Return type Numpy array[N, 2] .UNINDENT .UNINDENT .INDENT 7.0 .TP .B L(*xy) Add straight line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Endpoint coordinates of the line segments. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B l(*xy) Add straight line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Endpoint coordinates of the line segments relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B H(*x) Add horizontal line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBx\fP (\fInumbers\fP) \-\- Endpoint x\-coordinates of the line segments. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B h(*x) Add horizontal line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBx\fP (\fInumbers\fP) \-\- Endpoint x\-coordinates of the line segments relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B V(*y) Add vertical line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBy\fP (\fInumbers\fP) \-\- Endpoint y\-coordinates of the line segments. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B v(*y) Add vertical line segments to the curve. .INDENT 7.0 .TP .B Parameters \fBy\fP (\fInumbers\fP) \-\- Endpoint y\-coordinates of the line segments relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B arc(radius, initial_angle, final_angle, rotation=0) Add an elliptical arc to the curve. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBradius\fP (\fInumber\fP\fI, \fP\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Arc radius. An elliptical arc can be created by passing an array with 2 radii. .IP \(bu 2 \fBinitial_angle\fP (\fInumber\fP) \-\- Initial angle of the arc (in \fIradians\fP). .IP \(bu 2 \fBfinal_angle\fP (\fInumber\fP) \-\- Final angle of the arc (in \fIradians\fP). .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Rotation of the axis of the ellipse. .UNINDENT .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B C(*xy) Add cubic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 3 pairs are interpreted as the control point at the beginning of the curve, the control point at the end of the curve and the endpoint of the curve. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B c(*xy) Add cubic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 3 pairs are interpreted as the control point at the beginning of the curve, the control point at the end of the curve and the endpoint of the curve. All coordinates are relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B S(*xy) Add smooth cubic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 2 pairs are interpreted as the control point at the end of the curve and the endpoint of the curve. The control point at the beginning of the curve is assumed to be the reflection of the control point at the end of the last curve relative to the starting point of the curve. If the previous curve is not a cubic Bezier, the control point is coincident with the starting point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B s(*xy) Add smooth cubic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 2 pairs are interpreted as the control point at the end of the curve and the endpoint of the curve. The control point at the beginning of the curve is assumed to be the reflection of the control point at the end of the last curve relative to the starting point of the curve. If the previous curve is not a cubic Bezier, the control point is coincident with the starting point. All coordinates are relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Q(*xy) Add quadratic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 2 pairs are interpreted as the control point and the endpoint of the curve. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B q(*xy) Add quadratic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. Each set of 2 pairs are interpreted as the control point and the endpoint of the curve. All coordinates are relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B T(*xy) Add smooth quadratic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinates of the endpoints of the curves. The control point is assumed to be the reflection of the control point of the last curve relative to the starting point of the curve. If the previous curve is not a quadratic Bezier, the control point is coincident with the starting point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B t(*xy) Add smooth quadratic Bezier curves to the curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinates of the endpoints of the curves. The control point is assumed to be the reflection of the control point of the last curve relative to the starting point of the curve. If the previous curve is not a quadratic Bezier, the control point is coincident with the starting point. All coordinates are relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B B(*xy) Add a general degree Bezier curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. The last coordinate is the endpoint of curve and all other are control points. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B b(*xy) Add a general degree Bezier curve. .INDENT 7.0 .TP .B Parameters \fBxy\fP (\fInumbers\fP) \-\- Coordinate pairs. The last coordinate is the endpoint of curve and all other are control points. All coordinates are relative to the current end point. .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B I(points, angles=None, curl_start=1, curl_end=1, t_in=1, t_out=1, cycle=False) Add a smooth interpolating curve through the given points. .sp Uses the Hobby algorithm .nf [1]_ .fi to calculate a smooth interpolating curve made of cubic Bezier segments between each pair of points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Vertices in the interpolating curve. .IP \(bu 2 \fBangles\fP (\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI] or \fP\fINone\fP) \-\- Tangent angles at each point (in \fIradians\fP). Any angles defined as None are automatically calculated. .IP \(bu 2 \fBcurl_start\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the first point and at its neighbor. A value of 1 renders the first segment a good approximation for a circular arc. A value of 0 will better approximate a straight segment. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBcurl_end\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the last point and at its neighbor. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBt_in\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when arriving at each point. One value per point or a single value used for all points. .IP \(bu 2 \fBt_out\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when leaving each point. One value per point or a single value used for all points. .IP \(bu 2 \fBcycle\fP (\fIbool\fP) \-\- If True, calculates control points for a closed curve, with an additional segment connecting the first and last points. .UNINDENT .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT Examples.sp .nf .ft C >>> c1 = gdspy.Curve(0, 1).I([(1, 1), (2, 1), (1, 0)]) >>> c2 = gdspy.Curve(0, 2).I([(1, 2), (2, 2), (1, 1)], \&... cycle=True) >>> ps = gdspy.PolygonSet([c1.get_points(), c2.get_points()]) .ft P .fi References .IP [1] 5 Hobby, J.D. \fIDiscrete Comput. Geom.\fP (1986) 1: 123. \fI\%DOI: 10.1007/BF02187690\fP .UNINDENT .INDENT 7.0 .TP .B i(points, angles=None, curl_start=1, curl_end=1, t_in=1, t_out=1, cycle=False) Add a smooth interpolating curve through the given points. .sp Uses the Hobby algorithm .nf [1]_ .fi to calculate a smooth interpolating curve made of cubic Bezier segments between each pair of points. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Vertices in the interpolating curve (relative to teh current endpoint). .IP \(bu 2 \fBangles\fP (\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI] or \fP\fINone\fP) \-\- Tangent angles at each point (in \fIradians\fP). Any angles defined as None are automatically calculated. .IP \(bu 2 \fBcurl_start\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the first point and at its neighbor. A value of 1 renders the first segment a good approximation for a circular arc. A value of 0 will better approximate a straight segment. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBcurl_end\fP (\fInumber\fP) \-\- Ratio between the mock curvatures at the last point and at its neighbor. It has no effect for closed curves or when an angle is defined for the first point. .IP \(bu 2 \fBt_in\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when arriving at each point. One value per point or a single value used for all points. .IP \(bu 2 \fBt_out\fP (\fInumber\fP\fI or \fP\fIarray\-like\fP\fI[\fP\fIN + 1\fP\fI]\fP) \-\- Tension parameter when leaving each point. One value per point or a single value used for all points. .IP \(bu 2 \fBcycle\fP (\fIbool\fP) \-\- If True, calculates control points for a closed curve, with an additional segment connecting the first and last points. .UNINDENT .TP .B Returns \fBout\fP \-\- This curve. .TP .B Return type \fICurve\fP .UNINDENT Examples.sp .nf .ft C >>> c1 = gdspy.Curve(0, 1).i([(1, 0), (2, 0), (1, \-1)]) >>> c2 = gdspy.Curve(0, 2).i([(1, 0), (2, 0), (1, \-1)], \&... cycle=True) >>> ps = gdspy.PolygonSet([c1.get_points(), c2.get_points()]) .ft P .fi References .IP [1] 5 Hobby, J.D. \fIDiscrete Comput. Geom.\fP (1986) 1: 123. \fI\%DOI: 10.1007/BF02187690\fP .UNINDENT .UNINDENT .SS Label .INDENT 0.0 .TP .B class gdspy.Label(text, position, anchor=\(aqo\(aq, rotation=None, magnification=None, x_reflection=False, layer=0, texttype=0) Bases: \fBobject\fP .sp Text that can be used to label parts of the geometry or display messages. The text does not create additional geometry, it\(aqs meant for display and labeling purposes only. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBtext\fP (\fIstring\fP) \-\- The text of this label. .IP \(bu 2 \fBposition\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Text anchor position. .IP \(bu 2 \fBanchor\fP (\fI\(aqn\(aq\fP\fI, \fP\fI\(aqs\(aq\fP\fI, \fP\fI\(aqe\(aq\fP\fI, \fP\fI\(aqw\(aq\fP\fI, \fP\fI\(aqo\(aq\fP\fI, \fP\fI\(aqne\(aq\fP\fI, \fP\fI\(aqnw\(aq...\fP) \-\- Position of the anchor relative to the text. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Angle of rotation of the label (in \fIdegrees\fP). .IP \(bu 2 \fBmagnification\fP (\fInumber\fP) \-\- Magnification factor for the label. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- If True, the label is reflected parallel to the x direction before being rotated (not supported by LayoutViewer). .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for these elements. .IP \(bu 2 \fBtexttype\fP (\fIinteger\fP) \-\- The GDSII text type for the label (between 0 and 63). .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBtext\fP (\fIstring\fP) \-\- The text of this label. .IP \(bu 2 \fBposition\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Text anchor position. .IP \(bu 2 \fBanchor\fP (\fIint\fP) \-\- Position of the anchor relative to the text. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Angle of rotation of the label (in \fIdegrees\fP). .IP \(bu 2 \fBmagnification\fP (\fInumber\fP) \-\- Magnification factor for the label. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- If True, the label is reflected parallel to the x direction before being rotated (not supported by LayoutViewer). .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for these elements. .IP \(bu 2 \fBtexttype\fP (\fIinteger\fP) \-\- The GDSII text type for the label (between 0 and 63). .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> label = gdspy.Label(\(aqSample label\(aq, (10, 0), \(aqsw\(aq) >>> myCell.add(label) .ft P .fi .INDENT 7.0 .TP .B to_gds(multiplier) Convert this label to a GDSII structure. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII structure. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this label. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this label. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fILabel\fP .UNINDENT Examples.sp .nf .ft C >>> text = gdspy.Label((0, 0), (10, 20)) >>> text = text.translate(2, 0) >>> myCell.add(text) .ft P .fi .UNINDENT .UNINDENT .SS boolean .INDENT 0.0 .TP .B gdspy.boolean(operand1, operand2, operation, precision=0.001, max_points=199, layer=0, datatype=0) Execute any boolean operation between 2 polygons or polygon sets. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoperand1\fP (\fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- First operand. If this is an iterable, each element must be a \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP, or an array\-like[N][2] of vertices of a polygon. .IP \(bu 2 \fBoperand2\fP (None, \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- Second operand. If this is an iterable, each element must be a \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP, or an array\-like[N][2] of vertices of a polygon. .IP \(bu 2 \fBoperation\fP (\fI{\(aqor\(aq\fP\fI, \fP\fI\(aqand\(aq\fP\fI, \fP\fI\(aqxor\(aq\fP\fI, \fP\fI\(aqnot\(aq}\fP) \-\- Boolean operation to be executed. The \(aqnot\(aq operation returns the difference \fBoperand1 \- operand2\fP\&. .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If greater than 4, fracture the resulting polygons to ensure they have at most \fImax_points\fP vertices. This is not a tessellating function, so this number should be as high as possible. For example, it should be set to 199 for polygons being drawn in GDSII files. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for the resulting element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for the resulting element (between 0 and 255). .UNINDENT .TP .B Returns \fBout\fP \-\- Result of the boolean operation. .TP .B Return type PolygonSet or None .UNINDENT .UNINDENT .SS offset .INDENT 0.0 .TP .B gdspy.offset(polygons, distance, join=\(aqmiter\(aq, tolerance=2, precision=0.001, join_first=False, max_points=199, layer=0, datatype=0) Shrink or expand a polygon or polygon set. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolygons\fP (\fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- Polygons to be offset. If this is an iterable, each element must be a \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP, or an array\-like[N][2] of vertices of a polygon. .IP \(bu 2 \fBdistance\fP (\fInumber\fP) \-\- Offset distance. Positive to expand, negative to shrink. .IP \(bu 2 \fBjoin\fP (\fI\(aqmiter\(aq\fP\fI, \fP\fI\(aqbevel\(aq\fP\fI, \fP\fI\(aqround\(aq\fP) \-\- Type of join used to create the offset polygon. .IP \(bu 2 \fBtolerance\fP (\fInumber\fP) \-\- For miter joints, this number must be at least 2 and it 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. .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertex coordinates. .IP \(bu 2 \fBjoin_first\fP (\fIbool\fP) \-\- Join all paths before offsetting to avoid unnecessary joins in adjacent polygon sides. .IP \(bu 2 \fBmax_points\fP (\fIinteger\fP) \-\- If greater than 4, fracture the resulting polygons to ensure they have at most \fImax_points\fP vertices. This is not a tessellating function, so this number should be as high as possible. For example, it should be set to 199 for polygons being drawn in GDSII files. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP) \-\- The GDSII layer number for the resulting element. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP) \-\- The GDSII datatype for the resulting element (between 0 and 255). .UNINDENT .TP .B Returns \fBout\fP \-\- Return the offset shape as a set of polygons. .TP .B Return type \fIPolygonSet\fP or None .UNINDENT .UNINDENT .SS slice .INDENT 0.0 .TP .B gdspy.slice(polygons, position, axis, precision=0.001, layer=0, datatype=0) Slice polygons and polygon sets at given positions along an axis. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpolygons\fP (\fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- Operand of the slice operation. If this is an iterable, each element must be a \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP, or an array\-like[N][2] of vertices of a polygon. .IP \(bu 2 \fBposition\fP (\fInumber\fP\fI or \fP\fIlist of numbers\fP) \-\- Positions to perform the slicing operation along the specified axis. .IP \(bu 2 \fBaxis\fP (\fI0\fP\fI or \fP\fI1\fP) \-\- Axis along which the polygon will be sliced. .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .IP \(bu 2 \fBlayer\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII layer numbers for the elements between each division. If the number of layers in the list is less than the number of divided regions, the list is repeated. .IP \(bu 2 \fBdatatype\fP (\fIinteger\fP\fI, \fP\fIlist\fP) \-\- The GDSII datatype for the resulting element (between 0 and 255). If the number of datatypes in the list is less than the number of divided regions, the list is repeated. .UNINDENT .TP .B Returns \fBout\fP \-\- Result of the slicing operation, with N = len(positions) + 1. Each PolygonSet comprises all polygons between 2 adjacent slicing positions, in crescent order. .TP .B Return type list[N] of \fIPolygonSet\fP or None .UNINDENT Examples.sp .nf .ft C >>> ring = gdspy.Round((0, 0), 10, inner_radius = 5) >>> result = gdspy.slice(ring, [\-7, 7], 0) >>> cell.add(result[1]) .ft P .fi .UNINDENT .SS inside .INDENT 0.0 .TP .B gdspy.inside(points, polygons, short_circuit=\(aqany\(aq, precision=0.001) Test whether each of the points is within the given set of polygons. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBpoints\fP (\fIarray\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI] or \fP\fIsequence of array\-like\fP\fI[\fP\fIN\fP\fI]\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Coordinates of the points to be tested or groups of points to be tested together. .IP \(bu 2 \fBpolygons\fP (\fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- Polygons to be tested against. If this is an iterable, each element must be a \fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP, or an array\-like[N][2] of vertices of a polygon. .IP \(bu 2 \fBshort_circuit\fP (\fI{\(aqany\(aq\fP\fI, \fP\fI\(aqall\(aq}\fP) \-\- If \fIpoints\fP is a sequence of point groups, testing within each group will be short\-circuited if any of the points in the group is inside (\(aqany\(aq) or outside (\(aqall\(aq) the polygons. If \fIpoints\fP is simply a sequence of points, this parameter has no effect. .IP \(bu 2 \fBprecision\fP (\fIfloat\fP) \-\- Desired precision for rounding vertice coordinates. .UNINDENT .TP .B Returns \fBout\fP \-\- Tuple of booleans indicating if each of the points or point groups is inside the set of polygons. .TP .B Return type tuple .UNINDENT .UNINDENT .SS copy .INDENT 0.0 .TP .B gdspy.copy(obj, dx=0, dy=0) Create a copy of \fIobj\fP and translate it by (dx, dy). .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBobj\fP (\fItranslatable object\fP) \-\- Object to be copied. .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- Translated copy of original \fIobj\fP .TP .B Return type translatable object .UNINDENT Examples.sp .nf .ft C >>> rectangle = gdspy.Rectangle((0, 0), (10, 20)) >>> rectangle2 = gdspy.copy(rectangle, 2,0) >>> myCell.add(rectangle) >>> myCell.add(rectangle2) .ft P .fi .UNINDENT .SS GDSII Library .SS Cell .INDENT 0.0 .TP .B class gdspy.Cell(name, exclude_from_current=False) Bases: \fBobject\fP .sp Collection of polygons, paths, labels and raferences to other cells. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- The name of the cell. .IP \(bu 2 \fBexclude_from_current\fP (\fIbool\fP) \-\- If True, the cell will not be automatically included in the current library. .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- The name of this cell. .IP \(bu 2 \fBpolygons\fP (list of \fIPolygonSet\fP) \-\- List of cell polygons. .IP \(bu 2 \fBpaths\fP (list of \fIRobustPath\fP or \fIFlexPath\fP) \-\- List of cell paths. .IP \(bu 2 \fBlabels\fP (list of \fILabel\fP) \-\- List of cell labels. .IP \(bu 2 \fBreferences\fP (list of \fICellReference\fP or \fICellArray\fP) \-\- List of cell references. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier, timestamp=None) Convert this cell to a GDSII structure. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII structure. .IP \(bu 2 \fBtimestamp\fP (\fIdatetime object\fP) \-\- Sets the GDSII timestamp. If None, the current time is used. .UNINDENT .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this cell. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B copy(name, exclude_from_current=False, deep_copy=False) Creates a copy of this cell. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- The name of the cell. .IP \(bu 2 \fBexclude_from_current\fP (\fIbool\fP) \-\- If True, the cell will not be included in the global list of cells maintained by \fIgdspy\fP\&. .IP \(bu 2 \fBdeep_copy\fP (\fIbool\fP) \-\- If False, the new cell will contain only references to the existing elements. If True, copies of all elements are also created. .UNINDENT .TP .B Returns \fBout\fP \-\- The new copy of this cell. .TP .B Return type \fICell\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add(element) Add a new element or list of elements to this cell. .INDENT 7.0 .TP .B Parameters \fBelement\fP (\fIPolygonSet\fP, \fICellReference\fP, \fICellArray\fP or iterable) \-\- The element or iterable of elements to be inserted in this cell. .TP .B Returns \fBout\fP \-\- This cell. .TP .B Return type \fICell\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B remove_polygons(test) Remove polygons from this cell. .sp The function or callable \fItest\fP is called for each polygon in the cell. If its return value evaluates to True, the corresponding polygon is removed from the cell. .INDENT 7.0 .TP .B Parameters \fBtest\fP (\fIcallable\fP) \-\- Test function to query whether a polygon should be removed. The function is called with arguments: \fB(points, layer, datatype)\fP .TP .B Returns \fBout\fP \-\- This cell. .TP .B Return type \fICell\fP .UNINDENT Examples .sp Remove polygons in layer 1: .sp .nf .ft C >>> cell.remove_polygons(lambda pts, layer, datatype: \&... layer == 1) .ft P .fi .sp Remove polygons with negative x coordinates: .sp .nf .ft C >>> cell.remove_polygons(lambda pts, layer, datatype: \&... any(pts[:, 0] < 0)) .ft P .fi .UNINDENT .INDENT 7.0 .TP .B remove_paths(test) Remove paths from this cell. .sp The function or callable \fItest\fP is called for each \fIFlexPath\fP or \fIRobustPath\fP in the cell. If its return value evaluates to True, the corresponding label is removed from the cell. .INDENT 7.0 .TP .B Parameters \fBtest\fP (\fIcallable\fP) \-\- Test function to query whether a path should be removed. The function is called with the path as the only argument. .TP .B Returns \fBout\fP \-\- This cell. .TP .B Return type \fICell\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B remove_labels(test) Remove labels from this cell. .sp The function or callable \fItest\fP is called for each label in the cell. If its return value evaluates to True, the corresponding label is removed from the cell. .INDENT 7.0 .TP .B Parameters \fBtest\fP (\fIcallable\fP) \-\- Test function to query whether a label should be removed. The function is called with the label as the only argument. .TP .B Returns \fBout\fP \-\- This cell. .TP .B Return type \fICell\fP .UNINDENT Examples .sp Remove labels in layer 1: .sp .nf .ft C >>> cell.remove_labels(lambda lbl: lbl.layer == 1) .ft P .fi .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of the elements on this cell, including cell references and arrays. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the areas of each individual pair (layer, datatype). .TP .B Returns \fBout\fP \-\- Area of this cell. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_layers() Return the set of layers in this cell. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Set of the layers used in this cell. .TP .B Return type set .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_datatypes() Return the set of datatypes in this cell. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Set of the datatypes used in this cell. .TP .B Return type set .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box for this cell. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygons(by_spec=False, depth=None) Return a list of polygons in this cell. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the polygons of each individual pair (layer, datatype). .IP \(bu 2 \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If \fIby_spec\fP is True the key will be the name of this cell. .UNINDENT .TP .B Returns \fBout\fP \-\- List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if \fIby_spec\fP is True). .TP .B Return type list of array\-like[N][2] or dictionary .UNINDENT .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Instances of \fIFlexPath\fP and \fIRobustPath\fP are also included in the result by computing their polygonal boundary. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygonsets(depth=None) Return a list with a copy of the polygons in this cell. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons from. .TP .B Returns \fBout\fP \-\- List containing the polygons in this cell and its references. .TP .B Return type list of \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_paths(depth=None) Return a list with a copy of the paths in this cell. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve paths from. .TP .B Returns \fBout\fP \-\- List containing the paths in this cell and its references. .TP .B Return type list of \fIFlexPath\fP or \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_labels(depth=None) Return a list with a copy of the labels in this cell. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve labels from. .TP .B Returns \fBout\fP \-\- List containing the labels in this cell and its references. .TP .B Return type list of \fILabel\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_dependencies(recursive=False) Return a list of the cells included in this cell as references. .INDENT 7.0 .TP .B Parameters \fBrecursive\fP (\fIbool\fP) \-\- If True returns cascading dependencies. .TP .B Returns \fBout\fP \-\- List of the cells referenced by this cell. .TP .B Return type set of \fICell\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B flatten(single_layer=None, single_datatype=None, single_texttype=None) Convert all references into polygons, paths and labels. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBsingle_layer\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, all polygons will be transferred to the layer indicated by this number. .IP \(bu 2 \fBsingle_datatype\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, all polygons will be transferred to the datatype indicated by this number. .IP \(bu 2 \fBsingle_datatype\fP \-\- If not None, all labels will be transferred to the texttype indicated by this number. .UNINDENT .TP .B Returns \fBout\fP \-\- This cell. .TP .B Return type \fICell\fP .UNINDENT .UNINDENT .UNINDENT .SS CellReference .INDENT 0.0 .TP .B class gdspy.CellReference(ref_cell, origin=(0, 0), rotation=None, magnification=None, x_reflection=False, ignore_missing=False) Bases: \fBobject\fP .sp Simple reference to an existing cell. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBref_cell\fP (\fICell\fP or string) \-\- The referenced cell or its name. .IP \(bu 2 \fBorigin\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Position where the reference is inserted. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Angle of rotation of the reference (in \fIdegrees\fP). .IP \(bu 2 \fBmagnification\fP (\fInumber\fP) \-\- Magnification factor for the reference. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- If True the reference is reflected parallel to the x direction before being rotated. .IP \(bu 2 \fBignore_missing\fP (\fIbool\fP) \-\- If False a warning is issued when the referenced cell is not found. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a GDSII element. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII element. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of the referenced cell with the magnification factor included. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the areas of each individual pair (layer, datatype). .TP .B Returns \fBout\fP \-\- Area of this cell. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygons(by_spec=False, depth=None) Return the list of polygons created by this reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the polygons of each individual pair (layer, datatype). .IP \(bu 2 \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If \fIby_spec\fP is True the key will be the name of the referenced cell. .UNINDENT .TP .B Returns \fBout\fP \-\- List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if \fIby_spec\fP is True). .TP .B Return type list of array\-like[N][2] or dictionary .UNINDENT .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Instances of \fIFlexPath\fP and \fIRobustPath\fP are also included in the result by computing their polygonal boundary. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygonsets(depth=None) Return the list of polygons created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons from. .TP .B Returns \fBout\fP \-\- List containing the polygons in this cell and its references. .TP .B Return type list of \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_paths(depth=None) Return the list of paths created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve paths from. .TP .B Returns \fBout\fP \-\- List containing the paths in this cell and its references. .TP .B Return type list of \fIFlexPath\fP or \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_labels(depth=None) Return the list of labels created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve labels from. .TP .B Returns \fBout\fP \-\- List containing the labels in this cell and its references. .TP .B Return type list of \fILabel\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box for this reference. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fICellReference\fP .UNINDENT .UNINDENT .UNINDENT .SS CellArray .INDENT 0.0 .TP .B class gdspy.CellArray(ref_cell, columns, rows, spacing, origin=(0, 0), rotation=None, magnification=None, x_reflection=False, ignore_missing=False) Bases: \fBobject\fP .sp Multiple references to an existing cell in an array format. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBref_cell\fP (\fICell\fP or string) \-\- The referenced cell or its name. .IP \(bu 2 \fBcolumns\fP (\fIpositive integer\fP) \-\- Number of columns in the array. .IP \(bu 2 \fBrows\fP (\fIpositive integer\fP) \-\- Number of columns in the array. .IP \(bu 2 \fBspacing\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- distances between adjacent columns and adjacent rows. .IP \(bu 2 \fBorigin\fP (\fIarray\-like\fP\fI[\fP\fI2\fP\fI]\fP) \-\- Position where the cell is inserted. .IP \(bu 2 \fBrotation\fP (\fInumber\fP) \-\- Angle of rotation of the reference (in \fIdegrees\fP). .IP \(bu 2 \fBmagnification\fP (\fInumber\fP) \-\- Magnification factor for the reference. .IP \(bu 2 \fBx_reflection\fP (\fIbool\fP) \-\- If True, the reference is reflected parallel to the x direction before being rotated. .IP \(bu 2 \fBignore_missing\fP (\fIbool\fP) \-\- If False a warning is issued when the referenced cell is not found. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B to_gds(multiplier) Convert this object to a GDSII element. .INDENT 7.0 .TP .B Parameters \fBmultiplier\fP (\fInumber\fP) \-\- A number that multiplies all dimensions written in the GDSII element. .TP .B Returns \fBout\fP \-\- The GDSII binary string that represents this object. .TP .B Return type string .UNINDENT .UNINDENT .INDENT 7.0 .TP .B area(by_spec=False) Calculate the total area of the cell array with the magnification factor included. .INDENT 7.0 .TP .B Parameters \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the areas of each individual pair (layer, datatype). .TP .B Returns \fBout\fP \-\- Area of this cell. .TP .B Return type number, dictionary .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygons(by_spec=False, depth=None) Return the list of polygons created by this reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBby_spec\fP (\fIbool\fP) \-\- If True, the return value is a dictionary with the polygons of each individual pair (layer, datatype). .IP \(bu 2 \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons. References below this level will result in a bounding box. If \fIby_spec\fP is True the key will be name of the referenced cell. .UNINDENT .TP .B Returns \fBout\fP \-\- List containing the coordinates of the vertices of each polygon, or dictionary with the list of polygons (if \fIby_spec\fP is True). .TP .B Return type list of array\-like[N][2] or dictionary .UNINDENT .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 Instances of \fIFlexPath\fP and \fIRobustPath\fP are also included in the result by computing their polygonal boundary. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_polygonsets(depth=None) Return the list of polygons created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve polygons from. .TP .B Returns \fBout\fP \-\- List containing the polygons in this cell and its references. .TP .B Return type list of \fIPolygonSet\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_paths(depth=None) Return the list of paths created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve paths from. .TP .B Returns \fBout\fP \-\- List containing the paths in this cell and its references. .TP .B Return type list of \fIFlexPath\fP or \fIRobustPath\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_labels(depth=None) Return the list of labels created by this reference. .INDENT 7.0 .TP .B Parameters \fBdepth\fP (\fIinteger\fP\fI or \fP\fINone\fP) \-\- If not None, defines from how many reference levels to retrieve labels from. .TP .B Returns \fBout\fP \-\- List containing the labels in this cell and its references. .TP .B Return type list of \fILabel\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B get_bounding_box() Calculate the bounding box for this reference. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty. .TP .B Return type Numpy array[2, 2] or None .UNINDENT .UNINDENT .INDENT 7.0 .TP .B translate(dx, dy) Translate this reference. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBdx\fP (\fInumber\fP) \-\- Distance to move in the x\-direction. .IP \(bu 2 \fBdy\fP (\fInumber\fP) \-\- Distance to move in the y\-direction. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fICellArray\fP .UNINDENT .UNINDENT .UNINDENT .SS GdsLibrary .INDENT 0.0 .TP .B class gdspy.GdsLibrary(name=\(aqlibrary\(aq, infile=None, unit=1e\-06, precision=1e\-09, **kwargs) Bases: \fBobject\fP .sp GDSII library (file). .sp Represent a GDSII library containing a dictionary of cells. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- Name of the GDSII library. Ignored if a name is defined in \fIinfile\fP\&. .IP \(bu 2 \fBinfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- GDSII stream file (or path) to be imported. It must be opened for reading in binary format. .IP \(bu 2 \fBkwargs\fP (\fIkeyword arguments\fP) \-\- Arguments passed to \fIread_gds\fP\&. .UNINDENT .TP .B Variables .INDENT 7.0 .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- Name of the GDSII library. .IP \(bu 2 \fBcell_dict\fP (\fIdictionary\fP) \-\- Dictionary of cells in this library, indexed by name. .IP \(bu 2 \fBunit\fP (\fInumber\fP) \-\- Unit size for the objects in the library (in \fImeters\fP). .IP \(bu 2 \fBprecision\fP (\fInumber\fP) \-\- Precision for the dimensions of the objects in the library (in \fImeters\fP). .UNINDENT .UNINDENT .INDENT 7.0 .TP .B add(cell, overwrite_duplicate=False) Add one or more cells to the library. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcell\fP (\fICell\fP or iterable) \-\- Cells to be included in the library. .IP \(bu 2 \fBoverwrite_duplicate\fP (\fIbool\fP) \-\- If True an existing cell with the same name in the library will be overwritten. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIGdsLibrary\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp \fICellReference\fP or \fICellArray\fP instances that referred to an overwritten cell are not automatically updated. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B write_gds(outfile, cells=None, timestamp=None, binary_cells=None) Write the GDSII library to a file. .sp The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio unit/precision. For example, if a circle with radius 1.5 is created and we set \fIGdsLibrary.unit\fP to 1.0e\-6 (1 um) and \fIGdsLibrary.precision\fP to 1.0e\-9\(ga (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoutfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. .IP \(bu 2 \fBcells\fP (\fIiterable\fP) \-\- The cells or cell names to be included in the library. If None, all cells are used. .IP \(bu 2 \fBtimestamp\fP (\fIdatetime object\fP) \-\- Sets the GDSII timestamp. If None, the current time is used. .IP \(bu 2 \fBbinary_cells\fP (\fIiterable of bytes\fP) \-\- Iterable with binary data for GDSII cells (from \fIget_binary_cells\fP, for example). .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Only the specified cells are written. The user is responsible for ensuring all cell dependencies are satisfied. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B read_gds(infile, units=\(aqskip\(aq, rename={}, rename_template=\(aq{name}\(aq, layers={}, datatypes={}, texttypes={}) Read a GDSII file into this library. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBinfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- GDSII stream file (or path) to be imported. It must be opened for reading in binary format. .IP \(bu 2 \fBunits\fP (\fI{\(aqconvert\(aq\fP\fI, \fP\fI\(aqimport\(aq\fP\fI, \fP\fI\(aqskip\(aq}\fP) \-\- Controls how to scale and use the units in the imported file. \(aqconvert\(aq: the imported geometry is scaled to this library units. \(aqimport\(aq: the unit and precision in this library are replaced by those from the imported file. \(aqskip\(aq: the imported geometry is not scaled and units are not replaced; the geometry is imported in the \fIuser units\fP of the file. .IP \(bu 2 \fBrename\fP (\fIdictionary\fP) \-\- Dictionary used to rename the imported cells. Keys and values must be strings. .IP \(bu 2 \fBrename_template\fP (\fIstring\fP) \-\- Template string used to rename the imported cells. Appiled only if the cell name is not in the \fIrename\fP dictionary. Examples: \(aqprefix\-{name}\(aq, \(aq{name}\-suffix\(aq .IP \(bu 2 \fBlayers\fP (\fIdictionary\fP) \-\- Dictionary used to convert the layers in the imported cells. Keys and values must be integers. .IP \(bu 2 \fBdatatypes\fP (\fIdictionary\fP) \-\- Dictionary used to convert the datatypes in the imported cells. Keys and values must be integers. .IP \(bu 2 \fBtexttypes\fP (\fIdictionary\fP) \-\- Dictionary used to convert the text types in the imported cells. Keys and values must be integers. .UNINDENT .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIGdsLibrary\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Not all features from the GDSII specification are currently supported. A warning will be produced if any unsupported features are found in the imported file. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B extract(cell, overwrite_duplicate=False) Extract a cell from the this GDSII file and include it in the current global library, including referenced dependencies. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcell\fP (\fICell\fP or string) \-\- Cell or name of the cell to be extracted from the imported file. Referenced cells will be automatically extracted as well. .IP \(bu 2 \fBoverwrite_duplicate\fP (\fIbool\fP) \-\- If True an existing cell with the same name in the current global library will be overwritten. .UNINDENT .TP .B Returns \fBout\fP \-\- The extracted cell. .TP .B Return type \fICell\fP .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp \fICellReference\fP or \fICellArray\fP instances that referred to an overwritten cell are not automatically updated. .UNINDENT .UNINDENT .UNINDENT .INDENT 7.0 .TP .B top_level() Output the top level cells from the GDSII data. .sp Top level cells are those that are not referenced by any other cells. .INDENT 7.0 .TP .B Returns \fBout\fP \-\- List of top level cells. .TP .B Return type list .UNINDENT .UNINDENT .UNINDENT .SS GdsWriter .INDENT 0.0 .TP .B class gdspy.GdsWriter(outfile, name=\(aqlibrary\(aq, unit=1e\-06, precision=1e\-09, timestamp=None) Bases: \fBobject\fP .sp GDSII strem library writer. .sp The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio unit/precision. For example, if a circle with radius 1.5 is created and we set \fIunit\fP to 1.0e\-6 (1 um) and \fIprecision\fP to 1.0e\-9 (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoutfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- Name of the GDSII library (file). .IP \(bu 2 \fBunit\fP (\fInumber\fP) \-\- Unit size for the objects in the library (in \fImeters\fP). .IP \(bu 2 \fBprecision\fP (\fInumber\fP) \-\- Precision for the dimensions of the objects in the library (in \fImeters\fP). .IP \(bu 2 \fBtimestamp\fP (\fIdatetime object\fP) \-\- Sets the GDSII timestamp. If None, the current time is used. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp This class can be used for incremental output of the geometry in case the complete layout is too large to be kept in memory all at once. .UNINDENT .UNINDENT Examples.sp .nf .ft C >>> writer = gdspy.GdsWriter(\(aqout\-file.gds\(aq, unit=1.0e\-6, \&... precision=1.0e\-9) >>> for i in range(10): \&... cell = gdspy.Cell(\(aqC{}\(aq.format(i), True) \&... # Add the contents of this cell... \&... writer.write_cell(cell) \&... # Clear the memory: erase Cell objects and any other objects \&... # that won\(aqt be needed. \&... del cell >>> writer.close() .ft P .fi .INDENT 7.0 .TP .B write_cell(cell, timestamp=None) Write the specified cell to the file. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBcell\fP (\fICell\fP) \-\- Cell to be written. .IP \(bu 2 \fBtimestamp\fP (\fIdatetime object\fP) \-\- Sets the GDSII timestamp. If None, the current time is used. .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp Only the specified cell is written. Dependencies must be manually included. .UNINDENT .UNINDENT .INDENT 7.0 .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIGdsWriter\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B write_binary_cells(binary_cells) Write the specified binary cells to the file. .INDENT 7.0 .TP .B Parameters \fBbinary_cells\fP (\fIiterable of bytes\fP) \-\- Iterable with binary data for GDSII cells (from \fIget_binary_cells\fP, for example). .TP .B Returns \fBout\fP \-\- This object. .TP .B Return type \fIGdsWriter\fP .UNINDENT .UNINDENT .INDENT 7.0 .TP .B close() Finalize the GDSII stream library. .UNINDENT .UNINDENT .SS LayoutViewer .SS write_gds .INDENT 0.0 .TP .B gdspy.write_gds(outfile, cells=None, name=\(aqlibrary\(aq, unit=1e\-06, precision=1e\-09, timestamp=None, binary_cells=None) Write the current GDSII library to a file. .sp The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio unit/precision. For example, if a circle with radius 1.5 is created and we set \fIunit\fP to 1.0e\-6 (1 um) and \fIprecision\fP to 1.0e\-9 (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBoutfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format. .IP \(bu 2 \fBcells\fP (\fIarray\-like\fP) \-\- The sequence of cells or cell names to be included in the library. If None, all cells are used. .IP \(bu 2 \fBname\fP (\fIstring\fP) \-\- Name of the GDSII library. .IP \(bu 2 \fBunit\fP (\fInumber\fP) \-\- Unit size for the objects in the library (in \fImeters\fP). .IP \(bu 2 \fBprecision\fP (\fInumber\fP) \-\- Precision for the dimensions of the objects in the library (in \fImeters\fP). .IP \(bu 2 \fBtimestamp\fP (\fIdatetime object\fP) \-\- Sets the GDSII timestamp. If None, the current time is used. .IP \(bu 2 \fBbinary_cells\fP (\fIiterable of bytes\fP) \-\- Iterable with binary data for GDSII cells (from \fIget_binary_cells\fP, for example). .UNINDENT .UNINDENT .UNINDENT .SS gdsii_hash .INDENT 0.0 .TP .B gdspy.gdsii_hash(filename, engine=None) Calculate the a hash value for a GDSII file. .sp The hash is generated based only on the contents of the cells in the GDSII library, ignoring any timestamp records present in the file structure. .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBfilename\fP (\fIstring\fP) \-\- Full path to the GDSII file. .IP \(bu 2 \fBengine\fP (\fIhashlib\-like engine\fP) \-\- The engine that executes the hashing algorithm. It must provide the methods \fIupdate\fP and \fIhexdigest\fP as defined in the hashlib module. If None, the default \fIhashlib.sha1()\fP is used. .UNINDENT .TP .B Returns \fBout\fP \-\- The hash corresponding to the library contents in hex format. .TP .B Return type string .UNINDENT .UNINDENT .SS get_binary_cells .INDENT 0.0 .TP .B gdspy.get_binary_cells(infile) Load all cells from a GDSII stream file in binary format. .INDENT 7.0 .TP .B Parameters \fBinfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- GDSII stream file (or path) to be loaded. It must be opened for reading in binary format. .TP .B Returns \fBout\fP \-\- Dictionary of binary cell representations indexed by name. .TP .B Return type dictionary .UNINDENT .INDENT 7.0 .INDENT 3.5 .IP "Notes" .sp The returned cells inherit the units of the loaded file. If they are used in a new library, the new library must use compatible units. .UNINDENT .UNINDENT .UNINDENT .SS get_gds_units .INDENT 0.0 .TP .B gdspy.get_gds_units(infile) Return the unit and precision used in the GDS stream file. .INDENT 7.0 .TP .B Parameters \fBinfile\fP (\fIfile\fP\fI or \fP\fIstring\fP) \-\- GDSII stream file to be queried. .TP .B Returns \fBout\fP \-\- Return \fB(unit, precision)\fP from the file. .TP .B Return type 2\-tuple .UNINDENT .UNINDENT .SS current_library .INDENT 0.0 .TP .B gdspy.current_library = Current \fIGdsLibrary\fP instance for automatic creation of GDSII files. .sp This variable can be freely overwritten by the user with a new instance of \fIGdsLibrary\fP\&. Examples.sp .nf .ft C >>> gdspy.Cell(\(aqMAIN\(aq) >>> gdspy.current_library = GdsLibrary() # Reset current library >>> gdspy.Cell(\(aqMAIN\(aq) # A new MAIN cell is created without error .ft P .fi .UNINDENT .SH SUPPORT .sp Help support the development of gdspy by donating: .sp \fI\%Click here\fP .SH AUTHOR Lucas H. Gabrielli .SH COPYRIGHT 2009-2020, Lucas H. Gabrielli .\" Generated by docutils manpage writer. .