Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    def next_frame(self):

        for i in range(0, 1000):  # number of steps per game

            # Calculate each hex's fate
            for cell in self.life_hexes.life_map:
                self.life_hexes.decide_fate(cell)

            # Push all at once the new fates into current state
            for cell in self.life_hexes.life_map:
                self.life_hexes.get(cell).push_state()

            # Draw the actual hexes, but only the ones in the display
            for cell in self.hexes.cellmap.keys():
                mapped_cell = self.life_hexes.get(cell)
                if mapped_cell:
                    color = self.on_color if mapped_cell.is_alive(
                    ) else self.off_color
                    self.hexes.set_cell(cell, color)

            # Slowly change the colors
            if helpfunc.one_in(10):
                self.on_color = change_color(self.on_color, 0.1)

            if helpfunc.one_in(5):
                if self.off_color != black():  # Black - keep as black
                    self.off_color = change_color(self.off_color, -0.05)

            yield self.speed  # random time set in init function
Ejemplo n.º 4
0
 def input(self, key):
     """
     キー入力
     """
     if key == "space":
         # ポーズ
         self.can_drop = not self.can_drop
     elif key == "Escape":
         self.reset()
         self.game.reset()
     elif key == "c":
         change_color()
     elif key == "w":
         print("Input: HOLD")
         self.hold()
     elif key == "e":
         print("Input: ROTATE:e")
         # 回転
         self.__rotate(clockwise=True)
     elif key == "q":
         print("Input: ROTATE:q")
         # 回転
         self.__rotate(clockwise=False)
     elif key == "a" and not self.__is_collision_left():
         # 移動 左
         self.block.pos_x -= 1
     elif key == "s":
         # ハードドロップ
         self.__hard_drop()
     elif key == "d" and not self.__is_collision_right():
         # 移動 右
         self.block.pos_x += 1
Ejemplo n.º 5
0
    def next_frame(self):

        while True:

            # Randomly fire a bullet
            for h in helpfunc.all_hexes():
                spin_center = (h, 4, 0)
                self.bullets.append(Bullet(hexmodel=self.hexes, color=self.spincolor,
                                           pos=choice(self.mirror_hexes(spin_center))))
                self.draw_background()
                self.draw_spinners(spin_center)

                # Draw the bullets
                for bullet in self.bullets:
                    if not bullet.move_bullet():	# bullet has moved off the board
                        self.bullets.remove(bullet)	# kill the bullet

                self.time += 1

                # Random move the spin centers

                if helpfunc.one_in(10):
                    new_spot = choice(helpfunc.hex_ring(spin_center, 1))
                    if self.hexes.cell_exists(choice(helpfunc.hex_ring(spin_center, 1))):
                        spin_center = new_spot

            # Change the colors
            self.background = change_color(self.background, 0.05)
            self.spincolor = change_color(self.background, -0.1)

            yield self.speed  	# random time set in init function
Ejemplo n.º 6
0
    def next_frame(self):

        self.square.clear()

        while (True):

            if self.counter % self.density == 0:
                color1 = change_color(self.color1, self.inc * 5 / 1500.0)
                color2 = change_color(self.color2, self.inc * 5 / 1500.0)
                dx = self.inc / 100.0
                dy = 1.0 - dx

                self.bricks.add_brick(color1,
                                      life=200,
                                      pos=(0, self.square.height - 1),
                                      length=0,
                                      pitch=1,
                                      length_x=0,
                                      length_y=0,
                                      dx=dx,
                                      dy=dy,
                                      accel_x=0,
                                      accel_y=0,
                                      use_faders=True,
                                      change=0.4)

                self.bricks.add_brick(color2,
                                      life=1000,
                                      pos=(self.square.width - 1,
                                           self.square.height - 1),
                                      length=0,
                                      pitch=1,
                                      length_x=0,
                                      length_y=0,
                                      dx=-dx,
                                      dy=dy,
                                      accel_x=0,
                                      accel_y=0,
                                      use_faders=True,
                                      change=0.2)

                self.inc = (self.inc + 1) % 100

            self.bricks.move_bricks()

            self.counter += 1

            yield self.speed  # random time set in init function
Ejemplo n.º 7
0
    def next_frame(self):

        self.ripples = [Ripple(self.hexes, h) for h in helpfunc.all_hexes()]

        while True:

            # Check how many rips are in play
            # If no rips, add one. If rips < 6 then add one more randomly
            if len(self.ripples) < 6 * helpfunc.NUM_HEXES and helpfunc.one_in(
                    20):
                self.ripples.append(Ripple(self.hexes))

            for ripple in self.ripples:
                ripple.draw(self.color, self.time, self.width)

            # Slowly change the colors
            if helpfunc.one_in(10):
                self.color = change_color(self.color, 0.07)

            # Decrease the life of each ripple - kill a ripple if life is zero
            for ripple in self.ripples:
                if not ripple.decrease_time():
                    self.ripples.remove(ripple)

            self.time += 1

            yield self.speed  # random time set in init function
Ejemplo n.º 8
0
    def next_frame(self):

        self.sparkles = [
            Sparkle(self.hexes, pos=self.hexes.rand_cell(), color=self.color)
            for _ in range(self.spark_num)
        ]

        while True:

            while len(self.sparkles) < self.spark_num:
                self.sparkles.append(
                    Sparkle(self.hexes,
                            pos=self.hexes.rand_cell(),
                            color=self.color))

            self.hexes.black_all_cells()

            # Draw the sparkles
            for sparkle in self.sparkles:
                sparkle.draw_sparkle()
                if not sparkle.fade_sparkle():
                    self.sparkles.remove(sparkle)

            if helpfunc.one_in(5):
                self.color = change_color(self.color, 0.02)

            yield self.speed  # random time set in init function
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
    def next_frame(self):

        while (True):

            before_cells = [
                k for k, v in self.cellmap.iteritems() if v == True
            ]

            self.check_life()

            after_cells = [k for k, v in self.cellmap.iteritems() if v == True]

            if self.counter % 400 == 0 or \
              (len(before_cells) == len(after_cells) and len(before_cells) < 10 * self.square.squares): # Have cells changed?
                self.square.clear()
                self.color = random_color()
                for i in range(randint(self.min_start, self.max_start)):
                    self.light_square(choice(self.cellmap.keys()))
                yield self.speed

            self.counter += 1
            self.color = change_color(self.color, 0.02)

            if one_in(200):
                self.speed = up_or_down(self.speed, 0.1, 0.2, 2.0)

            yield self.speed
Ejemplo n.º 12
0
	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
Ejemplo n.º 13
0
    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
Ejemplo n.º 14
0
    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
Ejemplo n.º 15
0
    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
Ejemplo n.º 16
0
 def __init__(self, squaremodel):
     self.name = "BounceCannons"
     self.square = squaremodel
     self.bricks = Bricks(squaremodel, bounce=True)
     self.speed = 0.01
     self.color1 = rand_color()
     self.color2 = change_color(self.color1, 0.5)
     self.density = randint(20, 50)
Ejemplo n.º 17
0
 def draw_drop(self):
     if self.current_size == 0:  # just draw the center
         self.hexes.set_cell(self.center, self.color)
     else:
         self.hexes.set_cells(
             helpfunc.hex_ring(self.center, self.current_size),
             change_color(self.color,
                          0.008 * self.current_size * self.bands))
Ejemplo n.º 18
0
 def __init__(self, squaremodel):
     self.name = "BounceCannons2"
     self.square = squaremodel
     self.bricks = Bricks(squaremodel)
     self.speed = 0.05
     self.color1 = rand_color()
     self.color2 = change_color(self.color1, 0.5)
     self.density = randint(1, 5)
     self.length = randint(1, 10)
Ejemplo n.º 19
0
 def __init__(self, squaremodel):
     self.name = "Waterfall"
     self.square = squaremodel
     self.bricks = Bricks(squaremodel, bounce=False)
     self.speed = 0.1
     self.color1 = rand_color()
     self.color2 = change_color(self.color1, 0.5)
     self.density = randint(2, 5)
     self.accel = randint(1, 10)
     self.fade = randint(1, 5)
Ejemplo n.º 20
0
 def __init__(self, squaremodel):
     self.name = "WavePendulum"
     self.square = squaremodel
     self.speed = 0.05
     self.counter = 0
     self.background = rand_color()
     self.color = change_color(self.background, 0.5)
     self.min_freq = 10  # fastest pendulum does this many cycles in one loop
     self.cycle_time = 5  # speed of one cycle
     self.cycles = int(self.cycle_time / self.speed)
     self.gradient = 3
Ejemplo n.º 21
0
    def next_frame(self):

        # self.square.clear()

        while (True):
            for x in range(self.square.width):
                for y in range(self.square.height):
                    color = change_color(self.color1, -y *
                                         0.02) if x % 2 else change_color(
                                             self.color2, y * 0.02)
                    self.square.set_cell((x, y), dim_color(color, 0.33))

            # Change the colors
            if one_in(10):
                self.color1 = change_color(self.color1, 0.007)

            if one_in(2):
                self.color2 = change_color(self.color2, -0.007)

            yield self.speed  # random time set in init function
Ejemplo n.º 22
0
    def draw_rotater(self):
        for l in range(self.length):
            for i in range(self.sym):
                rad = 2 * 3.14159 * (self.angle + (i * 360 / self.sym)) / 360
                pos = (round(self.pos[0] + (sin(rad) * l)),
                       round(self.pos[1] + (cos(rad) * l)))
                self.faders.add_fader(change_color(self.color, l * 0.01),
                                      pos,
                                      intense=0.8,
                                      growing=False,
                                      change=self.change)

        self.faders.cycle_faders(False)
Ejemplo n.º 23
0
    def next_frame(self):

        self.set_up_spinners()

        while True:

            # Draw the spinners - draw exploding spinners last

            for s in self.spinners:
                s.draw_spinner(self.spincolor, self.explode_color, self.time)
                if not s.is_resting():
                    s.move_spinner()

            # Explode a spinner
            if self.all_resting() and helpfunc.one_in(5):
                choice(self.spinners).explode_spinner()

            # Change the colors
            self.explode_color = change_color(self.explode_color, 0.05)
            self.spincolor = change_color(self.spincolor, -0.01)

            self.time += 1

            yield self.speed  # random time set in init function
Ejemplo n.º 24
0
    def next_frame(self):

        while True:

            self.hexes.set_all_cells(dim_color(self.background, 0.3))

            for x in range(hex.NUM_HEXES * hex.HEX_SIZE):

                w = (self.min_freq + x) / float(self.cycles)  # pendulum frequency
                y = int((cos(w * self.counter) + 1) * hex.HEX_SIZE / 2)
                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),
                                    change_color(self.color, y * self.gradient / 1500.0))

            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, 1, 0, 10)
                self.color = change_color(self.color, 0.15)
                self.background = random_color_range(self.background, 0.015)

            yield self.speed
Ejemplo n.º 25
0
    def next_frame(self):

        while (True):

            self.square.set_all_cells(dim_color(self.background, 0.3))

            for x in range(self.square.width):

                w = (self.min_freq + x) / float(
                    self.cycles)  # pendulum frequency
                y = int((cos(w * self.counter) + 1) * self.square.height / 2)

                self.square.set_cell((x, y),
                                     change_color(self.color,
                                                  y * self.gradient / 1500.0))

            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, 1, 0, 10)
                self.color = change_color(self.color, 0.15)
                self.background = random_color_range(self.background, 0.015)

            yield self.speed
Ejemplo n.º 26
0
    def next_frame(self):

        while True:

            # Check how many snakes are in play
            # If no snakes, add one. Otherwise if snakes < 4, add more snakes randomly
            if not self.live_snakes or helpfunc.one_in(10):
                start_pos = self.snakemap.pick_open_hex()
                if start_pos:  # Found a valid starting position
                    self.next_snake_id += 1
                    self.main_color = change_color(self.main_color, 0.1)
                    self.snakemap.put_snake_value(start_pos,
                                                  self.next_snake_id)
                    new_snake = Snake(self.hexes, self.main_color,
                                      self.next_snake_id, start_pos)
                    self.live_snakes[self.next_snake_id] = new_snake

            for id, snake in self.live_snakes.items():
                if snake.alive:
                    snake.draw_snake()  # Draw the snake head

                    # Try to move the snake
                    next_pos = helpfunc.hex_in_direction(
                        snake.pos, snake.direction
                    )  # Get the coord of where the snake will go
                    if self.snakemap.is_open_hex(
                            next_pos):  # Is the new spot open?
                        snake.pos = next_pos  # Yes, update snake position
                        self.snakemap.put_snake_value(
                            snake.pos, snake.snakeID
                        )  # Put snake on the virtual snake map
                    else:
                        dirs = self.snakemap.get_valid_directions(
                            snake.pos)  # Blocked, check possible directions

                        if dirs:  # Are there other places to go?
                            snake.direction = choice(
                                dirs)  # Yes, pick a random new direction
                            snake.pos = helpfunc.hex_in_direction(
                                snake.pos, snake.direction)
                            self.snakemap.put_snake_value(
                                snake.pos, snake.snakeID)
                        else:  # No directions available
                            snake.alive = False  # Kill the snake
                            self.snakemap.remove_snake_path(
                                snake.snakeID)  # Snake is killed

            yield self.speed  # random time set in init function
Ejemplo n.º 27
0
    def draw(self):

        # Draw the center hex - Not included in the ring model
        x = self.gauss(self.a, self.c, 0)
        self.hexes.set_cell(self.pos, gradient_wheel(self.color, 1 + x))

        # Draw the rings
        for i in range(
                0, 15):  # total number of rings - can be bigger than display
            x = self.gauss(self.a, self.c, i + 1)
            self.hexes.set_cells(helpfunc.hex_ring(self.pos, i),
                                 gradient_wheel(self.color, 1 + x))

        self.time = (self.time + 16) % 720
        self.a = sin(radians(self.time))

        if helpfunc.one_in(8):
            self.color = change_color(self.color, 0.02)
Ejemplo n.º 28
0
    def next_frame(self):

        while True:

            if self.time == 0:
                self.pos = self.get_pin_centers(randint(3, 10))
                self.c = randint(2, 5)  # Width of well

            self.hexes.set_all_cells(self.color)

            # Draw the rings
            for ring in range(
                    12, 0,
                    -1):  # total number of rings - can be bigger than display
                for center in self.pos:
                    h, x, y, = center
                    x = self.gauss(self.a, self.c, ring + 1, h)
                    atten = 1 + x if x < 0 else x
                    if abs(atten) < self.min_bright:
                        atten = self.min_bright
                    color = gradient_wheel(self.color, atten)

                    self.hexes.set_cells(helpfunc.hex_ring(center, ring),
                                         color)

            # Draw the center hexes - Not included in the ring model
            for center in self.pos:
                h, x, y, = center
                x = self.gauss(self.a, self.c, ring + 1, h)
                atten = 1 + x if x < 0 else x
                if abs(atten) < self.min_bright:
                    atten = self.min_bright
                color = gradient_wheel(self.color, atten)

                self.hexes.set_cells(self.pos, color)

            if helpfunc.one_in(8):
                self.color = change_color(self.color, 0.1)

            self.time = (self.time + 4) % 720

            self.a = sin(radians(self.time))

            yield self.speed  # random time set in init function
Ejemplo n.º 29
0
    def next_frame(self):

        while True:
            fractal = self.mandelbrot_set(
                self.calc_edges(self.counter, self.center), self.square.width,
                self.square.height, self.maxiter)

            for x in range(self.square.width):
                for y in range(self.square.height):
                    value = fractal[x, y]
                    color = change_color(self.color, value *
                                         20) if value < self.maxiter else (0,
                                                                           0,
                                                                           0)
                    self.square.set_cell((x, y), color)

            self.counter += 1

            yield self.speed  # random time set in init function
Ejemplo n.º 30
0
    def next_frame(self):

        while True:

            for h in helpfunc.all_hexes():

                self.hexes.set_cell(
                    self.centers[h],
                    gradient_wheel(self.color[h],
                                   self.get_att(self.width[h], 0, self.time)))

                # Draw the rings
                for ring in range(
                        15
                ):  # total number of rings - can be bigger than display
                    color = gradient_wheel(
                        self.color[h],
                        self.get_att(self.width[h], ring, self.time))
                    self.hexes.set_cells(
                        helpfunc.hex_ring(self.centers[h], ring), color)

                # Slowly change the colors
                if helpfunc.one_in(4):
                    self.color[h] = change_color(self.color[h], 0.05)

                # Move the center of the ripple like a drunken mason
                if helpfunc.one_in(5):
                    while True:
                        new_hex = choice(helpfunc.neighbors(self.centers[h]))
                        if self.hexes.cell_exists(new_hex):
                            self.centers[h] = new_hex
                            break

            self.time += 1

            yield self.speed  # random time set in init function