Пример #1
0
def next_animation():
    global current_animations, animation_index, ms_since_last_change
    if animation_index == 0:
        current_animations = [FadeAnimation(polygon) for polygon in polygons]
    elif animation_index == 1:
        current_animations = [
            ChangingColorsAnimation(polygon,
                                    flash_with_volume=True,
                                    change_size_with_volume=False)
            for i, polygon in enumerate(polygons)
        ]
    elif animation_index == 2:
        current_animations = [
            MovingBarAnimation(polygon, fill_below=True)
            for i, polygon in enumerate(polygons)
        ]
    elif animation_index == 3:
        current_animations = [
            EdgeAnimation(polygon,
                          velocity=10,
                          reverse=np.random.choice([True, False]))
            for polygon in polygons
        ]
    elif animation_index == 4:
        current_animations = [
            ShootingBallsAnimation(polygon, which_volume='all')
            for i, polygon in enumerate(polygons)
        ]
    elif animation_index == 5:
        current_animations = [RedBlueAnimation(polygons, velocity=0.5)]
    animation_index += 1
    if animation_index > 5:
        animation_index = 0
    ms_since_last_change = 0
Пример #2
0
    MAX_Y = 8
    tailsize = 4  #Size of ping-pong ball's tail
    speed = 15.  #Speed of the Ball

    green_x = 0  #The Ball starts at (0,0) going bottom-right
    green_y = 0
    green_dir_x = 1
    green_dir_y = 1

    off = (0.0, 0.0, 0.0)  #We define three states the lights can be in
    half = (0.0, 512.0, 0.0)
    green = (0.0, 1023.0, 0.0)
    pix = []  #Set up data structures that hold light information
    x_vals = Queue(maxsize=tailsize)
    y_vals = Queue(maxsize=tailsize)
    out = FadeAnimation()  #Set up the fade animation
    out.FADERATE = 1.0
    out.start()

    for i in range(MAX_X * MAX_Y):
        pix.append(off)  #Turns Off all Lights
    x_vals.put(green_x)  #Put the first light on the array and turns it on
    y_vals.put(green_y)
    pix[(green_y * MAX_X) + green_x] = green
    out.write(pix)

    while True:
        time.sleep(1 / speed)  #Sleeps to keep the animation running at speed

        green_dir_x = check_speed(green_x, green_dir_x,
                                  MAX_X)  #Find the next direction we're going
Пример #3
0
#author: Harsh Singh
nice_pixels = [
    (1023.0,0.0,0.0),
    (0.0,1023.0,0.0),
    (0.0,0.0,1023.0),
    (0.0,1023.0,1023.0),
    (1023.0,0.,1023.0),
    (1023.0,1023.0,0.)  
]
bgColor=(0.0,0.0,0.0)
layout = [[bgColor for col in range(4)] for row in range(4)]
randColor = random.sample(nice_pixels,6)
bool_layout = [[True for col in range(4)] for row in range(4)]
max_x = 3

out = FadeAnimation()
out.start()
frame_sleep_time = .05

def makeX(col1, col2, col3):
    for x in xrange(4):
        for y in xrange(4):
            if (x==y or x==max_x-y):
                if x <= 1:
                    layout[x][y] = col1
                else:
                    layout[x][y] = col2
            else:
                layout[x][y] = col3

def makeX2(col1, col2, col3):