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
#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):
################# # VARIABLES # ################# DEBUG = 0 # 0/1, gives more program feedback ip = "127.0.0.1" # receiving osc from port = 9125 MAX_BRIGHTNESS = [1024.0] # max intensity of any color value MIN_BRIGHTNESS = [102.4] # min intensity of any color value NUMBER_OF_LIGHTS = 48 default_color = [(102.4, 102.4, 102.4)] # dim white light canvas = default_color * NUMBER_OF_LIGHTS # this gets sent to chroma default_orb = [-1, -1, -1, -1] # [orbID, distance, hue, canvasID] orbs = [default_orb] * NUMBER_OF_LIGHTS # this stores orb data map_IDs = [-1] * NUMBER_OF_LIGHTS # maps from orbID to canvasID out = FadeAnimation() ################# # MAIN # ################# def run(): # SETUP # resetCanvas() import time out.FADERATE = 8 # fade rate, currently broken? out.start() # OSC SERVER/HANDLERS # initOSCServer(ip, port) # setup OSC server setOSCHandler('/reset', reset) # resets the visualization
#!/usr/bin/env python import sys, random from animations import FadeAnimation red = (1023.0,0.0,0.0) white = (1023.0,1023.0,1023.0) blue = (0.0,0.0,1023.0) flag = [white, red, white, blue, blue, blue, white, red, white, blue, blue, blue, white, red, white, blue, blue, blue, white, red, white, blue, blue, blue, white, red, white, red, white, red, white, red, white, red, white, red, white, red, white, red, white, red, white, red, white, red, white, red] if __name__ == "__main__": import time out = FadeAnimation() out.start() while True: out.write(flag) time.sleep(1.0)
#!/usr/bin/env python import sys, random sys.path.append("./osc") from animations import FadeAnimation if __name__ == "__main__": import time out = FadeAnimation() out.start() n = 0 direction = 1 while True: pix = [] alive = 0 if n == 3: direction = -1 elif n == 0: direction = 1 for i in xrange(6): for j in xrange(4): if j == n: pix.append((1023.0, 0.0, 0.0)) else: pix.append((0.0, 0.0, 0.0)) out.write(pix) time.sleep(0.3) n += direction
import sys from random import randint, gammavariate from animations import FadeAnimation from math import sin, radians, degrees from colorsys import hsv_to_rgb speed = 40.0 light_count = 48 def randomness(): return 1. if randint(1, 9 * 15 * 5) != 1 else 2 if __name__ == "__main__": import time out = FadeAnimation() out.FADERATE = 1.0 # seconds out.start() counter = 0.0 while True: pix = [(0.0, 0.0, 0.0)] * light_count for i in range(9): for j in range(16): r = randomness() rgb = hsv_to_rgb( (sin(radians(counter) / 2.0 + float(i) / 6.0) + 1.0) / 6.0, 1.0, 1.0) pix[i * 4 + j] = (rgb[0] * 1023.0, rgb[1] * 1023.0 / r, rgb[2] * 1023.0 / r)
def init(): for i in range(-3,10): for j in range(-3,10): if random.random() < 0.5: board[(i,j)] = 1 else: board[(i,j)] = 0 if __name__ == "__main__": import time init() out = FadeAnimation() out.start() twoback = {} oldpix = {} while True: pix = [] alive = 0 for i in xrange(6): for j in xrange(8): if board[(i,j)] > 0: pix.append((1023.0,0.0,0.0)) alive += 1 else: pix.append((0.0,0.0,1023.0)) out.write(pix) update()
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
import sys from animations import FadeAnimation from math import sin, radians, degrees from colorsys import hsv_to_rgb speed = 2.0 if __name__ == "__main__": import time out = FadeAnimation() out.FADERATE = 1.0 # seconds out.start() counter = 0 red = (1024*0.9, 1024*0.1, 1024*0.1) orange = (1024*0.9, 1024*0.4, 1024*0.1) yellow = (1024*0.8, 1024*0.8, 1024*0.1) green = (1024*0.2, 1024*0.6, 1024*0.2) blue = (1024*0.2, 1024*0.2, 1024*0.7) purple = (1024*0.6, 1024*0.1, 1024*0.6) while True: pix = [(0.0,0.0,0.0)]*48 if counter ==0: pix[0] = purple pix[6] = purple pix[12] = purple pix[18] = purple pix[24] = purple pix[30] = purple
import sys sys.path.append("./osc") from animations import FadeAnimation if __name__ == "__main__": import time out = FadeAnimation() out.FADERATE = 32.0 out.start() pix = [(1023.0, 1023.0, 1023.0)] * 48 path = [ 0, 1, 2, 3, 4, 5, 11, 17, 23, 29, 35, 41, 47, 46, 45, 44, 43, 42, 36, 30, 24, 18, 12, 6 ] sleeptime = 0.02 counter = 1 while True: for i in range(len(path)): counter = counter + 1 pix[path[i]] = (1023.0, 0.0, 0.0) pix[path[i - 1]] = (511.5, 511.5, 0.0) pix[path[i - 2]] = (0.0, 1023.0, 0.0) pix[path[i - 3]] = (0.0, 511.5, 511.5) pix[path[i - 4]] = (0.0, 0.0, 1023.0) pix[path[i - 5]] = (511.5, 0.0, 511.5) pix[path[i - 6]] = (1023.0, 1023.0, 1023.0) out.write(pix) sleeptime = sleeptime + 0.002
red = (1023.0, 0.0, 0.0) blue = (0.0, 0.0, 1023.0) orange = (1023.0, 511.5, 0.0) yellow = (1023.0, 1023.0, 0.0) purple = (1023.0, 0.0, 1023.0) teal = (511.5, 1023.0, 1023.0) pixels = [ black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black, black ] out = FadeAnimation() def pushcolor(color): time.sleep(1.0) pixels[0] = color out.write(pixels) time.sleep(1.0) random.shuffle(pixels) pixels[0] = black out.write(pixels) if __name__ == "__main__": password = "******" out.start()
import sys from animations import FadeAnimation if __name__ == "__main__": import time import random stepDelay = 0.7 stepFadeRate = 8 fadeFadeRate = 20 out = FadeAnimation() out.FADERATE = stepFadeRate out.start() pix = [(0.0,0.0,0.0)]*24 colors = [(700.,0.,0.), (0.,700.,0.), (0.,0.,700.), (700.,700.,0.), (700.,0.,700.), (0.,700.,700.) ] path = [0,1,2,3,7,11,15,14,13,12,8,4,5,6,10,9] randOrder = random.sample(colors,len(colors)) orderCount=0 while True: for i in xrange(16):
from math import sqrt from animations import FadeAnimation import requests from PIL import Image from StringIO import StringIO from time import sleep from collections import namedtuple Color = namedtuple("Color", ["r", "g", "b"]) # author: Harsh Singh light_count = 48 rows = 8 cols = 6 out = FadeAnimation() out.FADEINRATE = 2 # optional out.FADEOUTRATE = 8 # optional, makes things 'trail off' out.start() pix = [(1023.0, 0.0, 0.0)] * light_count class ImagePoint(object): """docstring for Point""" def __init__(t, size, rows, cols, x=0, y=0): super(ImagePoint, t).__init__() t.x = x t.y = y t.rows = rows t.cols = cols t.size_x, t.size_y = size t.done = False
def init(): for i in range(-3,10): for j in range(-3,10): if random.random() < 0.5: board[(i,j)] = 1 else: board[(i,j)] = 0 if __name__ == "__main__": import time init() out = FadeAnimation() out.start() twoback = {} oldpix = {} while True: pix = [] alive = 0 for i in xrange(6): for j in xrange(4): if board[(i,j)] > 0: pix.append((1023.0,0.0,0.0)) alive += 1 else: pix.append((0.0,0.0,1023.0)) out.write(pix) update()
import sys sys.path.append("./osc") from animations import FadeAnimation if __name__ == "__main__": import time import random stepDelay = 0.7 stepFadeRate = 8 fadeFadeRate = 20 out = FadeAnimation() out.FADERATE = stepFadeRate out.start() pix = [(0.0,0.0,0.0)]*24 colors = [(700.,0.,0.), (0.,700.,0.), (0.,0.,700.), (700.,700.,0.), (700.,0.,700.), (0.,700.,700.) ] path = [0,1,2,3,7,11,15,14,13,12,8,4,5,6,10,9] randOrder = random.sample(colors,len(colors)) orderCount=0 while True:
import time from animations import FadeAnimation import operator #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)] out = FadeAnimation() out.start() rev_sleep_time = .2 frame_sleep_time = .7 def frame1(): randColor = random.sample(nice_pixels,3) lastColor = randColor[2] for x in range(0,4): mycol = transition_color(randColor[0],randColor[1],x,4) for i in range(0,4): for j in range(0,4): if ((i == x and j <= x) or (i< x and j == x)): layout[i][j] = mycol out.write(makeLayout(layout))
import pyaudio # from http://people.csail.mit.edu/hubert/pyaudio/ import numpy # from http://numpy.scipy.org/ import audioop import sys import math import struct from oscapi import ColorsOut from animations import FadeAnimation chunk = 2**11 # Change if too fast/slow, never less than 2**11 scale = 50 # Change if too dim/bright exponent = 9 # Change if too little/too much difference between loud and quiet sounds samplerate = 44100 MAX = 48 out = FadeAnimation() out.FADEINRATE = 2.0 #optional out.FADEOUTRATE = 4.0 #optional, makes things 'trail off' out.start() def list_devices(): # List all audio input devices p = pyaudio.PyAudio() i = 0 n = p.get_device_count() while i < n: dev = p.get_device_info_by_index(i) if dev['maxInputChannels'] > 0: print str(i)+'. '+dev['name'] i += 1
else: cloud = 0.4 if conditions.find("Heavy") > -1: severe = 0.02 elif conditions.find("Light") > -1: severe = 0.2 else: severe = 0.05 i = 0 count = 0 print temp + "F" print conditions if __name__ == "__main__": import time out = FadeAnimation() pix = [(0.0,0.0,0.0)] * 24 out.FADERATE = 10.0 out.start() while True: #Rain if conditions.find("Rain") > -1: if random.randint(0,5) < 3: pix[random.randint(0,23)] = (0.0,0.0,1023.0) out.write(pix) for i in xrange(24): if pix[i][2] > 0.0: pix[i] = (0.0,0.0,pix[i][2] - 50.0) else: pix[i] = (0.0,0.0,0.0)
black, black, black, black, black, black, black, black, black, black, black, black, black, ] out = FadeAnimation() def pushcolor(color): time.sleep(1.0) pixels[0] = color out.write(pixels) time.sleep(1.0) random.shuffle(pixels) pixels[0] = black out.write(pixels) if __name__ == "__main__": password = "******" out.start()