class WhiteRandomOneColor(object): def __init__(self, sheep_sides): self.name = "White Random One Color" self.sheep = sheep_sides.both self.speed = 0.1 self.color = RGB(255,255,255) # White self.panel_map = {} # Dictionary of panels: value is Panel object for cell in self.sheep.all_cells(): newpanel = Panel() self.panel_map[cell] = newpanel def next_frame(self): while True: for cell, panel in self.panel_map.iteritems(): adj_color = self.color.copy() adj_color.v = panel.intensity / 100.0 self.sheep.set_cell(cell, adj_color) panel.update_panel() yield self.speed
class Sparkle(object): def __init__(self, sheep_sides): self.name = "Sparkle" self.sheep = sheep_sides.both self.speed = 0.05 self.color = RGB(0,255,0) # set background to dim white self.background = RGB(255,255,255) self.background.v = 0.2 self.neighbor_count = None def set_param(self, name, val): # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 0xff) if name == 'colorR': self.color.r = rgb255 elif name == 'colorG': self.color.g = rgb255 elif name == 'colorB': self.color.b = rgb255 def clear(self): self.sheep.set_all_cells(self.background) def next_frame(self): while True: color = self.color.copy() start = random.choice(sheep.ALL) for i in range(random.randint(3,5)): neighbors = sheep.edge_neighbors(start) if len(neighbors) > 2: edges = random.sample(neighbors, 2) else: edges = [] self.clear() color.v = 1.0 self.sheep.set_cell(start, color) color.v = 0.8 self.sheep.set_cells(edges, color) yield self.speed self.clear() yield 1.0
class Sparkle(object): def __init__(self, sheep_sides): self.name = "Sparkle" self.sheep = sheep_sides.both self.speed = 0.05 self.color = RGB(0, 255, 0) # set background to dim white self.background = RGB(255, 255, 255) self.background.v = 0.2 self.neighbor_count = None def set_param(self, name, val): # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 0xff) if name == 'colorR': self.color.r = rgb255 elif name == 'colorG': self.color.g = rgb255 elif name == 'colorB': self.color.b = rgb255 def clear(self): self.sheep.set_all_cells(self.background) def next_frame(self): while True: color = self.color.copy() start = random.choice(sheep.ALL) for i in range(random.randint(3, 5)): neighbors = sheep.edge_neighbors(start) if len(neighbors) > 2: edges = random.sample(neighbors, 2) else: edges = [] self.clear() color.v = 1.0 self.sheep.set_cell(start, color) color.v = 0.8 self.sheep.set_cells(edges, color) yield self.speed self.clear() yield 1.0
class Neighbors(object): def __init__(self, sheep_sides): self.name = "Test neighbors" self.sheep = sheep_sides.both self.color = RGB(0, 255, 0) self.speed = 1.0 def set_param(self, name, val): # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 0xFF) if name == "colorR": self.color.r = rgb255 elif name == "colorG": self.color.g = rgb255 elif name == "colorB": self.color.b = rgb255 def next_frame(self): while True: for cellnum in sheep.ALL: self.sheep.clear() # unnecessary for it to do a go here? col = self.color.copy() # set the primary panel to the base color self.sheep.set_cell(cellnum, col) # set edge neighbors to 80% brightness col.v = 0.8 self.sheep.set_cells(sheep.edge_neighbors(cellnum), col) # set vertex neighbors to 20% brightness col.v = 0.2 self.sheep.set_cells(sheep.vertex_neighbors(cellnum), col) yield self.speed
class Neighbors(object): def __init__(self, sheep_sides): self.name = "Test neighbors" self.sheep = sheep_sides.both self.color = RGB(0, 255, 0) self.speed = 1.0 def set_param(self, name, val): # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 0xff) if name == 'colorR': self.color.r = rgb255 elif name == 'colorG': self.color.g = rgb255 elif name == 'colorB': self.color.b = rgb255 def next_frame(self): while True: for cellnum in sheep.ALL: self.sheep.clear() # unnecessary for it to do a go here? col = self.color.copy() # set the primary panel to the base color self.sheep.set_cell(cellnum, col) # set edge neighbors to 80% brightness col.v = 0.8 self.sheep.set_cells(sheep.edge_neighbors(cellnum), col) # set vertex neighbors to 20% brightness col.v = 0.2 self.sheep.set_cells(sheep.vertex_neighbors(cellnum), col) yield self.speed
class ExampleShow(object): def __init__(self, sheep_sides): self.name = "ExampleShow" # Mirror drawing to both sides of the bus. Can also # treat the two sides separately. # choices: [both, party, business] self.cells = sheep_sides.both # color to draw self.color = RGB(255, 0, 0) # number of seconds to wait between frames self.frame_delay = 1.0 def set_param(self, name, val): """ Receive a command from OSC or other external controller 'name' is the name of the value being set 'val' is a floating point number between 0.0 and 1.0 See 'doc/OSC.md' for details on the named parameters This example responds to three color sliders (corresponding to R, G and B) in the OSC controller to set the primary color of the show. RGB color values range from 0-255, so we must convert the input value. """ # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 255) if name == 'colorR': self.color.r = rgb255 elif name == 'colorG': self.color.g = rgb255 elif name == 'colorB': self.color.b = rgb255 def next_frame(self): """ Draw the next step of the animation. This is the main loop of the show. Set some pixels and then 'yield' a number to indicate how long you'd like to wait before drawing the next frame. Delay numbers are in seconds. """ while True: # clear whatever was drawn last frame self.cells.clear() # choose a random panel on the sheep panel_id = random.choice(sheep.ALL) # set the chosen panel to the current color self.cells.set_cell(panel_id, self.color) # make the neighboring panels dimmer (80% brightness) # first find out all of the neighboring panels neighbors = sheep.edge_neighbors(panel_id) # make a copy of the color so it's safe to change dim_color = self.color.copy() dim_color.v = 0.8 # then set multiple panels in one call self.cells.set_cells(neighbors, dim_color) # then wait to draw the next frame yield self.frame_delay
class ExampleShow(object): def __init__(self, sheep_sides): self.name = "ExampleShow" # Mirror drawing to both sides of the bus. Can also # treat the two sides separately. # choices: [both, party, business] self.cells = sheep_sides.both # color to draw self.color = RGB(255,0,0) # number of seconds to wait between frames self.frame_delay = 1.0 def set_param(self, name, val): """ Receive a command from OSC or other external controller 'name' is the name of the value being set 'val' is a floating point number between 0.0 and 1.0 See 'doc/OSC.md' for details on the named parameters This example responds to three color sliders (corresponding to R, G and B) in the OSC controller to set the primary color of the show. RGB color values range from 0-255, so we must convert the input value. """ # name will be 'colorR', 'colorG', 'colorB' rgb255 = int(val * 255) if name == 'colorR': self.color.r = rgb255 elif name == 'colorG': self.color.g = rgb255 elif name == 'colorB': self.color.b = rgb255 def next_frame(self): """ Draw the next step of the animation. This is the main loop of the show. Set some pixels and then 'yield' a number to indicate how long you'd like to wait before drawing the next frame. Delay numbers are in seconds. """ while True: # clear whatever was drawn last frame self.cells.clear() # choose a random panel on the sheep panel_id = random.choice(sheep.ALL) # set the chosen panel to the current color self.cells.set_cell(panel_id, self.color) # make the neighboring panels dimmer (80% brightness) # first find out all of the neighboring panels neighbors = sheep.edge_neighbors(panel_id) # make a copy of the color so it's safe to change dim_color = self.color.copy() dim_color.v = 0.8 # then set multiple panels in one call self.cells.set_cells(neighbors, dim_color) # then wait to draw the next frame yield self.frame_delay