Example #1
0
# Let's make a new blank device DL and add some text to it, but this time on
# different layers
DL = Device()

# You can specify any layer in one of three ways:
# 1) as a single number 0-255 representing the gds layer number, e.g. layer = 1
# where the gds layer datatype will be automatically set to zero
DL.add_ref(pg.text('Layer1', size=10, layer=1))

# 2) as a 2-element list [0,1] or tuple (0,1) representing the gds layer
# number (0-255) and gds layer datatype (0-255)
DL.add_ref(pg.text('Layer2', size=10, layer=[2, 5])).movey(-20)

# 3) as a Layer object
gold = Layer(name='goldpads',
             gds_layer=3,
             gds_datatype=0,
             description='Gold pads liftoff')
DL.add_ref(pg.text('Layer3', size=10, layer=gold)).movey(-40)

# What you can also do is make a dictionary of layers, which lets you
# conveniently call each Layer object just by its name.  You can also specify
# the layer color using an RGB triplet e.g (0.1, 0.4, 0.2), an HTML hex color
# (e.g. #a31df4), or a CSS3 color name (e.g. 'gold' or 'lightblue'
# see http://www.w3schools.com/colors/colors_names.asp )
# The 'alpha' argument also lets you specify how transparent that layer should
# look when using quickplot (has no effect on the written GDS file)
layers = {
    'titanium':
    Layer(gds_layer=4,
          gds_datatype=0,
          description='Titanium resistor',
# Let's make a new blank device DL and add some text to it, but this time on
# different layers
DL = Device()

# You can specify any layer in one of three ways:
# 1) as a single number 0-255 representing the gds layer number, e.g. layer = 1
# where the gds layer datatype will be automatically set to zero
DL.add_ref(pg.text('Layer1', size=10, layer=1))

# 2) as a 2-element list [0,1] or tuple (0,1) representing the gds layer
# number (0-255) and gds layer datatype (0-255)
DL.add_ref(pg.text('Layer2', size=10, layer=[2, 5])).movey(-20)

# 3) as a Layer object
my_gold_layer = Layer(gds_layer=3,
                      gds_datatype=0,
                      name='goldpads',
                      description='Gold pads liftoff')
my_unused_layer = Layer(240,
                        1)  # Creates a Layer for GDS layer 240 (dataype 1)
DL.add_ref(pg.text('Layer3', size=10, layer=my_gold_layer)).movey(-40)

#==============================================================================
# Advanced layers: Generating geometry on multiple layers at once
#==============================================================================
# Say we want to create the same ellipse on several different layers.  We can
# do that by using a Python `set` of layers.  So if we want to add it to three
# layers, say GDS layer 1 datatype 0, GDS layer 3 datatype 5, and GDS layer 7
# datatype 8:

# Note each element of the set must be a valid layer input by itself
my_layers = {1, (3, 5), (7, 8)}
Example #3
0
from phidl import Device, Layer, geometry as pg

some_layer = Layer(1)


def some_device(width=10, height=20):
    D = Device('somedevice')
    r1 = D << pg.rectangle((width, height), layer=some_layer)
    r2 = D << pg.circle(radius=width, layer=some_layer)
    r2.movex(30)
    return D