FLayout core factories yielding native klayout datastructures.

Shape

 

layer[source]

layer(lr:int, dt:int, name:str='')

layer(19, 0)
<klayout.dbcore.LayerInfo at 0x7f03a6dc0f70>

point[source]

point(x:Union[float, int], y:Union[float, int])

create a KLayout DPoint

Args:
    x: the x-value of the point
    y: the y-value of the point

Returns:
    the point
my_point = point(3, 5)
my_point
Bokeh Application

vector[source]

vector(x:Union[float, int], y:Union[float, int])

create a KLayout DVector

Args:
    x: the x-value of the vector
    y: the y-value of the vector

Returns:
    the vector
my_vector = vector(3, 5)
my_vector
Bokeh Application

box[source]

box(p1:Union[Point, DPoint], p2:Union[Point, DPoint])

my_box = box((0, 0), (5, 10))
my_box
Bokeh Application

polygon[source]

polygon(hull:Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')], holes:Optional[List[typing.Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')]]]=None, raw:bool=False)

create a KLayout polygon

Args:
    hull: the points that make the polygon hull
    holes: the collection of points that make the polygon holes
    raw: if true, the points won't be compressed.

Returns:
    the polygon

polygon[source]

polygon(hull:Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')], holes:Optional[List[typing.Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')]]]=None, raw:bool=False)

create a KLayout polygon

Args:
    hull: the points that make the polygon hull
    holes: the collection of points that make the polygon holes
    raw: if true, the points won't be compressed.

Returns:
    the polygon

polygon[source]

polygon(hull:Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')], holes:Optional[List[typing.Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')]]]=None, raw:bool=False)

create a KLayout polygon

Args:
    hull: the points that make the polygon hull
    holes: the collection of points that make the polygon holes
    raw: if true, the points won't be compressed.

Returns:
    the polygon

A simple polygon is a polygon without holes. You can create this by using fl.polygon and only specifying a hull.

my_simple_poly = polygon(
    hull=[(0, -2), (5, -2), (1, 2)],
)
my_simple_poly
Bokeh Application

General Polygons (with holes) can be specified by also specifying a holes keyword in fl.polygon:

my_poly = polygon(
    hull=[(0, 0), (6, 0), (6, 4), (0, 3)],
    holes=[[(3, 1), (4, 1), (4, 2), (3, 2)]]
)
my_poly
Bokeh Application

path[source]

path(pts:Union[typing.List[typing.Union[klayout.dbcore.DPoint, typing.Tuple[int, int], typing.Tuple[float, float], ForwardRef('np.ndarray')]], ForwardRef('np.ndarray')], width:float, bgn_ext:float=0.0, end_ext:float=0.0, round:bool=False)

create a KLayout path

Args:
    pts: the points that make the path
    width: the width of the path
    bgn_ext: the begin extension of the path
    end_ext: the end extension of the path
    round: round the ends of the path

Returns:
    the path
my_path = path([(3.0, 4.0), (6.0, -1.0)], 1.2)
my_path
[<klayout.dbcore.DPoint object at 0x7f03a6d4a430>, <klayout.dbcore.DPoint object at 0x7f03a6d4aaf0>]
Bokeh Application

cell[source]

cell(name:str, shapes:Optional[Dict[LayerInfo, typing.Union[klayout.dbcore.DBox, klayout.dbcore.DSimplePolygon, klayout.dbcore.DPolygon, klayout.dbcore.DPath, klayout.dbcore.Box, klayout.dbcore.SimplePolygon, klayout.dbcore.Polygon, klayout.dbcore.Path]]]=None, child_cells:Optional[List[typing.Union[klayout.dbcore.Cell, typing.Tuple[klayout.dbcore.Cell, klayout.dbcore.CplxTrans]]]]=None)

create a KLayout cell

Args:
    name: the name of the cell
    shapes: the shapes to add to the cell
    child_cells: the child cells to add to the cell

Returns:
    the cell
my_cell = cell(
    name="cell0", 
    shapes={
        (10, 0): [my_simple_poly, my_poly],
        (19, 0): [my_path],
    },
)
my_cell
Bokeh Application

Child cells can also be added to a cell:

my_other_poly = polygon([(10, 0), (11, 0), (11, 0), (10, 5)])
my_other_cell = cell(
    name="cell1", 
    shapes={(0, 0): [my_other_poly]},
    child_cells=[my_cell],
)
my_other_cell
Bokeh Application

transform[source]

transform(mag:float=1.0, rot:float=0.0, mirrx:bool=False, x:float=0.0, y:float=0.0)

create a KLayout Transformation

Args:
    mag: the magnitude of the transformation
    rot: the rotation of the transformation
    mirrx: mirror over the x-axis (x=0 line).
    x: translation distance in the x-direction
    y: translation distance in the y-direction

Returns:
    the cell reference

One can apply transformations to the child cell as well:

my_third_poly = polygon([(0, 0), (6, 0), (6, 4), (0, 5)])
my_third_cell = cell(
    name="cell2", 
    shapes={(0, 0): [my_third_poly]},
    child_cells=[
        (my_other_cell, transform(mirrx=True, x=12.0, y=3.0)),
    ],
)
my_third_cell
Bokeh Application

The combination of a child cell and a transformation is called an instance of a cell (sometimes also called a reference):

inst = next(my_third_cell.each_inst()) # get the only instance
inst
Bokeh Application

layout[source]

layout(cells:Optional[List[Cell]]=None)

create a KLayout Layout

Args:
    cells: the cells to add to the layout

Returns:
    the KLayout layout

Finally, a layout is a collection of multiple cells. If a cell is not a sub cell of another cell, it will be considered a top-level cell. Moreover, one cannot have cyclic references within a layout.

Let's create a layout with two top-level cells:

my_independent_cell = cell(
    name='independent_cell',
    shapes={(19, 0): [polygon([(6, 0), (10, -2), (10, 0)])]}
)
    
# even though we specify four cells for our layout, only two of them are independent
# i.e. some of the cells we are added are actually child cells of other cells
# top level cells in this case are 'my_independent_cell' and 'my_third_cell'
my_layout = layout(cells=[my_independent_cell, my_cell, my_other_cell, my_third_cell])
# my_layout = layout(cells=[my_independent_cell, my_third_cell]) # equivalent

my_layout
Bokeh Application

library[source]

library(name:str, cells:Optional[List[Cell]]=None, pcells:Optional[List[Cell]]=None, description:str='')

create a KLayout Library

Args:
    name: the name of the library
    cells: the cells to add to the library
    pcells: the pcells to add to the library

Returns:
    the KLayout library