Пример #1
0
def boundingDiamond(wid=50, inner=1500, owid=250, outer=2250, left="Left", right="Right", center="Center", centeru="?"):
    print "boundingDiamond"
    toReturn = Shape([])
    
    v = Vector(1,1)
    w = Vector(1,-1)
    
    oo = outer/2.
    oi = (outer - owid)/2.
    
#    print outer, wid, outer-wid
#    print oo, oi

    m = (Matrix(1, -1, 1, 1)/math.sqrt(2))

    rect1 = Polyline([v*oo, w*oo, -v*oo, -w*oo, v*oo, v*oi, -w*oi, -v*oi, w*oi, v*oi], True, False, 3)*m;
    
    oo = inner/2.
    oi = (inner - wid)/2.
    rect2 = Polyline([v*oo, w*oo, -v*oo, -w*oo, v*oo, v*oi, -w*oi, -v*oi, w*oi, v*oi], True, False, 3)

    toReturn.add(rect(Vector(-inner/2, -inner/3), Vector(-inner/2 + wid, inner/3)).setMaterial(3))
    toReturn.add(rect(Vector(inner/2, -inner/3), Vector(inner/2 - wid, inner/3)).setMaterial(3))
    if centeru[0] != '?':
        toReturn.add(rect(Vector(-inner/3, inner/2-wid), Vector(inner/3, inner/2)).setMaterial(3))
    toReturn.add(rect(Vector(-inner/3, -inner/2+wid), Vector(inner/3, -inner/2)).setMaterial(3))

#    rect1 = (rect(v*(-oi), v*oi)).add(rect(v*(-oo), v*oo))

#    print rect1

#    toReturn.add(rect(v*(-oi), v*oi));
#    toReturn.add(rect(v*(-oo), v*oo));

    toReturn.add(rect1.setMaterial(3))
#    toReturn.add(rect2)

    toReturn.add((font.shapeFromStringBoundedCentered(left, wid, -1) +      Vector(-inner/2. - inner/4. + 3*wid, 0)).setMaterial(3))
    toReturn.add((font.shapeFromStringBoundedCentered(center, wid, -1) +    Vector(0, -inner/2. - inner/4. + 4*wid)).setMaterial(3))
    toReturn.add((font.shapeFromStringBoundedCentered(right, wid, -1) +      Vector(inner/2. + inner/4. - 3*wid, 0)).setMaterial(3))
    if centeru[0] != '?' and centeru[0] != ' ':
        toReturn.add((font.shapeFromStringBoundedCentered(centeru, wid, -1) +    Vector(0, +inner/2. + inner/4. - 4*wid)).setMaterial(3))

    mark = alignmentMark(100).setMaterial(3)*m;
    
    mx = inner - 5*wid;
    
    toReturn.add(mark + Vector(0, mx));
    toReturn.add(mark + Vector(0, -mx));
    toReturn.add(mark + Vector(mx, 0));
    toReturn.add(mark + Vector(-mx, 0));
    
    return toReturn
Пример #2
0
def fontIntersectTest(string="T"):
    font1 = TTF("/Users/I/Desktop/Desktop/diamondGDS/fonts/courier-bold.ttf")
    rect2 = -rect(Vector(-100,-10), Vector(100,10));
    
    font2 = font1.shapeFromStringBoundedCentered(string, -1, 15)

    font2.intersect(-rect2).plot();
Пример #3
0
def starkChip(wire=10):
    boxdim = 200
    padsize = 100
    
#    membrane(boxdim).plot()

    toReturn = Shape([]);
    
    dev = dev2D()
    
    box = rect(Vector(0,0), Vector(1,1))
    
    for x in range(0, 4):
        for y in range(0,4):
            text = (font.shapeFromStringBoundedCentered(str(x+1) + str(y+1), -1, 7*5) + Vector(-85, 0)).setMaterial(3)
            text2 = (font.shapeFromStringBoundedCentered(str(x+1) + str(y+1), -1, 5) +   Vector(-35, 0)).setMaterial(1)
            toReturn.add(dev +      Vector(x-1.5, y-1.5)*boxdim*2);
            toReturn.add(text +     Vector(x-1.5, y-1.5)*boxdim*2);
            toReturn.add(text2 +    Vector(x-1.5, y-1.5)*boxdim*2 + Vector(0, 10));
            #toReturn.add(text2 +    Vector(x-1.5, y-1.5)*boxdim*2 + Vector(0, -10));

            for xx in range(0,4):
                for yy in range(0,4):
                    if not (xx == x and yy == y):
                        toReturn.add(box + Vector(2*(xx-2)-35+.5, 2*(yy-2)-10+.5) + Vector(x-1.5, y-1.5)*boxdim*2);


#    for x in range(0, 4):
#        toReturn.add(rect(Vector(0,0), Vector(padsize, padsize)) + Vector((x-2)*boxdim*2 + 40, boxdim*2*2));
#        toReturn.add(rect(Vector(0,0), Vector(padsize, padsize)) + Vector((x-1)*boxdim*2 - padsize, boxdim*2*2));

    return toReturn
Пример #4
0
def intersectionTest():
    c1 = -circle(Vector(0,0), 1)
    c2 = -circle(Vector(1,1), 1.5)
    c3 = -circle(Vector(0,0), .5)
    r1 = rect(Vector(-1,-1), Vector(1,1))
    
#    print c1.area()
#    print c2.area()
#    print c3.area()
#    
#    c1.plot()
#    c2.plot()
#    
#    (c1.union(c2) + Vector(4,0)).plot()
#    (c2.union(c1) + Vector(8,0)).plot()
#    (c1.union(-c2) + Vector(12,0)).plot()
#    (c2.union(-c1) + Vector(16,0)).plot()
#    (c3.intersect(c1) + Vector(20,0)).plot()
    (c3.intersect(r1)).plot()

#    print rect(Vector(3,3), Vector(6,6))
#    print rect(Vector(6,3), Vector(12,6))

#    (rect(Vector(3,3), Vector(6,6)).union(rect(Vector(6,3), Vector(12,6))) + Vector(12,0)).plot()
#    (rect(Vector(6,2), Vector(12,6)).union(rect(Vector(3,3), Vector(6,7))) + Vector(0,0)).plot()
    return None
Пример #5
0
 def __init__(self):
     super().__init__()
     self.model.add_obj(Line("noia", np.array([10, 10, 1]), np.array([100, 100, 1])))
     self.model.add_obj(rect("wee", np.array([10, 10, 1]), np.array([80, 80, 0])))
     self.model.add_obj(Point("kkk", 69, 69))
     self.model.add_obj(Bezier("weed", np.array([69, 89, 1]), np.array([99, 109, 1]), np.array([269, 190, 1]), np.array([270, 290, 1])))
     self.win_main: MainController = self.win_main
Пример #6
0
def grating(connection):
    wid = 1.5
    wid2 = 1.5/2
    
    base = Shape([thickenPolyline(Polyline([Vector(0,0), Vector(8,0)], False), "CUBIC", [connection.wid,wid])], [connection])
    
    grates = [.15, .26, .25, .145, .26, .16, .245, .105, .365]
    mB = [[.05, .26, .26, .26], [.1, .225, .22, .21], [.15, .185, .18, .175]]
    spacing = .05
    x = 8
    
    i = 0
    
    for grate in grates:
        if len(mB) > i:
            base.add(rect(Vector(x,        -mB[i][1]/2),
                          Vector(x+spacing, mB[i][1]/2)))
            base.add(rect(Vector(x,         mB[i][1]/2 + mB[i][0]),
                          Vector(x+spacing, mB[i][1]/2 + mB[i][0] + mB[i][2])))
            base.add(rect(Vector(x,         mB[i][1]/2 + mB[i][0] + mB[i][2] + mB[i][0]),
                          Vector(x+spacing, mB[i][1]/2 + mB[i][0] + mB[i][2] + mB[i][0] + mB[i][3])))
            base.add(rect(Vector(x,        -mB[i][1]/2 - mB[i][0] - mB[i][2]),
                          Vector(x+spacing,-mB[i][1]/2 - mB[i][0])))
            base.add(rect(Vector(x,        -mB[i][1]/2 - mB[i][0] - mB[i][2] - mB[i][0] - mB[i][3]),
                          Vector(x+spacing,-mB[i][1]/2 - mB[i][0] - mB[i][2] - mB[i][0])))
    
        i += 1
        x += spacing
        base.add(rect(Vector(x, -wid2), Vector(x+grate, wid2)))
        x += grate
    
    base *= connection.matrix()
    base.plot()

    return base
Пример #7
0
def membrane(boxdim=200, viawid=16, boxnum=7, viagap=75):
    toReturn = Shape([]);
    
    box = rect(Vector(-.5,-.5)*boxdim, Vector(.5,.5)*boxdim)
    
    line = Polyline([Vector(-(boxdim - viagap)/2., boxdim/2.), Vector((boxdim - viagap)/2., boxdim/2.)]);
    
    via = thickenPolyline(line, "LINEAR", viawid/2., "SHARP", "ROUND")
    
    box = box.intersect(via);
    box = box.intersect(via*Matrix(math.pi/2));
    box = box.intersect(via*Matrix(math.pi));
    box = box.intersect(via*Matrix(3*math.pi/2));
    
    #edge = box.intersect(rect(Vector(-boxdim, -boxdim/2.+viagap), Vector(boxdim, boxdim)))
    #r = rect(Vector(-boxdim, -boxdim/2.+viagap), Vector(boxdim, boxdim))
    #edge = box.intersect(r)
    
    for x in range(0, boxnum+2):
        for y in range(0, boxnum+2):
            if   x == 0           and y == 0:
                0
            elif x == boxnum+1    and y == 0:
                0
            elif x == 0           and y == boxnum+1:
                0
            elif x == boxnum+1    and y == boxnum+1:
                0
            elif x == 0:
                0 #toReturn.add(edge + Vector(x,y)*boxdim)
            elif x == boxnum+1:
                0 #toReturn.add(edge + Vector(x,y)*boxdim)
            elif y == 0:
                0 #toReturn.add(edge + Vector(x,y)*boxdim)
            elif y == boxnum+1:
                0 #toReturn.add(edge + Vector(x,y)*boxdim)
            else:
                toReturn.add(box + Vector(x, y)*boxdim)

    #toReturn.setMaterial(4).plot()

    return (toReturn + Vector(-boxdim*(boxnum+1)/2., -boxdim*(boxnum+1)/2.)).setMaterial(4)
Пример #8
0
def select_shape():
    #    shape_choosen = -1
    user_input = raw_input("Select shape: dot [d] | line [l] | square [s] ")
    if user_input == 'QUIT':
        state = 9
    elif int(user_input) == 0:
        print("You choose [dot]")
        shape_choosen = int(user_input)
        shape.pix = 1
        state = 3
    elif int(user_input) == 1:
        print("You choose [line]")
        shape_choosen = int(user_input)
        shape.pix = shapes.line_h(shape_length)
        state = 3
    elif int(user_input) == 2:
        print("You choose [square]")
        shape_choosen = int(user_input)
        shape.pix = shapes.rect(shape_length,shape_length,0)
        state = 3
    else:
        print("Shape not found")
Пример #9
0
 def next(self,input):
     global canvas, layer, shape, shape_choosen, shape_length, shape_orientation
     user_input = raw_input("Select shape: dot [0] | line [1] | square [2] | Clear Canvas [9]")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 0
         shape.orientation = 0
         shape.length = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 1
         shape.orientation = 0
         shape.length = 5
         shape.pix = shapes.line_h(shape_length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 2
         shape.orientation = 0
         shape.length = 5
         shape.fill = 0
         shape.pix = shapes.rect(shape_length, shape_length, 0)
         return DrawingApp.create
     elif int(user_input) == 9:
         print "Clearing Canvas..."
         return DrawingApp.clear_canvas
     else:
         print("Shape not found")
         return DrawingApp.select
Пример #10
0
 def next(self,input):
     user_input = raw_input("Select shape: dot [0] | line [1] | square [2] ")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         # shape.pix = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         shape.pix = shapes.line_h(shape_length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         shape.pix = shapes.rect(shape_length, shape_length, 0)
         return DrawingApp.create
     else:
         print("Shape not found")
         return DrawingApp.select
Пример #11
0
            # key DOMAINS
            f.write(
                '\t\t<rect x="295" y="110" width="10" height="10" '
                'style="fill: #cecece; stroke-width:1; stroke: #474141" />\n'
                '\t\t<text text-anchor="start" x="315" y="120" '
                'style = "font-size: 10; font-weight: bold; fill: #474141">Domains</text>\n\n'
            )
            # set up number line + labels + domains
            n = 0
            for n in range(0, 4):
                base = 200 + 100 * n
                # domains
                for domain in domainresults:
                    f.write('\n<!-- Domain -->\n')
                    f.write(
                        shapes.rect(base, domain[0] * 3 - 1,
                                    domain[1] * 3 - 1))

                # line and labels
                f.write('\n<!-- #LINE + LABELS -->\n')
                f.write(
                    '\t<line x1="0" y1="' + str(base) + '" x2="' +
                    str(length) + '" y2="' + str(base) + '" '
                    'style="stroke: #000000; stroke-width:2; stroke-linecap: round" />\n'
                    '\t<line x1="1" y1="' + str(base - 10) + '" x2="1" y2="' +
                    str(base + 10) + '" '
                    'style="stroke: #000000; stroke-width:2; stroke-linecap: round" />\n'
                    '\t<text text-anchor="start" x="0" y="' + str(base + 30) +
                    '" '
                    'style = "font-size: 12px;">0</text>'
                    '\t<line x1="' + str(length) + '" y1="' + str(base - 10) +
                    '" x2="' + str(length) + '" y2="' + str(base + 10) +
                # key DOMAINS
                f.write(
                    '\t\t<rect x="295" y="90" width="10" height="10" '
                    'style="fill: #cecece; stroke-width:1; stroke: #474141" />\n'
                    '\t\t<text text-anchor="start" x="315" y="100" '
                    'style = "font-size: 10; font-weight: bold; fill: #474141">Domains</text>\n\n'
                )

                n = 0
                for n in range(0, 2):
                    height = 200 + 100 * n

                    # Domain
                    for domain in domainresults:
                        f.write('\n<!-- Domain -->\n')
                        f.write(shapes.rect(height, domain[0] * 3 - 1, domain[1] * 3 - 1))

                    # line and labels
                    f.write('\n<!-- #LINE + LABELS -->\n')
                    f.write(
                        '\t<line x1="0" y1="' + str(height) + '" x2="' + str(length) + '" y2="' + str(height) + '" '
                        'style="stroke: #000000; stroke-width:2; stroke-linecap: round" />\n'
                        
                        '\t<line x1="1" y1="' + str(height - 10) + '" x2="1" y2="' + str(height + 10) + '" '
                        'style="stroke: #000000; stroke-width:2; stroke-linecap: round" />\n'
                        
                        '<text text-anchor="start" x="0" y="' + str(height + 30) + '" '
                        'style = "font-size: 12px;">0</text>'
                        
                        '\t<line x1="' + str(length + 2) + '" y1="' + str(height - 10)
                        + '" x2="' + str(length+2) + '" y2="' + str(height + 10)
Пример #13
0
def starkRound1(fname):
    gds = GDSinfo()
    
#    gds.add(capacitor(10, 10, 150, 200, 100, 5, 5, 3, 4));
#    gds.add(dev2D(0) + Vector(0, 100));
#    gds.add(dev2D(1) + Vector(0, 50));

    xi = 0
    yi = 0
    
    P = [75, 100, 150];
    CS = [7, 10, 25] #, 8, 10, 15, 20
    T = [0, 2] #, -7]#, 3]
    N = [2]
    WWS = [10, 15]
    DS = [14, 16, 18, 20, 25, 30]

    for p in P:
        for cs in CS:
            for n in N:
                for wws in WWS:
                    yi += 1;
                    for t in T:
                        for ds in DS:
                            xi += 1;
                            
#                            wws = 10

    #                        print p, cs, t

                            chip = Shape([], []);
                            
                            boxwid = 1400 - 4*wws
                            
                            tipwid = 2
                                
                            if t < 0:
                                tipwid = -t
                                t = 1
                            
                            tipwid *= ds/12.
                            tipwid = int(tipwid*100)/100.
                                
                            if t == 3:
                                [dev, devhgt] = dev2D(T[0], padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30)
                            else:
                                [dev, devhgt] = dev2D(t, padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30)
                            
                            [bbll, bbur] = dev.getBoundingBox()
                            
                            wid = bbur.x - bbll.x;
                            
                            capwid = (boxwid - wid - 4*wws)/2.
                            
                            numcap = int((boxwid/devhgt) + .25)
                            
                            for i in range(1, numcap+1):
                                if t == 3:
                                    if i == 1:
                                        chip.add(dev + Vector(0, -boxwid/2. + (i-1)*devhgt + p + wws*2));
                                    else:
    #                                    print T[i-1]
    #                                    print dev2D(T[i-1], diskspacing=ds, padsize=p, wirewidF=wws, wirespaceF=wws, gespace=30)
                                        t2 = T[i-1]
                                        if t2 < 0:
                                            t = 1
                                            tipwid = -t2

                                        chip.add(dev2D(t2, diskspacing=ds, padsize=p, wirewidF=wws, wirespaceF=wws, gespace=30, tipwid=tipwid) + Vector(0, boxwid/2. - i*devhgt));
                                else:
                                    chip.add(dev + Vector(0, -boxwid/2. + (i-1)*devhgt + p + wws*2));
                            
                            [cap, capwidtrue] = capacitor(wirewid=wws, wirespace=cs, height=boxwid, width=capwid, paddepth=p, numY=n, circlewid=5, numcirclesets=4, addBreak=5)
                            
            #                [bbll, bbur] = cap.getBoundingBox()

            #                capwidtrue

                            chip.add(cap - Vector(boxwid/2., boxwid/2.));
                            chip.add(cap + Vector(boxwid/2. - capwidtrue, -boxwid/2.));

                            height=boxwid
                            paddepth=p
                            numY=n
                            
                            l = int((height - paddepth)/float(numY) - paddepth)
                            
                            if   t == 0:
                                type = "SQUARE"
                            elif t == 1:
                                type = "TIP:" + str(tipwid) + "UM"
                            elif t == 2:
                                type = "CIRCLE"
                            elif t == 3:
                                type = "MIXED"

                            chip.add(boundingDiamond(left="W=10um\nS=" + str(cs) + "um\nP=" + str(p) + "um\nL=" + str(l) + "um", center="T=" + type + "\nDS=" + str(ds) + "um\nP=" + str(p) + "um\n[" + str(xi) + ", " + str(yi) + "]", right="W=10um\nS=" + str(cs) + "um\nP=" + str(p) + "um\nL=" + str(l) + "um"));

                            gds.add(chip*(Matrix(1, -1, 1, 1, xi*2250, yi*2250)/math.sqrt(2)))
                    xi = 0;

    
#    yi += 1;
    xi = 0;

    for p in P:
        yi += 1;
        for t in T:
            for ds in DS:
                xi += 1;
                
                wws = 10
                
                #                        print p, cs, t
                
                chip = Shape([], []);
                
                boxwid = 1400 - 4*wws
                
                tipwid = 2
                
                if t < 0:
                    tipwid = -t
                    t = 1
                
                tipwid *= ds/12.
                tipwid = int(tipwid*100)/100.
                
                lrpad = 2
    
                if t == 3:
                    [dev, devhgt] = dev2D(T[0], padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=2)
                else:
                    [dev, devhgt] = dev2D(t, padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=2)
                
#                dev = dev - Vector(p, 0);

                [bbll, bbur] = dev.getBoundingBox()
                    
                wid = bbur.x - bbll.x;
                
                boxwid2 = boxwid - p - 4*wws

                numcap = int((boxwid/devhgt) + .25)

                numdev = -1
    
                while boxwid2 > 0:
                    boxwid2 -= wid
                    numdev += 1
                
                for x in range(1, numdev+1):
                    
                    for i in range(1, numcap+1):
                        if t == 3:
                            if i == 1:
                                chip.add(dev + Vector((x-(numdev+1)*.5)*wid, (i-1-numcap/2.)*devhgt + p + wws*2));
                            else:
                                #                                    print T[i-1]
                                #                                    print dev2D(T[i-1], diskspacing=ds, padsize=p, wirewidF=wws, wirespaceF=wws, gespace=30)
                                t2 = T[i-1]
                                if t2 < 0:
                                    t = 1
                                    tipwid = -t2
                                
                                chip.add(dev2D(t2, diskspacing=ds, padsize=p, wirewidF=wws, wirespaceF=wws, gespace=30, tipwid=tipwid, lrpad=lrpad) + Vector((x-numdev*.5)*wid, boxwid/2. - i*devhgt));
                        else:
                            print (x-(numdev+1)*.5)
                            chip.add(dev + Vector((x-(numdev+1)*.5)*wid, -boxwid/2. + (i-1)*devhgt + p + wws*2));
                
                    if x+1 == numdev:
                        lrpad = 0
                        if t == 3:
                            [dev, devhgt] = dev2D(T[0], padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=0)
                        else:
                            [dev, devhgt] = dev2D(t, padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=0)
                                
#                        dev += Vector(p, 0)
#                    elif x+1 == numdev-1:
#                        print "Bye...";
#                    else:
#                        lrpad = 3
#                        
#                        if t == 3:
#                            [dev, devhgt] = dev2D(T[0], padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=3)
#                        else:
#                            [dev, devhgt] = dev2D(t, padsize=p, diskspacing=ds, wirewidF=wws, wirespaceF=wws, tipwid=tipwid, gespace=30, lrpad=3)

                if   t == 0:
                    type = "SQUARE"
                elif t == 1:
                    type = "TIP:" + str(tipwid) + "UM"
                elif t == 2:
                    type = "CIRCLE"
                elif t == 3:
                    type = "MIXED"
                        
                string = "[" + str(xi) + ", " + str(yi) + "]"
                
                chip.add(boundingDiamond(left=string, center="T=" + type + "\nDS=" + str(ds) + "um\nP=" + str(p) + "um", right=string));
                
                gds.add(chip*(Matrix(1, -1, 1, 1, xi*2250, yi*2250)/math.sqrt(2)))
        xi = 0;

    yi += 1;
    
    boxwid = 1400 - 4*wws
    
    for xi in range(-2, len(T)*len(DS)-2):
        chip = Shape([], []);
        
        wid = 5*xi + 5
        
        x = -boxwid/2.
        h = -boxwid/2.
        
        if xi <= 0:
            string = "L=.5:1:2:3:...um"
            
            wid = .5
            chip.add(rect(Vector(x,-h), Vector(x+wid, h)).setMaterial(3))
            x += 2*wid;
            chip.add(rect(Vector(x,-h), Vector(x+wid, h)).setMaterial(3))
            x += 2*wid;
            chip.add(rect(Vector(x,-h), Vector(x+wid, h)).setMaterial(3))
            x += 2*wid;
            
            wid = 1
            
            i = 1
            
            while x + wid < boxwid/2.:
                if (wid%5) == 0:
                    chip.add(rect(Vector(x,-.95*h), Vector(x+wid, .95*h)).setMaterial(3))
                else:
                    chip.add(rect(Vector(x,-h), Vector(x+wid, h)).setMaterial(3))
                
                x += 2*wid;
                if (i%3) == 0:
                    wid += 1;

                i += 1;
        else:
            string = "L=" + str(wid) + "um";
            
            while x + wid < boxwid/2.:
                chip.add(rect(Vector(x,-h), Vector(x+wid, h)).setMaterial(3))
                x += 2*wid;
        
        string2 = "[" + str(xi+2) + ", " + str(yi) + "]";
        
        chip.add(boundingDiamond(left=string2, center=string, right=string2, centeru=" "));
        
        gds.add(chip*(Matrix(1, -1, 1, 1, (xi+3)*2250, yi*2250)/math.sqrt(2)))
        gds.add(chip*(Matrix(1, -1, 1, 1, (xi+3)*2250, (yi+1)*2250)/math.sqrt(2)))
        gds.add(chip*(Matrix(1, -1, 1, 1, (xi+3)*2250, (yi+2)*2250)/math.sqrt(2)))
            
    yi += 3;
                    
    for xi in range(0, len(T)*len(DS)):
#        chip = Shape([], []);

        v = Vector(1,1)
        w = Vector(1,-1)
        
        oo = 2250/2.
        oi = (2100 - xi*25)/2.
        
        #    print outer, wid, outer-wid
        #    print oo, oi
        
        rect1 = Polyline([v*oo, w*oo, -v*oo, -w*oo, v*oo, v*oi, -w*oi, -v*oi, w*oi, v*oi], True, False, 3).setMaterial(3);
        
        gds.add(rect1 + Vector((xi+1)*2250, yi*2250))
        
        gds.add((font.shapeFromStringBoundedCentered(str(2100 - xi*25) + "um", 100, -1) + Vector((xi+1)*2250, (yi+.6)*2250)).setMaterial(3))

#    print "Plotting"
#    gds.plot()
    print "Exporting"
    gds.exportGDS(fname)
    print "Done"
Пример #14
0
def dev2D(tip=2, tipwid=2, diskspacing=12, electspacing=5, gap=6, groundoffset=2.5, electwid=8, wirewid=6, wirespaceF=10, wirewidF=10, gespace=40, padsize=100, disks=[1.2, 1.3, 1.4, 1.5], couplinggap=.08, couplingwid=.12, couplinglen=1, lrpad=0):
    toReturn = Shape([]);
    
    if diskspacing < electwid:
        return None
    
    numdisks = len(disks)

    electspacing = diskspacing/3.
    groundoffset = diskspacing/4.
    electwid = 2*diskspacing/3.
    wirewid = diskspacing/2.
    wirespace = diskspacing/2.
    gespace = 4.5*electwid
    
    if wirespace >= wirespaceF:
        wirespaceF = wirespace #+.001
    if wirewid >= wirewidF:
        wirewidF = wirewid #+.001
    
            
    v1 = Vector(math.cos(math.pi/2.+couplinglen/2.), math.sin(math.pi/2.+couplinglen/2.))
    v2 = Vector(math.cos(math.pi/2.-couplinglen/2.), math.sin(math.pi/2.-couplinglen/2.))

    prevConnection = 0
    
    tranlen = .75
    
    disky = wirewidF + wirespaceF/2. + groundoffset
    
    gapStuff = Shape([]);

    for i in range(0, numdisks):
        c = Vector((i+.5-numdisks/2.)*diskspacing, disky)
        gapStuff.add(circle(c, disks[i]/2.).setMaterial(1))

        irad = disks[i]/2. + couplinggap
        orad = disks[i]/2. + couplinggap + couplingwid
        
        iwid = couplingwid
        owid = .24
        mrad = (irad + orad)/2.
        
#        pline = arc(c, c+v1, c+v2)

        pline = arc(c, c+v1*irad, c+v2*irad) + arc(c, c+v2*orad, c+v1*orad)
        pline.closed = True

        gapStuff.add(pline.setMaterial(1))
        left =  thickenPolyline(Polyline([c+v1*mrad, c+v1*mrad+v1.perp()*tranlen]), "CUBIC", [iwid, owid]).setMaterial(1)
        right = thickenPolyline(Polyline([c+v2*mrad, c+v2*mrad+v2.perp().perp().perp()*tranlen]), "CUBIC", [iwid, owid]).setMaterial(1)

        gapStuff.add(left)
        gapStuff.add(right)

#        print 'L: ', left.connections
#        print 'R: ', right.connections

        if not isinstance(prevConnection, Connection):
            firstConnection = Connection(c+v1*mrad+v1.perp()*tranlen, v1.perp(), owid)
        else:
            i = prevConnection
            f = Connection(c+v1*mrad+v1.perp()*tranlen, v1.perp(), owid)
            gapStuff.add(connectAndThicken(i,f).setMaterial(1))
        
        prevConnection = Connection(c+v2*mrad+v2.perp().perp().perp()*tranlen, v2.perp().perp().perp(), owid)
            
    gratingOne = Connection(Vector(-numdisks*diskspacing/2. - diskspacing/2., disky), Vector(1,0), owid)
    gratingTwo = Connection(Vector(-numdisks*diskspacing/2. - diskspacing/2. - 9.5 - 5,    disky - 9.5), Vector(0,-1), owid)
    gratingTwoA = Connection(Vector(-(numdisks+2)*diskspacing/2., wirewidF/6.), Vector(1,0), owid)
    gratingTwoC = Connection(Vector(numdisks*diskspacing/2., wirewidF/6.), Vector(1,0), owid)
    
    gapStuff.add(connectAndThicken(gratingOne,firstConnection).setMaterial(1))
    gapStuff.add(connectAndThicken(gratingTwoC,prevConnection).setMaterial(1))
    gapStuff.add(connectAndThicken(-gratingTwoC,gratingTwoA).setMaterial(1))
    gapStuff.add(connectAndThicken(-gratingTwoA,gratingTwo).setMaterial(1))
    gapStuff.add(gratingMike(gratingOne))
    gapStuff.add(gratingMike(gratingTwo))

#    gapStuff.plot();

#        arc(c, c+v1, c+v2).plot()

    y = gespace/4. # electspacing - groundoffset + electwid/2. -wirewid/2 + tipwid/2.

    for i in range(0, (numdisks+2)/2):
        v = Vector((i-numdisks/2.)*diskspacing, electspacing - groundoffset + electwid/2. + disky)
#        if i == 0:
#            rect1 = rect(v + Vector(0, -wirewid/2. + tipwid/2.), v + Vector(-10, wirewid/2. + tipwid/2.))
#            rect1 = rect(v + Vector(wirewid/2., -wirewid/2. + tipwid/2.), v + Vector(-electwid, wirewidF-wirewid/2. + tipwid/2.))
#        else:
        rect1 = -rect(v + Vector(-wirewid/2., -wirewid/2 + tipwid/2.), v + Vector(wirewid/2, y + wirewidF - (electspacing - groundoffset + electwid/2.)))

        if tip == 0:        # SQUARE
            tipobj = rect(v - Vector(electwid/2., electwid/2.), v + Vector(electwid/2., electwid/2.)).union(-rect1).setMaterial(3)
        elif tip == 1:      # POINTY
            x = electwid/2. - tipwid/2.
            if i == 0:
                pline = Polyline([v, v + Vector(x,-x)])
                
                tipobj = rect1.union(-thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND")).setMaterial(3)
            else:
                pline = Polyline([v + Vector(-x,-x), v, v + Vector(x,-x)])
                
                tipobj = thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND").union(-rect1).setMaterial(3)
        elif tip == 2:      # CIRCLE
            tipobj = circle(v, electwid/2.).union(rect1).setMaterial(3)
        
        if i != (numdisks+2)/2.:
            toReturn.add(tipobj)
    
    
    # Pads
#    v = Vector(-padsize-wirespaceF/2., y + 2*wirespaceF + wirewidF + padsize)   # Right
#    toReturn.add(rect(v, v + Vector(padsize, padsize)))
#    toReturn.add(rect(v + Vector(padsize-wirewidF, -padsize + wirewidF + wirespaceF), v + Vector(padsize, 0)))
#    toReturn.add(rect(Vector((2-numdisks/2.)*diskspacing - wirewid/2., gespace/2. + wirewidF), Vector((2-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + 2*wirewidF + 2*wirespaceF)))
#    toReturn.add(rect(Vector((2-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + 2*wirewidF + 2*wirespaceF), v + Vector(padsize-wirewidF, -padsize + wirewidF + wirespaceF)))

    v = Vector(-padsize-wirespaceF-wirewidF/2., y + wirespaceF + wirewidF + disky)    # L/R (prev Middle)
    toReturn.add(rect(v, v + Vector(padsize, padsize)))
    toReturn.add(rect(Vector((1-numdisks/2.)*diskspacing - wirewid/2., y + disky + wirewidF), Vector((1-numdisks/2.)*diskspacing + wirewid/2., y + disky + wirewidF + wirespaceF)))
    toReturn.add(rect(v + Vector(padsize, 0), Vector((1-numdisks/2.)*diskspacing + wirewid/2., y + disky + 2*wirewidF + wirespaceF)))

    toReturn.add(rect(v - Vector(wirespaceF, wirewidF + wirespaceF), Vector((0-numdisks/2.)*diskspacing - wirewid/2., y + disky + wirewidF)))

#    v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, y)                          # Left
##    toReturn.add(rect(v, v + Vector(padsize, padsize)))
#    toReturn.add(rect(v + Vector(padsize, 0), Vector((-numdisks/2.)*diskspacing - wirewid/2., y + wirewidF)))

#    v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, -groundoffset)                          # Ground Left
##    toReturn.add(rect(v, v + Vector(padsize, -padsize)))
#    toReturn.add(rect(v + Vector(padsize, 0), Vector((-numdisks/2.)*diskspacing - wirewid/2., -groundoffset - wirewidF)))

    toReturn.add(toReturn*Matrix(-1,0,0,1)) # FLIP HORIZ

    #toReturn.add(rect(v - Vector(wirewidF + wirespaceF, wirewidF + wirespaceF), v - Vector(wirespaceF, - padsize - wirewidF - wirespaceF)))
    #toReturn.add(rect(Vector(v.x - (wirewidF + wirespaceF), 0), v - Vector(wirespaceF, - padsize - wirewidF - wirespaceF)))
    toReturn.add(rect(Vector(v.x - (2*wirewidF + wirespaceF), 0), Vector(v.x-wirespaceF, 200)))
    toReturn.add(rect(Vector(7*wirewidF/2. + 3*wirespaceF + padsize, 0), Vector(11*wirewidF/2. + 3*wirespaceF + padsize, 200)))   # Ground line

    toReturn.add(rect(v + Vector(-wirespaceF, padsize + wirespaceF), Vector(-v.x + wirespaceF, v.y + padsize + wirespaceF + wirewidF)))

    toReturn.add(rect(Vector(-wirewidF/2., y + disky + 3*wirespaceF + wirewidF), Vector(wirewidF/2., y + disky + 2*wirespaceF + wirewidF + padsize)))
    toReturn.add(rect(Vector(-wirewid/2., y + disky + wirewidF), Vector(wirewid/2., y + disky + 3*wirespaceF + wirewidF)))
    toReturn.add(tipobj)
    
#    if not (lrpad & 0x01):  # Make left pad
#        v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, y)                          # Left
#        toReturn.add(rect(v, v + Vector(padsize, padsize)))
#        v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, -groundoffset)                          # Ground Left
#        toReturn.add(rect(v, v + Vector(padsize, -padsize)))
#    
#    if not (lrpad & 0x02):  # Make right pad
#        v = Vector(-(-padsize-5*wirespaceF/2.-wirewidF), y)                          # Left
#        toReturn.add(rect(v, v + Vector(padsize, padsize)))
#        v = Vector(-(-padsize-5*wirespaceF/2.-wirewidF), -groundoffset)                          # Ground Left
#        toReturn.add(rect(v, v + Vector(padsize, -padsize)))

    # Ground
    gwid = diskspacing*numdisks/2. + electwid/2.
    gwid2 = diskspacing*numdisks/2. + wirewid/2.
#    toReturn.add(rect(Vector(-gwid, -gespace/2.), Vector(gwid, -groundoffset)).setMaterial(3))
#    toReturn.add(rect(Vector(-gwid2, -gespace/2.-wirewidF), Vector(gwid2, -gespace/2.)).setMaterial(3))
    toReturn.add(rect(Vector(-gwid2, wirespaceF/2.), Vector(gwid2 + wirespaceF, wirewidF + wirespaceF/2.)).setMaterial(3))

    toReturn.add((rect(v - Vector(wirewidF + wirespaceF, wirewidF + wirespaceF), v - Vector(wirespaceF, - padsize - wirewidF - wirespaceF))*Matrix(-1,0,0,1)).setMaterial(3))
    
    toReturn.setMaterial(3)

    toReturn.add(gapStuff)

    toReturn.add(toReturn*Matrix(1,0,0,-1)) # FLIP VERT

    toReturn.add(rect(Vector(gwid2 + wirespaceF, -wirewidF - wirespaceF/2.), Vector(gwid2 + wirespaceF + wirewidF, wirewidF + wirespaceF/2.)).setMaterial(3))
    toReturn.add(rect(Vector(gwid2 + wirespaceF + wirewidF, - wirewidF), Vector(7*wirewidF/2. + 3*wirespaceF + padsize, wirewidF)).setMaterial(3))
#    toReturn.add(rect(Vector(3*wirewidF/2. + 3*wirespaceF + padsize, -wirespaceF/2.), Vector(5*wirewidF/2. + 3*wirespaceF + 2*padsize, -wirespaceF/2. + padsize)).setMaterial(3))

#    toReturn.add((rect(v - Vector(wirewidF + wirespaceF, wirewidF + wirespaceF), v - Vector(wirespaceF, - padsize - wirewidF - wirespaceF))*Matrix(-1,0,0,1)).setMaterial(3))

#    toReturn.add((font.shapeFromStringBoundedCentered("42", -1, 7*5) +      Vector(-85, 0)).setMaterial(3))

#    return [toReturn.setMaterial(3), 2*padsize + 3*wirespaceF + groundoffset + gespace/2. + 3*wirewidF]

    return toReturn
Пример #15
0
def capacitor(wirewid=10, wirespace=10, height=1300, width=200, paddepth=100, numY=2., circlewid=5, numcirclesets=4, addBreak=0):
    toReturn = Shape([]);
    
    length = (height - (numY+1)*paddepth)/numY
    
    numcirclesets = int(2*math.sqrt((length-2*wirespace)/(12*circlewid)))

    wire = rect(Vector(0,0), Vector(wirewid, length-2*wirespace))
    wire.material = 3;
    
    d = (length-4.*wirespace)/numcirclesets
#    print length
#    print -4*wirespace
#    print length-4*wirespace
#    print d
#    print ''
#    circlespacing = 1.5*circlewid
#    
##    print range(1,numcirclesets)
#
#    c = circle(Vector(0,0), circlewid/2)
#    x = circlewid/4.
##    c = -rect(Vector(-x,-x), Vector(x,x))
#    c.material = 3;
#    
##    for y in range(0,numcirclesets+1):
##        toReturn.add(circle(Vector(-circlewid, y*d + 2.*wirespace), circlewid/2))
#
#    for y in range(1,numcirclesets+1):
##        print range(0,y)
#
#        for z in range(0,y):
#            print y, z
#            #            circle(Vector(-wirewid/2, (y*d - d/2 + 2*wirespace) - (y*circlespacing/2) + z*circlespacing), circlewid/2).plot()
#            #            wire = (circle(Vector(wirewid/2, (y*d - d/2 + 2*wirespace) - (y*circlespacing/2) + z*circlespacing), circlewid/2)).intersect(wire)
#            wire = (c + Vector(wirewid/2., (y*d - d/2. + 2.*wirespace) - ((y-1)*circlespacing/2.) + z*circlespacing)).intersect(wire)

#    for

#    m = Matrix(math.pi, wirewid, length)
#    
#    print m

    wire2 = wire*Matrix(math.pi, wirewid, length)
    
#    print wire
#    print wire2

    x = 0;
    
    wires = Shape([]);
    
    while x < width - 1*(wirewid):
        wires.add(wire + Vector(x, 0))
        x += wirewid+wirespace
        
        if x < width - 1*(wirewid):
            wires.add(wire2 + Vector(x, 0))
            x += wirewid+wirespace

    pad = rect(Vector(0, 0), Vector(x-wirespace, paddepth));
    pad.material = 3;

    pad2 = rect(Vector(0, addBreak/2. + paddepth/2.), Vector(x-wirespace, paddepth));
    pad3 = rect(Vector(0, 0), Vector(x-wirespace, -addBreak/2. + paddepth/2.));
    pad2.material = 3;
    pad3.material = 3;

    toReturn.add(pad)

    for i in range(0, numY):
        toReturn.add(wires + Vector(0, i*(length + paddepth) + paddepth))
        if i != numY-1 and addBreak:
            toReturn.add(pad2 + Vector(0, (i+1)*(length+paddepth)))
            toReturn.add(pad3 + Vector(0, (i+1)*(length+paddepth)))
        else:
            toReturn.add(pad + Vector(0, (i+1)*(length+paddepth)))
    
    
    
    if x-wirespace < width:
        print 'capacitor: Could not fit another wire in. Shrinking the pad width.'
    
#    toReturn.add(font.shapeFromStringBoundedCentered(string, w=0, h=2) + Vector(10,10))

#    toReturn.plot()

    return [toReturn, x-wirespace]
Пример #16
0
def dev2D(tip=1, tipwid=2, diskspacing=12, electspacing=5, gap=6, groundoffset=2.5, electwid=8, wirewid=6, wirespaceF=10, wirewidF=10, gespace=40, padsize=100, disks=[1.2, 1.25, 1.3, 1.35, 1.4], couplinggap=.08, couplingwid=.12, couplinglen=1, lrpad=0):
    toReturn = Shape([]);
    
    if diskspacing < electwid:
        return None
    
    numdisks = len(disks)

    electspacing = diskspacing/3.
    groundoffset = diskspacing/4.
    electwid = 2*diskspacing/3.
    wirewid = diskspacing/2.
    wirespace = diskspacing/2.
    gespace = 4.5*electwid
    
    if wirespace >= wirespaceF:
        wirespaceF = wirespace #+.001
    if wirewid >= wirewidF:
        wirewidF = wirewid #+.001
    
            
    v1 = Vector(math.cos(math.pi/2.+couplinglen/2.), math.sin(math.pi/2.+couplinglen/2.))
    v2 = Vector(math.cos(math.pi/2.-couplinglen/2.), math.sin(math.pi/2.-couplinglen/2.))

    prevConnection = 0
    
    tranlen = .75
    
#    gapStuff = Shape([]);
#
#    for i in range(0, numdisks):
#        c = Vector((i+.5-numdisks/2.)*diskspacing, 0)
#        gapStuff.add(circle(c, disks[i]/2.).setMaterial(1))
#
#        irad = disks[i]/2. + couplinggap
#        orad = disks[i]/2. + couplinggap + couplingwid
#        
#        iwid = couplingwid
#        owid = .24
#        mrad = (irad + orad)/2.
#        
##        pline = arc(c, c+v1, c+v2)
#
#        pline = arc(c, c+v1*irad, c+v2*irad) + arc(c, c+v2*orad, c+v1*orad)
#        pline.closed = True
#
#        gapStuff.add(pline.setMaterial(1))
#        left =  thickenPolyline(Polyline([c+v1*mrad, c+v1*mrad+v1.perp()*tranlen]), "CUBIC", [iwid, owid]).setMaterial(1)
#        right = thickenPolyline(Polyline([c+v2*mrad, c+v2*mrad+v2.perp().perp().perp()*tranlen]), "CUBIC", [iwid, owid]).setMaterial(1)
#
#        gapStuff.add(left)
#        gapStuff.add(right)
#
##        print 'L: ', left.connections
##        print 'R: ', right.connections
#
#        if not isinstance(prevConnection, Connection):
#            firstConnection = Connection(c+v1*mrad+v1.perp()*tranlen, v1.perp(), owid)
#        else:
#            i = prevConnection
#            f = Connection(c+v1*mrad+v1.perp()*tranlen, v1.perp(), owid)
#            gapStuff.add(connectAndThicken(i,f).setMaterial(1))
#        
#        prevConnection = Connection(c+v2*mrad+v2.perp().perp().perp()*tranlen, v2.perp().perp().perp(), owid)
#
#    gapStuff.plot();

#        arc(c, c+v1, c+v2).plot()

    y = gespace/2. # electspacing - groundoffset + electwid/2. -wirewid/2 + tipwid/2.

    for i in range(0, (numdisks+1)/2):
        v = Vector((i-numdisks/2.)*diskspacing, electspacing - groundoffset + electwid/2.)
#        if i == 0:
#            rect1 = rect(v + Vector(0, -wirewid/2. + tipwid/2.), v + Vector(-10, wirewid/2. + tipwid/2.))
#            rect1 = rect(v + Vector(wirewid/2., -wirewid/2. + tipwid/2.), v + Vector(-electwid, wirewidF-wirewid/2. + tipwid/2.))
#        else:
        rect1 = -rect(v + Vector(-wirewid/2., -wirewid/2 + tipwid/2.), v + Vector(wirewid/2, gespace/2. + wirewidF - (electspacing - groundoffset + electwid/2.)))

        if tip == 0:        # SQUARE
            toReturn.add(rect(v - Vector(electwid/2., electwid/2.), v + Vector(electwid/2., electwid/2.)).union(-rect1).setMaterial(3))
        elif tip == 1:      # POINTY
            x = electwid/2. - tipwid/2.
            if i == 0:
                pline = Polyline([v, v + Vector(x,-x)])
                toReturn.add(rect1.union(-thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND")).setMaterial(3))
#                toReturn.add(rect1)
#            elif i == numdisks:
#                pline = Polyline([v + Vector(-x,-x), v])
#                toReturn.add(thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND").setMaterial(3))
            else:
                pline = Polyline([v + Vector(-x,-x), v, v + Vector(x,-x)])
#                pline.plot()
#                toReturn.add(thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND").setMaterial(3))
#                toReturn.add(rect(v + Vector(-wirewid/2., -wirewid/2 + tipwid/2.), v + Vector(wirewid/2, 10)).setMaterial(3))
                toReturn.add(thickenPolyline(pline, "CONSTANT", tipwid/2., "SHARP", "ROUND").union(-rect1).setMaterial(3))
        elif tip == 2:      # CIRCLE
            toReturn.add(circle(v, electwid/2.).union(rect1).setMaterial(3))
    
    # Pads
    v = Vector(-padsize-wirespaceF/2., y + 2*wirespaceF + wirewidF + padsize)   # Right
    toReturn.add(rect(v, v + Vector(padsize, padsize)))
    toReturn.add(rect(v + Vector(padsize-wirewidF, -padsize + wirewidF + wirespaceF), v + Vector(padsize, 0)))
    toReturn.add(rect(Vector((2-numdisks/2.)*diskspacing - wirewid/2., gespace/2. + wirewidF), Vector((2-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + 2*wirewidF + 2*wirespaceF)))
    toReturn.add(rect(Vector((2-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + 2*wirewidF + 2*wirespaceF), v + Vector(padsize-wirewidF, -padsize + wirewidF + wirespaceF)))
    
    v = Vector(-padsize-3*wirespaceF/2.-wirewidF, y + wirespaceF + wirewidF)    # Middle
    toReturn.add(rect(v, v + Vector(padsize, padsize)))
    toReturn.add(rect(Vector((1-numdisks/2.)*diskspacing - wirewid/2., gespace/2. + wirewidF), Vector((1-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + wirewidF + wirespaceF)))
    toReturn.add(rect(v + Vector(padsize, 0), Vector((1-numdisks/2.)*diskspacing + wirewid/2., gespace/2. + 2*wirewidF + wirespaceF)))
    
    v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, y)                          # Left
#    toReturn.add(rect(v, v + Vector(padsize, padsize)))
    toReturn.add(rect(v + Vector(padsize, 0), Vector((-numdisks/2.)*diskspacing - wirewid/2., y + wirewidF)))
    
    v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, -groundoffset)                          # Ground Left
#    toReturn.add(rect(v, v + Vector(padsize, -padsize)))
    toReturn.add(rect(v + Vector(padsize, 0), Vector((-numdisks/2.)*diskspacing - wirewid/2., -groundoffset - wirewidF)))

    toReturn.add(toReturn*Matrix(-1,0,0,1))
    
    if not (lrpad & 0x01):  # Make left pad
        v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, y)                          # Left
        toReturn.add(rect(v, v + Vector(padsize, padsize)))
        v = Vector(-2*padsize-5*wirespaceF/2.-wirewidF, -groundoffset)                          # Ground Left
        toReturn.add(rect(v, v + Vector(padsize, -padsize)))
    
    if not (lrpad & 0x02):  # Make right pad
        v = Vector(-(-padsize-5*wirespaceF/2.-wirewidF), y)                          # Left
        toReturn.add(rect(v, v + Vector(padsize, padsize)))
        v = Vector(-(-padsize-5*wirespaceF/2.-wirewidF), -groundoffset)                          # Ground Left
        toReturn.add(rect(v, v + Vector(padsize, -padsize)))

    # Ground
    gwid = diskspacing*numdisks/2. + electwid/2.
    gwid2 = diskspacing*numdisks/2. + wirewid/2.
#    toReturn.add(rect(Vector(-gwid, -gespace/2.), Vector(gwid, -groundoffset)).setMaterial(3))
#    toReturn.add(rect(Vector(-gwid2, -gespace/2.-wirewidF), Vector(gwid2, -gespace/2.)).setMaterial(3))
    toReturn.add(rect(Vector(-gwid2, -groundoffset-wirewidF), Vector(gwid2, -groundoffset)).setMaterial(3))

    return [toReturn.setMaterial(3), 2*padsize + 3*wirespaceF + groundoffset + gespace/2. + 3*wirewidF]
Пример #17
0
 def next(self, input):
     global canvas, layer, shape, shape_choosen, shape_length, shape_orientation, secret_mode
     user_input = raw_input(
         "Select shape: dot [0] | line [1] | square [2] | Clear Canvas [9]")
     if user_input == 'QUIT':
         return DrawingApp.end_program
     elif user_input == 'rainbow':
         if secret_mode:
             secret_mode = 0
         else:
             secret_mode = 1
         return DrawingApp.select
     elif int(user_input) == 0:
         print("You choose [dot]")
         shape_choosen = int(user_input)
         shape_orientation = 0
         shape.id = 0
         shape.orientation = 0
         shape.length = 1
         shape.pix[2][2] = 1
         return DrawingApp.create
     elif int(user_input) == 1:
         print("You choose [line]")
         shape_choosen = int(user_input)
         user_input = raw_input("Size: small[s] | medium[m] | large[l]")
         shape_orientation = 0
         shape.id = 1
         shape.orientation = 0
         if user_input == 's':
             shape.length = 5
         elif user_input == 'm':
             shape.length = 9
         elif user_input == 'l':
             shape.length = 16
     #  shape.pix = shapes.line_h(shape_length)
         shape.pix = shapes.line_h(shape.length)
         return DrawingApp.create
     elif int(user_input) == 2:
         print("You choose [square]")
         shape_choosen = int(user_input)
         user_input = raw_input("Size: small[s] | medium[m] | large[l]")
         shape_orientation = 0
         shape.id = 2
         shape.orientation = 0
         if user_input == 's':
             shape.length = 5
         elif user_input == 'm':
             shape.length = 9
         elif user_input == 'l':
             shape.length = 16
         user_input = raw_input("Fill: yes [f] | no [any]")
         if user_input == 'f':
             shape.fill = 1
         else:
             shape.fill = 0
     #    shape.pix = shapes.rect(shape_length, shape_length, 0)
         shape.pix = shapes.rect(shape.length, shape.length, shape.fill)
         return DrawingApp.create
     elif int(user_input) == 9:
         print "Clearing Canvas..."
         return DrawingApp.clear_canvas
     else:
         print("Shape not found")
         return DrawingApp.select