Exemple #1
0
def test_arc():
    D = pg.arc(radius=10,
               width=0.5,
               theta=45,
               start_angle=0,
               angle_resolution=2.5,
               layer=0)
    h = D.hash_geometry(precision=1e-4)
    assert (h == 'a273d16c6c7daf4f80fcdfdd82514be2484d6349')
E1.add_polygon([[10, 20, 35], [1, 60, 40]], layer=3)
qp(D_deepcopied)

#==============================================================================
# Extracting layers
#==============================================================================
# Say you want to grab all the polygons of a single layer from your Device. You
# can do this using the pg.extract() function, which will create a new Device
# with all of the polygons from D.  Note that the Device created from this
# function is necessarily flattened (otherwise it could inadvertantly modify
# other Devices which share references with the extracted Device)

D = Device()
E1 = pg.ellipse(layer=1)
E2 = pg.rectangle(layer=2)
E3 = pg.arc(layer=3)
D.add_ref(E1)
D.add_ref(E2).movex(15)
D.add_ref(E3).movex(30)
qp(D)

D_only_layers_1_and_2 = pg.extract(D, layers=[1, 2])
qp(D_only_layers_1_and_2)

#==============================================================================
# Making boolean shapes
#==============================================================================
# If you want to subtract one shape from another, merge two shapes, or
# perform an XOR on them, you can do that with the pg.boolean() function.
# the ``operation`` argument should be {not, and, or, xor, 'A-B', 'B-A', 'A+B'}.
# Note that 'A+B' is equivalent to 'or', 'A-B' is equivalent to 'not', and
Exemple #3
0
# example-rectangle
import phidl.geometry as pg
from phidl import quickplot as qp

D = pg.rectangle(size = (4.5, 2), layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'rectangle')


# example-bbox
import phidl.geometry as pg
from phidl import quickplot as qp
from phidl import Device

D = Device()
arc = D << pg.arc(radius = 10, width = 0.5, theta = 85, layer = 1).rotate(25)
 # Draw a rectangle around the arc we created by using the arc's bounding box
rect = D << pg.bbox(bbox = arc.bbox, layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'bbox')

# example-cross
import phidl.geometry as pg
from phidl import quickplot as qp

D = pg.cross(length = 10, width = 0.5, layer = 0)
qp(D) # quickplot the geometry
create_image(D, 'cross')

# example-ellipse
import phidl.geometry as pg