def draw_planet(self): self.trails.cycle_faders(refresh=False) self.trails.add_fader(color=hue_to_color(self.color), pos=self.pos, intense=1.0, growing=False, change=0.25) # Draw a middle ring gradient_color = gradient_wheel(hue_to_color(self.color), 0.9) for coord in helpfunc.hex_ring(self.pos, 1): self.trails.add_fader(color=gradient_color, pos=coord, intense=0.9, growing=False, change=0.25) # Draw an outer ring gradient_color = gradient_wheel(hue_to_color(self.color), 0.7) for coord in helpfunc.hex_ring(self.pos, 2): self.trails.add_fader(color=gradient_color, pos=coord, intense=0.7, growing=False, change=0.25)
def draw_background(self): """Draw the background - concentric rings of decreasing intensities""" for i in range(6): # total number of rings self.hexes.set_cells(helpfunc.hex_ring(self.center, i), gradient_wheel(self.background, 1 - (i / 8.0))) # Draw the center of the rings self.hexes.set_cell(self.center, gradient_wheel(self.background, 1))
def draw(self, color, time, width): self.hexes.set_cell( self.center, gradient_wheel(color, self.get_att(width, 0, time))) # Draw the rings for i in range( 20): # total number of rings - can be bigger than display self.hexes.set_cells( helpfunc.hex_ring(self.center, i), gradient_wheel(color, self.get_att(width, i, time)))
def draw_spinners(self, spin_center): """Draw the spinners""" self.draw_mirrored(spin_center, gradient_wheel(self.spincolor, 1)) for ring_size in [5, 10, 15]: for ring in range(ring_size): ring_coords = helpfunc.hex_ring(spin_center, 1) coord = ring_coords[ring_size % len(ring_coords)] if self.hexes.cell_exists(coord): gradient = 1 - (abs(ring_size - (self.time % ring_size)) / float(ring_size - 1)) self.draw_mirrored(coord, gradient_wheel(self.spincolor, gradient))
def draw_dendron(self, inversion): ratio = self.life / 10.0 if inversion else 1 - self.life / 40.0 # light center self.hexes.set_cells(helpfunc.mirror_hexes(self.pos), gradient_wheel(self.color, ratio)) if helpfunc.one_in(4): self.direction = helpfunc.turn_left_or_right(self.direction)
def draw_swirl(self): self.hexes.set_cells(self.multi_mirror_hexes(self.pos, self.sym), gradient_wheel(self.color, 1 - self.life / 50.0)) # Random chance that path changes - spirals only in one direction if helpfunc.one_in(2): self.direction = helpfunc.turn_right(self.direction)
def draw_asteroid(self): self.hexes.set_cell(self.pos, self.color) # Draw the center # Draw the outer rings for ring in range(self.size): self.hexes.set_cells( hex_ring(self.pos, ring), gradient_wheel(self.color, 1 - (0.2 * (ring + 1))))
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
def draw_spinner(self, spincolor, explodecolor, time): color = spincolor #if self.expand == 0 else explodecolor self.hexes.set_cell(self.pos, color) # Draw the center # Draw the spinning bits for ring_size in range(1, self.size + 1): ringcells = helpfunc.hex_ring(self.pos, ring_size) num = len(ringcells) for i, coord in enumerate(ringcells): gradient = 1 - (abs(i - (time % num)) / num) self.hexes.set_cell(coord, gradient_wheel(color, gradient))
def draw_ship(self): # Draw the body ship_cells = [ hex_in_direction(self.pos, direction) for direction in all_dir() if direction != (self.direction + 3) % 6 ] self.hexes.set_cells(ship_cells, self.color) # Draw the nozzle self.hexes.set_cell(hex_in_direction(self.pos, self.direction, 2), self.color) # Draw the center body self.hexes.set_cell(self.pos, gradient_wheel(self.color, 0.2))
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
def draw_rays(self): if self.ray == -1: return if self.ray > 7: start_on = self.ray - 7 end_on = 7 else: start_on = 0 end_on = self.ray for i in range(start_on, end_on): center = hex_in_direction(self.ray_pos, 5, i) hue = (self.ray_color + (i * 2)) % 255 dim_color = gradient_wheel(hue_to_color(hue), 1 - (i * 0.1)) self.draw_line(center, 3, i, dim_color) self.draw_line(center, 1, i, dim_color)
def draw_snake(self): self.hexes.set_cell( self.pos, gradient_wheel(self.color, 1.0 - (self.pathlength / 50.0))) self.pathlength += 1
def draw_sparkle(self): if self.hexes.cell_exists(self.pos): self.hexes.set_cell(self.pos, gradient_wheel(self.color, self.intense))
def draw_bullet(self): self.hexes.set_cell(self.pos, gradient_wheel(self.color, self.intense))
def draw_fader(self): self.hex.set_cell(self.pos, gradient_wheel(self.color, self.intense))
def draw_branch(self, inversion): ratio = self.life / 10.0 if inversion else 1 - self.life / 40.0 self.hexes.set_cell(self.pos, gradient_wheel(self.color, ratio)) if one_in(4): self.direction = turn_left_or_right(self.direction)
def draw_fader(self): self.pixel_model.set_cell(self.pos, gradient_wheel(self.color, self.intense))
def draw_ring(self): intensity = reversed([0.2, 0.4, 0.6, 0.8, 1.0]) for (ring, grade) in zip(range(self.size - 3, self.size + 2), intensity): self.hexes.set_cells(helpfunc.hex_ring(self.pos, ring), gradient_wheel(self.color, grade))
def draw_ball(self): self.hexes.set_cell(self.pos, self.color) # Draw the center for i in range(self.size): for coord in hex_ring(self.pos, i): self.hexes.set_cell(coord, gradient_wheel(self.color, 1 - (0.2 * (i + 1))))