def apply(self, time_percent): spin = int(math.floor(time_percent * self.num_of_spins)) if (spin != self.current_spin): self.current_spin = spin self.hue1 = Colors.reduce_by_1(self.hue1 + 0.4) self.hue2 = Colors.reduce_by_1(self.hue1+0.25) self.current_color1 = [int(c*255) for c in colorsys.hsv_to_rgb(self.hue1, 1.0, 0.15)] self.current_color2 = [int(c*255) for c in colorsys.hsv_to_rgb(self.hue2, 1.0, 0.15)] self.effect = AlternateColorEvery3Effect(self.signs.get_all_indexes(),self.current_color1,self.current_color2) oneSpinTime = 1.0 / self.num_of_spins relativePercent = (time_percent - oneSpinTime * self.current_spin) * self.num_of_spins self.effect.apply(relativePercent, self.signs.get_array())
def show_fibonacci_animation(): print "fibonacci" hue1 = random.random() hue2 = Colors.reduce_by_1(hue1 + 0.111) hue3 = Colors.reduce_by_1(hue1 + 0.222) global animations animations = [ FibonacciAnimation(smallSheep, NUM_OF_BITS / 8, hue2), FibonacciAnimation(bigSheep12, NUM_OF_BITS / 8, hue1), FibonacciAnimation(bigSheep34, NUM_OF_BITS / 8, hue3), AlwaysOnSignsAnimation(signs, [30, 30, 30]) ]
def apply(self, time_percent): spin = int(math.floor(time_percent * self.num_of_spins)) if (spin != self.current_spin): self.current_spin = spin self.hue1 = Colors.reduce_by_1(self.hue1 + 0.4) self.hue2 = Colors.reduce_by_1(self.hue1+0.25) self.current_color1 = [int(c*255) for c in colorsys.hsv_to_rgb(self.hue1, 1.0, 0.15)] self.current_color2 = [int(c*255) for c in colorsys.hsv_to_rgb(self.hue2, 1.0, 0.15)] self.create_effects() oneSpinTime = 1.0 / self.num_of_spins relativePercent = (time_percent - oneSpinTime * self.current_spin) * self.num_of_spins for effect in self.effects: effect.apply(relativePercent, self.flower.get_array())
def show_fade_in_out_animation(): print "fade_in_out" hue1 = random.random() hue2 = Colors.reduce_by_1(hue1 + 0.111) hue3 = Colors.reduce_by_1(hue1 + 0.222) hue4 = Colors.reduce_by_1(hue1 + 0.333) global animations animations = [ FadeInOutAnimation(smallSheep, NUM_OF_BITS / 2, hue2), FadeInOutAnimation(bigSheep12, NUM_OF_BITS / 2, hue1), FadeInOutAnimation(bigSheep34, NUM_OF_BITS / 2, hue3), FadeInOutSignsAnimation(signs, NUM_OF_BITS / 2, hue4) ]
def show_alternate_animation(): print "alternate" hue1 = random.random() hue2 = Colors.reduce_by_1(hue1 + 0.25) hue3 = Colors.reduce_by_1(hue1 + 0.5) hue4 = Colors.reduce_by_1(hue1 + 0.75) global animations animations = [ AlternateAnimation(smallSheep, NUM_OF_BITS / 4, hue2), AlternateAnimation(bigSheep12, NUM_OF_BITS / 4, hue1), AlternateAnimation(bigSheep34, NUM_OF_BITS / 4, hue3), AlternateSignsAnimation(signs, NUM_OF_BITS / 4, hue4) ]
def apply(self, time_percent): spin = int(math.floor(time_percent * self.num_of_spins)) if (spin != self.current_spin): self.current_spin = spin if (spin % 2 == 0): color = [ int(c * 255) for c in colorsys.hsv_to_rgb(self.hue, 1.0, 0.15) ] self.effects = [ FadeOutEffect(self.sheep.get_all_indexes(), color) ] else: self.hue = Colors.reduce_by_1(self.hue + 0.29) color = [ int(c * 255) for c in colorsys.hsv_to_rgb(self.hue, 1.0, 0.15) ] self.effects = [ FadeInEffect(self.sheep.get_all_indexes(), color) ] oneSpinTime = 1.0 / float(self.num_of_spins) relativePercent = (time_percent - oneSpinTime * self.current_spin) * self.num_of_spins for effect in self.effects: effect.apply(relativePercent, self.sheep.get_array())
def show_fibonacci_animation(self, current_block): print "fibonacci" num_of_blocks = self.num_of_blocks(current_block[1], 2) if current_block[2] == 'W': num_of_blocks = self.num_of_blocks(num_of_blocks, 4) hue1 = random.random() hue2 = hue1 hue3 = hue1 if current_block[2] == 'S': hue2 = Colors.reduce_by_1(hue1 + 0.111) hue3 = Colors.reduce_by_1(hue1 + 0.222) self.animations = [ FibonacciAnimation(self.smallSheep, num_of_blocks, hue2), FibonacciAnimation(self.bigSheep12, num_of_blocks, hue1), FibonacciAnimation(self.bigSheep34, num_of_blocks, hue3), AlwaysOnSignsAnimation(self.signs, [30, 30, 30]), FibonacciFlowerAnimation(self.flower, num_of_blocks, hue2) ]
def show_alternate_animation(self, current_block): print "alternate" num_of_blocks = current_block[1] if current_block[2] == 'W': num_of_blocks = self.num_of_blocks(num_of_blocks, 2) hue1 = random.random() hue2 = hue1 hue3 = hue1 if current_block[2] == 'S': hue2 = Colors.reduce_by_1(hue1 + 0.333) hue3 = Colors.reduce_by_1(hue1 + 0.666) self.animations = [ AlternateAnimation(self.smallSheep, num_of_blocks, hue2), AlternateAnimation(self.bigSheep12, num_of_blocks, hue1), AlternateAnimation(self.bigSheep34, num_of_blocks, hue3), AlternateSignsAnimation(self.signs, num_of_blocks, hue2), AlternateFlowerAnimation(self.flower, num_of_blocks, hue2) ]
def show_fade_in_out_animation(self, current_block): print "fade_in_out" num_of_blocks = current_block[1] if current_block[2] == 'W': num_of_blocks = self.num_of_blocks(num_of_blocks, 2) hue1 = random.random() hue2 = hue1 hue3 = hue1 hue4 = hue1 if current_block[2] == 'S': hue2 = Colors.reduce_by_1(hue1 + 0.111) hue3 = Colors.reduce_by_1(hue1 + 0.222) hue3 = Colors.reduce_by_1(hue1 + 0.333) self.animations = [ FadeInOutAnimation(self.smallSheep, num_of_blocks, hue2), FadeInOutAnimation(self.bigSheep12, num_of_blocks, hue1), FadeInOutAnimation(self.bigSheep34, num_of_blocks, hue3), FadeInOutSignsAnimation(self.signs, num_of_blocks, hue2), FadeInOutFlowerAnimation(self.flower, num_of_blocks, hue2) ]
def __init__(self, sheep, hue, num_of_spins): SheepAnimation.__init__(self, sheep) self.num_of_spins = num_of_spins self.current_spin = -1 self.color = [ int(c * 255) for c in colorsys.hsv_to_rgb(hue, 1.0, 0.25) ] hue2 = Colors.reduce_by_1(hue + 0.5) self.headColor = [ int(c * 255) for c in colorsys.hsv_to_rgb(hue2, 1.0, 0.25) ] self.legsColor1 = self.color #Colors.adjacent_color(self.color)[0] self.legsColor2 = self.headColor #Colors.adjacent_color(self.color)[1]
def apply(self, time_percent): spin = int(math.floor(time_percent * self.num_of_spins)) if (spin != self.current_spin): self.current_spin = spin self.hue = Colors.reduce_by_1(self.hue + 0.62) self.effects = [ AlwaysOnEffect(self.flower.get_all_indexes(), [30, 30, 30]), FibonacciEffect(self.flower.get_leaves(), self.hue) ] oneSpinTime = 1.0 / float(self.num_of_spins) relativePercent = (time_percent - oneSpinTime * self.current_spin) * self.num_of_spins for effect in self.effects: effect.apply(relativePercent, self.flower.get_array())
def apply(self, time_percent, parent_array): time_percent = math.pow(time_percent, 0.2) fib = len(self.indexes) - int(time_percent * (len(self.indexes)))+1 fib = max(fib, int(len(self.indexes)/100.0)) if (fib != self.start_fib): self.start_fib = fib self.start_fib = self.fibonacci(self.start_fib) for i in range(len(self.indexes)): color = [0,0,0] if (self.hue_num_array[i] != -1): hue = Colors.reduce_by_1(self.hue + self.hue_num_array[i] * 0.23) color = [int(c*255) for c in colorsys.hsv_to_rgb(hue, 1.0, 0.25)] parent_array[self.indexes[i]*3 : self.indexes[i]*3+3] = color