Esempio n. 1
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
        pinEdgeDist = 0.1*self.height
        pinBackDist = -0.08*self.width
        xBit = 0.2
        pl = self.pinLength
        bodyHeight = self.height
        bodyWidth = self.width - 2.0*pl

        gateBody = Group( 
                Path(
                    P(-pinBackDist+xBit, -pinEdgeDist), 
                    C(90, 225),
                    P(1.4*bodyWidth, bodyHeight/2.), 
                    C(-45, 90),
                    P(-pinBackDist+xBit, bodyHeight+pinEdgeDist), 
                    C(140, 40),
                    P(-pinBackDist+xBit, -pinEdgeDist),
                    ), 
                Path(
                    P(-pinBackDist, bodyHeight+pinEdgeDist), 
                    C(140, 40),
                    P(-pinBackDist, -pinEdgeDist)
                    ),
                )
        gatePinIn1 = Path(
                P(0, bodyHeight-pinEdgeDist), 
                P(pl, bodyHeight-pinEdgeDist))
        gatePinIn2 = Path(
                P(0, pinEdgeDist), 
                P(pl, pinEdgeDist))
        gatePinOut = Path(
                gateBody.e, 
                gateBody.e+P(pl, 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.c)

        # now set the object to myself
        self.append(obj)
Esempio n. 2
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
        pl = self.pinLength
        bodyHeight = self.height
        bodyWidth = self.width - 2.0*pl
        rad = 0.1

        gateBody = Group(
                Path(
                    P(pl, buff+0), 
                    P(pl, buff+bodyHeight), 
                    P(pl+bodyWidth/2., buff+bodyHeight)), 
                Circle(c=P(pl+bodyWidth/2., buff+bodyHeight/2.), 
                    r=bodyHeight/2., start=0, end=180), 
                Path(
                    P(pl+bodyWidth/2., 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 = Group( 
                Circle(c=P(bodyWidth+pl+rad, bodyHeight/2.), r=rad), 
                Path(
                    P(bodyWidth+pl+2.*rad, bodyHeight/2.), 
                    P(bodyWidth+2.*rad+2.*pl, bodyHeight/2.)))

        # 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.c)

        # now set the object to myself
        self.append(obj)
Esempio n. 3
0
    def __init__(self, **options):
        # intitialise base class
        Group.__init__(self, **options)

        self.sep = 0.25
        self.width = 1.0
        self.angle = 0.0
        self.pinLength = 0.5
        self.fg = Color(0)
        self.bg = Color(1)

        # process the options if any
        self.sep = options.get("sep", self.sep)
        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)

        pinIn = Group(
                Path( 
                    P(0, 0), 
                    P(self.pinLength, 0),
                    )
                )
        cap = Group( 
                Path(pinIn.e+P(0, -self.width/2.0), 
                    pinIn.e+P(0, self.width/2.0)), 
                Path(pinIn.e+P(self.sep, -self.width/2.0), 
                    pinIn.e+P(self.sep, self.width/2.0)),
                )
        pinOut = Path(
                cap.e, 
                cap.e+P(self.pinLength, 0))

        # group the objects together
        obj = Group(pinIn, pinOut, cap)

        # 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.c)

        # set the object to myself
        self.append(obj)
Esempio n. 4
0
    def __init__(self, **options):
        # intitialise base class
        Group.__init__(self, **options)

        self.length = 3.0
        self.width = 1.0
        self.angle = 0.0
        self.pinLength = 0.5
        self.fg = Color(0)
        self.bg = Color(1)

        # process the options if any
        self.length = options.get("length", self.length)
        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)

        pinIn = Group(
                Path( 
                    P(0, 0), 
                    P(self.pinLength, 0)
                    )
                )
        resistor = Rectangle(w=pinIn.e, width=self.length, height=self.width)
        pinOut = Path(
                resistor.e, 
                resistor.e+P(self.pinLength, 0))

        # collect the objects together
        obj = Group(pinIn, pinOut, resistor)

        # 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.c)

        # return object to myself
        self.append(obj)