def next_frame(self): self.square.clear() while (True): if one_in(self.density): start = choice(self.square.frame_cells()) dist = distance(start, self.center) length = 1 dx = (self.center[0] - start[0]) / dist dy = (self.center[1] - start[1]) / dist self.bricks.add_brick( random_color_range(self.dust_color, 0.02), 50, start, length, 1, dx, dy, dx, dy) self.draw_well() self.bricks.move_bricks(False) for b in self.bricks.get_bricks(): if distance(b.get_coord(), self.center) <= 1: self.bricks.kill_brick(b) if one_in(10): self.dust_color = random_color_range(self.dust_color, 0.02) if one_in(10): self.color = random_color_range(self.color, 0.007) if one_in(40): self.density = up_or_down(self.density, 1, 1, 4) yield self.speed
def next_frame(self): self.square.clear() while (True): self.square.black_all_cells() while len(self.rotaters) < 7: length = randint(3, 10) new_rotater = Rotater(self.square, length, 2 * (11 - length), random_color_range(self.color, 0.2), self.square.rand_cell()) self.rotaters.append(new_rotater) for r in self.rotaters: if r.rotate() == False: self.rotaters.remove(r) if one_in(30): self.color = random_color_range(self.color, 0.1) if one_in(40): self.density = up_or_down(self.density, 1, 1, 4) yield self.speed
def next_frame(self): self.square.clear() while (True): if len(self.growers) < 3 or one_in(self.density): self.growers.append( Grower(self.square, randint(3, 8), random_color_range(self.color, 0.01), self.square.rand_cell(), randint(10, 30) / 500.0, self.type)) for g in self.growers: g.draw_grower() if g.grow_grower() == False: self.growers.remove(g) if one_in(100): self.type = not self.type if one_in(100): self.color = random_color_range(self.color, 0.02) if one_in(40): self.density = up_or_down(self.density, 2, 4, 40) yield self.speed
def next_frame(self): while (True): if one_in(self.density): base_color = random_color_range(self.color, 0.05) x = randint(0, self.square.width) width = randint(2,5) for i in range(width): color = change_color(base_color, i * 0.01) self.bricks.add_brick(color, life=self.life, pos=(x+i, 0), length=self.length, pitch=1, length_x=-1, length_y=-1, dx=1, dy=1, use_faders=True, change=self.fade) self.bricks.add_brick(color, life=self.life, pos=(x+i, 0), length=self.length, pitch=1, length_x=1, length_y=-1, dx=-1, dy=1, use_faders=True, change=self.fade) self.bricks.add_brick(color, life=self.life, pos=(x+i, self.square.height), length=self.length, pitch=1, length_x=-1, length_y=1, dx=1, dy=-1, use_faders=True, change=self.fade) self.bricks.add_brick(color, life=self.life, pos=(x+i, self.square.height), length=self.length, pitch=1, length_x=1, length_y=1, dx=-1, dy=-1, use_faders=True, change=self.fade) self.bricks.move_bricks(refresh=False) # Change the colors if one_in(10): self.color = random_color_range(self.color, 0.2) if one_in(50): self.fade = up_or_down(self.fade, 1, 2, 10) if one_in(50): self.density = up_or_down(self.density, 1, 2, 10) yield self.speed # random time set in init function
def next_frame(self): self.square.clear() while (True): for x in range(self.square.width): waggle = sin(2 * pi * (self.counter % 100) / 100) waggle2 = cos(2 * pi * (self.counter % 100) / 100) y = round((sin((x + self.counter) / (self.freq1 * pi)) * waggle + 1) * (self.square.height-1) / 2) y2 = round((cos((x + self.counter) / (self.freq2 * pi)) * waggle2 + 1) * (self.square.height-1) / 2) for i in range(2): self.sparkles.add_fader(random_color_range(self.color1, 0.02), (x - i, y), 0.5, False, 0.05) self.sparkles.add_fader(random_color_range(self.color2, 0.02), (x - i, y2), 0.5, False, 0.05) self.sparkles.cycle_faders() # Change the colors if one_in(10): self.color1 = random_color_range(self.color1, 0.01) if one_in(5): self.color2 = random_color_range(self.color2, 0.01) self.counter -= 1 yield self.speed # random time set in init function
def next_frame(self): while (True): # Randomly add a center dendron if len(self.livedendrons) < 20 and one_in(5): sq = self.square.rand_square() newdendron = Dendron(self.square, sq, random_color_range(self.maincolor, 0.03), choice(self.square.edges(sq)), MAX_DIR, 0, self.longevity) self.livedendrons.append(newdendron) for d in self.livedendrons: d.draw_dendron(self.inversion) # Chance for branching if one_in(20): # Create a fork newdir = turn_left_or_right(d.dir) newdendron = Dendron(self.square, sq, d.color, d.pos, newdir, d.life, d.longevity) self.livedendrons.append(newdendron) if d.move_dendron() == False: # dendron has moved off the board self.livedendrons.remove(d) # kill the branch if one_in(20): self.maincolor = random_color_range(self.maincolor, 0.05) if one_in(100): self.inversion = randint(0, 1) # Toggle for effects if one_in(10): self.longevity = up_or_down(self.longevity, 1, 20, 100) yield self.speed
def next_frame(self): while (True): for i in range(self.density): color = dim_color(random_color_range(self.color, 0.1), 0.5) x = randint(0, self.square.width) # add_brick(self, color, life, pos, length, pitch, length_x, length_y, dx, dy, accel_x=0, accel_y=0, use_faders=False, change=0.25): self.bricks.add_brick(color, 40, pos=(x, 0), length=self.length, pitch=1, length_x=-1, length_y=-1, dx=1, dy=1) self.bricks.add_brick(color, 40, pos=(x, 0), length=self.length, pitch=1, length_x=1, length_y=-1, dx=-1, dy=1) self.bricks.add_brick(color, 40, pos=(x, self.square.height), length=self.length, pitch=1, length_x=-1, length_y=1, dx=1, dy=-1) self.bricks.add_brick(color, 40, pos=(x, self.square.height), length=self.length, pitch=1, length_x=1, length_y=1, dx=-1, dy=-1) self.bricks.move_bricks() # Change the colors if one_in(10): self.color = random_color_range(self.color, 0.2) if one_in(100): self.density = up_or_down(self.density, 1, 1, 4) if one_in(50): self.length = up_or_down(self.length, 1, 2, 10) yield self.speed # random time set in init function
def next_frame(self): self.square.clear() while (True): for i in range(self.density): L_cannon = True if one_in(2) else False color = self.color1 if L_cannon else self.color2 x_range = randint(1, 20) / 20.0 x = 0 if L_cannon else (self.square.width - 1) self.bricks.add_brick(random_color_range(color, 0.05), life=self.square.width, pos=(x, self.square.height - 3), length=0, pitch=1, length_x=0, length_y=0, dx=x_range if L_cannon else -x_range, dy=0, accel_x=0, accel_y=-self.accel / 100.0, use_faders=True, change=1.0 / self.fade) self.bricks.move_bricks() # Prevent drops from escaping off bottom of screen for b in self.bricks.get_bricks(): (x, y) = b.get_coord() if y < 0: b.set_y(0) # Change the colors if one_in(10): self.color1 = random_color_range(self.color1, 0.01) if one_in(10): self.color2 = random_color_range(self.color2, 0.02) if one_in(100): self.density = up_or_down(self.density, 1, 2, 5) if one_in(100): self.accel = up_or_down(self.accel, 1, 1, 10) if one_in(100): self.fade = up_or_down(self.fade, 1, 1, 5) yield self.speed
def next_frame(self): self.square.clear() while (True): if one_in(self.density): end = choice(self.square.frame_cells()) dist = distance(self.center, end) length = 1 dx = (end[0] - self.center[0]) / dist dy = (end[1] - self.center[1]) / dist self.bricks.add_brick(random_color_range( self.dust_color, 0.05), 200, self.center, length=length, pitch=1, length_x=dx, length_y=dy, dx=dx, dy=dy, accel_x=-dx / self.strength, accel_y=-dy / self.strength, use_faders=True, change=0.1) self.draw_well() self.bricks.move_bricks(False) for b in self.bricks.get_bricks(): if distance(b.get_coord(), self.center) <= 1 and b.get_life() < 180: self.bricks.kill_brick(b) if one_in(10): self.dust_color = random_color_range(self.dust_color, 0.02) if one_in(10): self.color = random_color_range(self.color, 0.007) if one_in(40): self.density = up_or_down(self.density, 1, 2, 10) if one_in(40): self.strength = up_or_down(self.strength, 5, 20, 50) yield self.speed
def next_frame(self): self.square.clear() while (True): for x in range(self.square.width): waggle = sin(2 * pi * self.get_fract(self.counter, self.wag_speed) ) # Up and Down motion results = -1 to +1 angle = self.freq1 * pi * self.get_fract( x + (self.counter * (self.wave_speed / 10.0)), self.square.width) y_top = ( sin(angle) * waggle + 0.9 ) * self.square.height / 2 # (-1 to 1) * (-1 to 1) + 1 = 0 to 2 for y in range(self.square.height): new_h = self.color[0] - (255 * 0.02 * abs(y - y_top)) new_color = new_h, self.color[1], self.color[2] * 0.3 self.square.set_cell((x, y), new_color) # Change the colors if one_in(10): self.color = random_color_range(self.color, 0.007) if one_in(10): self.color_x = up_or_down(self.color_x, 1, 10, 30) if waggle == 0 and one_in(10): self.freq1 = up_or_down(self.freq1, 2, 2, 8) self.counter -= 1 yield self.speed # random time set in init function
def __init__(self, hexmodel, main_color, main_bands): self.hexes = hexmodel self.color = random_color_range(main_color, 0.1) self.bands = main_bands self.center = self.hexes.rand_cell() self.size = randint(0, 5) # Random drop size self.current_size = 0
def __init__(self, hexmodel, main_color, pos=None): self.hexes = hexmodel self.color = random_color_range(main_color, 0.2) self.pos = self.hexes.rand_cell() if not pos else pos self.size = randint(5, 9) # Random ring size self.direction = helpfunc.rand_dir() self.life = randint(50, 200) # how long a ring is around
def next_frame(self): while (True): self.square.black_all_cells() for y in range(self.square.height): w = (self.min_freq + y) / float( self.cycles) # pendulum frequency x = int((cos(w * self.counter) + 1) * self.square.width / 2) self.faders.add_fader(change_color(self.color, y * self.gradient / 1500.0), (x, y), intense=1.0, growing=False, change=0.05) self.faders.cycle_faders() self.counter += 1 if self.counter % (int(2 * pi * self.cycles)) == 0: self.color = random_color_range(self.color, 0.15) self.gradient = up_or_down(self.gradient, 5, 15, 40) yield self.speed # random time set in init function
def next_frame(self): self.live_dendrons = [Dendron(hexmodel=self.hexes, color=self.main_color, pos=helpfunc.get_center(h), direction=5, life=0) for h in helpfunc.all_hexes()] while True: # Randomly add a center dendron if helpfunc.one_in(5): self.live_dendrons.append(Dendron(hexmodel=self.hexes, color=self.main_color, pos=helpfunc.get_random_center(), direction=5, life=0)) for dendron in self.live_dendrons: dendron.draw_dendron(self.inversion) if helpfunc.one_in(20): new_dir = helpfunc.turn_left_or_right(dendron.direction) self.live_dendrons.append(Dendron(hexmodel=self.hexes, color=dendron.color, pos=dendron.pos, direction=new_dir, life=dendron.life)) if not dendron.move_dendron(): # dendron has moved off the board self.live_dendrons.remove(dendron) # kill the dendron if helpfunc.one_in(10): self.main_color = random_color_range(self.main_color, 0.05) yield self.speed
def next_frame(self): self.square.clear() while (True): waggle = sin(2 * pi * self.get_fract(self.counter, self.wag_speed) ) # Up and Down motion results = -1 to +1 for x in range(self.square.width): for y in range(self.square.height): intensity = sin(float(x) / self.repeat) * cos( float(y) / self.repeat) # -1 to 1 spread = intensity * waggle # (-1 to 1) * (-1 to 1) = -1 to 1 self.square.set_cell( (x, y), dim_color( change_color(self.color, spread * MAX_COLOR / 6000.0), 0.3)) if waggle == 0 and one_in(10): self.repeat = up_or_down(self.repeat, 1, 1, 4) # Change the colors if one_in(10): self.color = random_color_range(self.color, 0.007) self.counter += 1 yield self.speed
def next_frame(self): self.square.clear() while (True): for x in range(self.square.width): waggle = sin(2 * pi * self.get_fract(self.counter, self.wag_speed)) # Up and Down motion results = -1 to +1 angle = self.freq1 * pi * self.get_fract(x + (self.counter * (self.wave_speed / 10.0)), self.square.width) y_top = (sin(angle) * waggle + 0.9) * self.square.height / 2 # (-1 to 1) * (-1 to 1) + 1 = 0 to 2 for y in range(self.square.height): self.square.set_cell((x,y), gradient_wheel(self.color, 0.8 * (1 - (0.2 * abs(y_top - y))))) # Change the colors if one_in(10): self.color = random_color_range(self.color, 0.01) if one_in(10): self.color_x = up_or_down(self.color_x, 1, 10, 30) if one_in(10) and waggle == 0: self.freq1 = up_or_down(self.freq1, 1, 1, 4) self.counter -= 1 yield self.speed # random time set in init function
def next_frame(self): self.square.clear() while (True): if one_in(self.density): angle = randint(0, 359) life = randint(50, 500) change = randint(1,5) / 10.0 symmetry = self.syms[self.sym] for i in range(symmetry): rad = 2 * 3.14159 * (angle + (i * 360 / symmetry)) / 360 self.bricks.add_brick(self.color, life=life, pos=(self.square.width // 2, self.square.height // 2), length=randint(1,4), pitch=1, length_x=sin(rad), length_y=cos(rad), dx=sin(rad), dy=cos(rad), accel_x=0, accel_y=0, use_faders=False, change=change) self.color = random_color_range(self.color, 0.1) if one_in(40): self.density = up_or_down(self.density, 1, 1, 4) if one_in(100): self.sym = up_or_down(self.sym, 1, 0, len(self.syms) - 1) self.bricks.move_bricks() yield self.speed
def __init__(self, squaremodel, max_size, color, pos, gradient): self.square = squaremodel self.size = 0 self.max_size = max_size self.color = random_color_range(color, 0.1) self.pos = pos self.gradient = gradient
def next_frame(self): self.square.clear() while (True): if len(self.growers) < 10 or one_in(self.density): pos = (randint(-self.square.height, self.square.width + self.square.height), self.square.height / 2) self.growers.append( Grower(self.square, randint(3, 8), self.color, pos, randint(10, 30) / 500.0)) for g in self.growers: g.draw_grower() if g.grow_grower() == False: self.growers.remove(g) if one_in(100): self.color = random_color_range(self.color, 0.02) if one_in(40): self.density = up_or_down(self.density, 2, 4, 40) yield self.speed
def next_frame(self): while True: self.hexes.black_all_cells() for y in range(hex.HEX_SIZE): w = (self.min_freq + y) / float( self.cycles) # pendulum frequency x = int((cos(w * self.counter) + 1) * self.width / 2) h = x // hex.HEX_SIZE hex_x = x % hex.HEX_SIZE self.faders.add_fader( change_color(self.color, y * self.gradient / 1500.0), (h, hex_x - hex.HEX_OFFSET, y - hex.HEX_OFFSET), intense=1.0, growing=False, change=0.05) self.faders.cycle_faders() self.counter += 1 if self.counter % (int(2 * pi * self.cycles)) == 0: self.color = random_color_range(self.color, 0.15) self.gradient = up_or_down(self.gradient, 5, 15, 40) yield self.speed # random time set in init function
def next_frame(self): while (True): for x in range(self.square.width): w = (self.min_freq + x) / float( self.cycles) # pendulum frequency y_top = (cos(w * self.counter) + 1) * self.square.height / 2 for y in range(self.square.height): if self.up_down: c = change_color(self.color, x * self.gradient / 1500.0) if y < y_top else self.black else: c = change_color(self.color, x * self.gradient / 1500.0) if y > y_top else self.black self.square.set_cell((x, y), dim_color(c, 0.5)) self.counter += 1 if self.counter % (int(2 * pi * self.cycles)) == 0: self.min_freq = up_or_down(self.min_freq, 1, 3, 10) self.gradient = up_or_down(self.gradient, 2, 5, 15) self.color = random_color_range(self.color, 0.007) self.up_down = not self.up_down yield self.speed # random time set in init function
def next_frame(self): self.square.clear() for i in range(self.num_grass): new_grass = Grass(self.square, random_color_range(self.color, 0.06)) self.grasses.append(new_grass) while (True): self.square.black_all_cells() self.wind = self.max_wind * sin(2 * pi * self.counter / 60) for g in self.grasses: g.draw() g.adj_bend(self.wind) if one_in(100): self.speed = up_or_down(self.speed, 0.05, 0.05, 0.5) self.counter += 1 yield self.speed
def next_frame(self): while (True): # Randomly add a center swirl if len(self.liveswirls) == 0 or one_in(30): for sq in range(self.square.num_squares): newswirl = Swirl(self.square, sq, self.maincolor, get_center(sq), rand_dir(), choice([1, 2, 4]), 0, self.longevity) self.liveswirls.append(newswirl) self.maincolor = change_color(self.maincolor, 0.02) for s in self.liveswirls: s.draw_swirl() # Chance for branching if one_in(15): # Create a fork newdir = turn_left(s.dir) # always fork left newswirl = Swirl(self.square, sq, s.color, s.pos, newdir, s.sym, s.life, s.longevity) self.liveswirls.append(newswirl) if s.move_swirl() == False: # Swirl has moved off the board self.liveswirls.remove(s) # kill the branch if one_in(20): self.longevity = up_or_down(self.longevity, 2, 40, 100) if one_in(40): self.maincolor = random_color_range(self.maincolor, 0.02) yield self.speed
def next_frame(self): while (True): # Check how many branches are in play # If no branches, add one. If branches < 10, add more branches randomly while len(self.livebranches) < 10 or one_in(10): sq = self.square.rand_square() # Pick a random Square newbranch = Branch(self.square, sq, random_color_range(self.maincolor, 0.02), choice(self.square.edges(sq)), self.maindir, 0) self.livebranches.append(newbranch) for b in self.livebranches: b.draw_branch() # Chance for branching if one_in(5): # Create a fork new_dir = turn_left_or_right(b.dir) new_branch = Branch(self.square, b.square_num, change_color(b.color, 0.03), b.pos, new_dir, b.life) self.livebranches.append(new_branch) if b.move_branch() == False: # branch has moved off the board self.livebranches.remove(b) # kill the branch # Infrequently change the dominate direction if one_in(10): self.maindir = turn_left_or_right(self.maindir) yield self.speed # random time set in init function
def __init__(self, hexmodel, maincolor): self.hexes = hexmodel self.color = random_color_range(maincolor, 30) self.pos = self.hexes.rand_cell() self.size = randint(2, 5) self.dir = rand_dir() self.life = randint(50, 200) # how long a ball is around
def next_frame(self): self.square.clear() while (True): for i in range(self.density): self.raindrops.add_brick(random_color_range(self.blue, 0.05), life=self.square.height + 2, pos=(randint(-10, 10 + self.square.width), self.square.height), length=0, pitch=1, length_x=0, length_y=-1, dx=self.wind / 10.0, dy=-1, accel_x=0, accel_y=0, use_faders=False) self.raindrops.move_bricks() if one_in(20): self.density = up_or_down(self.density, 1, 2, 10) if one_in(20): self.wind = up_or_down(self.wind, 1, -10, 10) self.raindrops.set_all_dx(self.wind / 10.0) if one_in(500): self.square.set_all_cells(rgb_to_hsv((255, 255, 100))) yield self.speed # random time set in init function
def next_frame(self): self.square.clear() for i in range(self.num_bricks): self.bricks.add_brick(random_color_range(self.color, 0.15), life=100000, pos=(self.square.rand_cell()), length=self.brick_length, pitch=0.5, length_x=1, length_y=0, dx=0, dy=0) while (True): x_angle = sin(self.a * self.counter - (pi / 2.0)) y_angle = sin(self.b * self.counter) x = int((x_angle + 1) * (self.square.width - 1) / 2.0) y = int((y_angle + 1) * (self.square.height - 1) / 2.0) self.adj_bricks((x,y)) self.bricks.move_bricks() self.square.set_cell((x, y), self.white) self.square.set_cell((x+1, y), self.white) self.square.set_cell((x, y+1), self.white) self.square.set_cell((x+1, y+1), self.white) self.counter += (0.1 / (self.a + self.b)) if self.counter > self.full_cycle: self.counter -= self.full_cycle (self.a, self.b) = choice([(1,1), (1,2), (3,2), (5,4), (3, pi/2)]) yield self.speed
def __init__(self, squaremodel, maincolor): self.square = squaremodel self.color = random_color_range(maincolor, 0.1) self.pos = self.square.rand_cell() self.size = randint(5, 8) # Random ball size self.dir = rand_dir() # Direction of ball's travel self.life = randint(50, 200) # how long a ball is around
def next_frame(self): while True: for x in range(self.width): w = (self.min_freq + x) / float( self.cycles) # pendulum frequency y_top = (cos(w * self.counter) + 1) * hex.HEX_SIZE / 2 for y in range(hex.HEX_SIZE): if self.up_down: c = change_color(self.color, x * self.gradient / 1500.0) if y < y_top else black() else: c = change_color(self.color, x * self.gradient / 1500.0) if y > y_top else black() h = x // hex.HEX_SIZE hex_x = x % hex.HEX_SIZE self.hexes.set_cell( (h, hex_x - hex.HEX_OFFSET, y - hex.HEX_OFFSET), dim_color(c, 0.5)) self.counter += 1 if self.counter % (int(2 * pi * self.cycles)) == 0: self.min_freq = up_or_down(self.min_freq, 1, 3, 10) self.gradient = up_or_down(self.gradient, 2, 5, 15) self.color = random_color_range(self.color, 0.007) self.up_down = not self.up_down yield self.speed # random time set in init function
def next_frame(self): self.square.clear() while (True): while self.sparkles.num_faders() < self.spark_num: self.sparkles.add_fader(random_color_range(self.color, 0.05), self.square.rand_cell()) self.sparkles.cycle_faders() # Change the colors if one_in(100): self.color = random_color_range(self.color, 0.1) yield self.speed