示例#1
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.height = options.get("height", self.height)
        self.angle = options.get("angle", self.angle)

        # make the beam splitter
        bs = Group()
        bs.append(
            Path(P(0, 0),
                 P(0, self.height),
                 P(self.height, self.height),
                 P(self.height, 0),
                 P(0, 0),
                 P(self.height, self.height),
                 fg=self.fg,
                 bg=self.bg))

        # rotate if necessary
        bs.rotate(self.angle, p=bs.bbox().c)

        self.append(bs)
示例#2
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.height = options.get("height", self.height)
        self.width = options.get("width", self.width)
        self.angle = options.get("angle", self.angle)

        # make the free space
        fs = Group()
        fs.append(
            Path(P(0, 0),
                 P(0, self.height),
                 P(self.width, self.height),
                 P(self.width, 0),
                 closed=1,
                 fg=self.fg,
                 bg=self.bg,
                 dash=Dash()))

        # rotate if necessary
        fs.rotate(self.angle, p=fs.bbox().c)

        self.append(fs)
示例#3
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.height = options.get("height", self.height)
        self.width = options.get("width", self.width)
        self.angle = options.get("angle", self.angle)

        # make the beam splitter
        lp = Group()
        lp.append(
            Path(P(0, 0),
                 P(-self.width, 0),
                 P(-self.width, self.height),
                 P(0, self.height),
                 P(0, 0),
                 P(-self.width, self.height),
                 fg=self.fg,
                 bg=self.bg))

        # rotate if necessary
        lp.rotate(self.angle, p=lp.bbox().c)

        self.append(lp)
示例#4
0
    def __init__(self, **options):
        Group.__init__(self, **options)
        p = Group()

        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        if self.width > self.height:
            p.append(
                Path(P(0, 0),
                     P(0, self.height),
                     P(self.width - self.height / 2.0, self.height),
                     C(90, 0),
                     P(self.width, self.height / 2.0),
                     C(180, 90),
                     P(self.width - self.height / 2.0, 0),
                     fg=self.fg,
                     bg=self.bg,
                     closed=1))
        else:
            p.append(
                Path(P(0, 0),
                     P(0, self.height),
                     C(90, 0),
                     P(self.width, self.height / 2.0),
                     C(180, 90),
                     closed=1))

        # rotate if necessary
        self.angle = options.get("angle", self.angle)
        p.rotate(self.angle, p=p.bbox().c)

        self.append(p)
示例#5
0
    def __init__(self, **options):
        # initialise the base class
        Gate.__init__(self, **options)

        # process the options if any
        self.height = options.get("height", self.height)
        self.width = options.get("width", self.width)
        self.angle = options.get("angle", self.angle)
        self.pinLength = options.get("pinLength", self.pinLength)
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
 
        # now draw the gate
        buff = 0.0
        pinEdgeDist = 0.1*self.height
        bodyHeight = self.height
        pl = self.pinLength
        bodyWidth = self.width - 2.0*pl
        gateBody = Group(
                Path(
                    P(pl, buff+0), 
                    P(pl, buff+bodyHeight), 
                    P(pl+bodyWidth/2.0, buff+bodyHeight)), 
                Circle(c=P(pl+bodyWidth/2.0, buff+bodyHeight/2.0), 
                    r=bodyHeight/2.0, start=0, end=180), 
                Path(
                    P(pl+bodyWidth/2.0, buff+0), 
                    P(pl, buff+0))) 
        gatePinIn1 = Path(
                P(0, bodyHeight-pinEdgeDist), 
                P(pl, bodyHeight-pinEdgeDist))
        gatePinIn2 = Path(
                P(0, pinEdgeDist), 
                P(pl, pinEdgeDist))
        gatePinOut = Path(
                P(bodyWidth+pl, bodyHeight/2.0), 
                P(bodyWidth+2.0*pl, bodyHeight/2.0))

        # collect the objects together
        obj = Group(gateBody, gatePinIn1, gatePinIn2, gatePinOut)

        # apply the colours
        obj.apply(fg=self.fg, bg=self.bg)

        # rotate if necessary
        if self.angle != 0.0:
            obj.rotate(self.angle, p=obj.bbox().c)

        # now set the object to myself
        self.append(obj)
示例#6
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.height = options.get("height", self.height)
        self.thickness = options.get("thickness", self.thickness)
        self.angle = options.get("angle", self.angle)
        self.type = options.get("type", self.type)

        # determine what type of lens to make
        if self.type == "convex":
            leftCurveAngle = -30
            rightCurveAngle = -30
        elif self.type == "concave":
            leftCurveAngle = 30
            rightCurveAngle = 30
        else:
            print "Unknown lens type, defaulting to concave"
            leftCurveAngle = 30
            rightCurveAngle = 30

        # make the lens
        lens = Group()
        lens.append(
            Path(
                P(0, 0),
                C(leftCurveAngle, 180 - leftCurveAngle),
                P(0, self.height),
                P(self.thickness, self.height),
                C(-180 + rightCurveAngle, -rightCurveAngle),
                P(self.thickness, 0),
                closed=1,
                fg=self.fg,
                bg=self.bg,
            ))

        # rotate if necessary
        lens.rotate(self.angle, p=lens.bbox().c)

        self.append(lens)
示例#7
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.height = options.get("height", self.height)
        self.width = options.get("width", self.width)
        self.angle = options.get("angle", self.angle)

        # make the modulator
        modulator = Group()
        modulator.append(
            Path(
                P(0, 0),
                P(0, self.height),
                P(self.width, self.height),
                P(self.width, 0),
                closed=1,
                fg=self.fg,
                bg=self.bg,
            ))
        modulator.append(
            Path(
                P(0, -self.buf),
                P(self.width, -self.buf),
                fg=self.fg,
                bg=self.bg,
            ))
        modulator.append(
            Path(
                P(0, self.height + self.buf),
                P(self.width, self.height + self.buf),
                fg=self.fg,
                bg=self.bg,
            ))

        # rotate if necessary
        modulator.rotate(self.angle, p=modulator.bbox().c)

        self.append(modulator)
示例#8
0
    def __init__(self, **options):
        # inherit from the base class
        Group.__init__(self, **options)

        # process the options if any
        self.fg = options.get("fg", self.fg)
        self.bg = options.get("bg", self.bg)
        self.length = options.get("length", self.length)
        self.thickness = options.get("thickness", self.thickness)
        self.angle = options.get("angle", self.thickness)
        self.flicks = options.get("flicks", self.flicks)

        # make the mirror itself
        mirror = Group()
        mirror.append(
            Path(P(0, 0),
                 P(0, self.length),
                 P(self.thickness, self.length),
                 P(self.thickness, 0),
                 closed=1,
                 fg=self.fg,
                 bg=self.bg))

        if self.flicks:
            # make the flicks on the back of the mirror
            flickLen = 0.15
            flicksObj = Group()
            for i in range(10):
                flicksObj.append(
                    Path(P((i + 1.0) * self.length / 10.0, self.thickness),
                         P(i * self.length / 10.0, self.thickness + flickLen),
                         fg=self.fg,
                         bg=self.bg))

            mirror.append(flicksObj)

        # rotate the mirror if necessary
        if self.angle != 0.0:
            mirror.rotate(self.angle, p=mirror.bbox().c)

        # make the mirror the current object
        self.append(mirror)