예제 #1
0
def make_cat(cat_location, screensize, border):
    # Get the cat again!
    files = list()
    for x in os.listdir("pictures"):
        if x not in ("README", "CVS", ".svn"):
            files.append(x)

    image_location = files[random.randint(0, len(files) - 1)]

    cat_surface = pygame.image.load("pictures/" + image_location)
    cat = cat_surface.convert()
    cat.set_colorkey((255, 255, 255), pygame.RLEACCEL)

    rotation_speed = randomFromRangeExcludingZero(-2, 2)
    scale_speed = float(randomFromRangeExcludingZero(-1, 1))
    position = list((random.randint(border, screensize[0] - border),
                     random.randint(border, screensize[1] - border)))

    newCat = BasicSprite(image=cat)

    X = Graphline(newCat=newCat,
                  rotator=loopingCounter(rotation_speed),
                  translation=cartesianPingPong(position, screensize[0],
                                                screensize[1], border),
                  scaler=bouncingFloat(scale_speed),
                  imaging=continuousIdentity(cat),
                  shutdown_fanout=Fanout([
                      "rotator", "translation", "scaler", "imaging",
                      "self_shutdown"
                  ]),
                  linkages={
                      ("rotator", "outbox"): ("newCat", "rotator"),
                      ("translation", "outbox"): ("newCat", "translation"),
                      ("scaler", "outbox"): ("newCat", "scaler"),
                      ("imaging", "outbox"): ("newCat", "imaging"),
                      ("newCat", "signal"): ("shutdown_fanout", "inbox"),
                      ("shutdown_fanout", "rotator"): ("rotator", "control"),
                      ("shutdown_fanout", "translation"):
                      ("translation", "control"),
                      ("shutdown_fanout", "scaler"): ("scaler", "control"),
                      ("shutdown_fanout", "imaging"): ("imaging", "control"),
                      ("shutdown_fanout", "self_shutdown"):
                      ("shutdown_fanout", "control"),
                  }).activate()

    return newCat
예제 #2
0
def make_cat(cat_location, screensize, border):
    # Get the cat again!
    files = list()
    for x in os.listdir("pictures"):
        if x not in ("README", "CVS", ".svn"):
            files.append(x)

    image_location = files[random.randint(0, len(files) - 1)]

    cat_surface = pygame.image.load("pictures/" + image_location)
    cat = cat_surface.convert()
    cat.set_colorkey((255, 255, 255), pygame.RLEACCEL)

    rotation_speed = randomFromRangeExcludingZero(-2, 2)
    scale_speed = float(randomFromRangeExcludingZero(-1, 1))
    position = list((random.randint(border, screensize[0] - border), random.randint(border, screensize[1] - border)))

    newCat = CatSprite(image=cat)
    newCat.activate()  # to register it with the sprite scheduler, this is a hack.

    X = Graphline(
        newCat=newCat,
        rotator=loopingCounter(rotation_speed),
        translation=cartesianPingPong(position, screensize[0], screensize[1], border),
        scaler=bouncingFloat(scale_speed),
        imaging=continuousIdentity(cat),
        shutdown_fanout=Fanout(["rotator", "translation", "scaler", "imaging", "self_shutdown"]),
        linkages={
            ("self", "inbox"): ("newCat", "inbox"),
            ("rotator", "outbox"): ("newCat", "rotator"),
            ("translation", "outbox"): ("newCat", "translation"),
            ("scaler", "outbox"): ("newCat", "scaler"),
            ("imaging", "outbox"): ("newCat", "imaging"),
            ("newCat", "signal"): ("shutdown_fanout", "inbox"),
            ("shutdown_fanout", "rotator"): ("rotator", "control"),
            ("shutdown_fanout", "translation"): ("translation", "control"),
            ("shutdown_fanout", "scaler"): ("scaler", "control"),
            ("shutdown_fanout", "imaging"): ("imaging", "control"),
            ("shutdown_fanout", "self_shutdown"): ("shutdown_fanout", "control"),
        },
    )
    return X
예제 #3
0
def main():
    # app = QtGui.QApplication(sys.argv)
    #myapp = MyForm(device_id=3)
    #myapp.show()
    #sys.exit(app.exec_())
    #
    #Pipe = Pipeline(CVCamera(),
    #                 #ColorFilter(settings=(100, 100, 100, 100, 100)),
    #                 Matelight()
    #).activate()

    MidiPipe = Graphline(
        CAM=CVCamera(),
        ML=Matelight(),
        MI=MidiInput(5),
        MR=MidiRouter({
            2: 'red',
            3: 'green',
            4: 'blue',
            14: 'brightness',
            15: 'gamma'
        }),
        LC=loopingCounter(1, 127),
        CF=ColorFilter(),
        CE=ConsoleEchoer(),
        linkages={
            ("MI", "outbox"): ("MR", "inbox"),
            #("MR", "red"): ("CF", "red"),
            ("LC", "outbox"): ("CF", "red"),
            ("MR", "green"): ("CF", "green"),
            ("MR", "blue"): ("CF", "blue"),
            ("MR", "brightness"): ("CF", "brightness"),
            ("MR", "gamma"): ("CF", "gamma"),
            ("CAM", "outbox"): ("CF", "inbox"),
            ("CF", "outbox"): ("ML", "inbox")
        }).activate()

    scheduler.run.runThreads()
예제 #4
0
파일: matejockey.py 프로젝트: ri0t/avio
def main():
    # app = QtGui.QApplication(sys.argv)
    #myapp = MyForm(device_id=3)
    #myapp.show()
    #sys.exit(app.exec_())
    #
    #Pipe = Pipeline(CVCamera(),
    #                 #ColorFilter(settings=(100, 100, 100, 100, 100)),
    #                 Matelight()
    #).activate()

    MidiPipe = Graphline(CAM=CVCamera(),
                         ML=Matelight(),
                         MI=MidiInput(5),
                         MR=MidiRouter({2: 'red',
                                        3: 'green',
                                        4: 'blue',
                                        14: 'brightness',
                                        15: 'gamma'}
                         ),
                         LC=loopingCounter(1,127),
                         CF=ColorFilter(),
                         CE=ConsoleEchoer(),
                         linkages={
                             ("MI", "outbox"): ("MR", "inbox"),
                             #("MR", "red"): ("CF", "red"),
                             ("LC", "outbox"): ("CF", "red"),
                             ("MR", "green"): ("CF", "green"),
                             ("MR", "blue"): ("CF", "blue"),
                             ("MR", "brightness"): ("CF", "brightness"),
                             ("MR", "gamma"): ("CF", "gamma"),
                             ("CAM", "outbox"): ("CF", "inbox"),
                             ("CF", "outbox"): ("ML", "inbox")
                         }
    ).activate()

    scheduler.run.runThreads()