class RainbowSignsAnimation():
    def __init__(self, signs, num_of_spins):
        self.signs = signs
        self.num_of_spins = num_of_spins
        self.current_spin = -1
        self.effect = RainbowEffect(self.signs.get_all_indexes()[::-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

        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 create_effects(self):
     bodyEffect = RainbowEffect(self.sheep.get_body_indexes())
     headEffect = RainbowEffect(self.sheep.get_head_indexes())
     self.effects = [bodyEffect, headEffect]
 def __init__(self, sign, props):
     SignAnimation.__init__(self, sign, props)
     self.effects = [RainbowEffect(self.sign.whole_sign[::-1])]
Exemple #4
0
 def __init__(self, tree, props):
     TreeAnimation.__init__(self, tree, props)
     self.effects = []
     for leaf in self.tree.get_leaves_and_stem():
         self.effects.append(RainbowEffect(leaf[0][::-1]))
         self.effects.append(RainbowEffect(leaf[1][::-1]))
 def __init__(self, flower, num_of_spins):
     self.flower = flower
     self.num_of_spins = num_of_spins
     self.current_spin = -1
     self.effects = [RainbowEffect(self.flower.get_leaves())]
 def __init__(self, signs, num_of_spins):
     self.signs = signs
     self.num_of_spins = num_of_spins
     self.current_spin = -1
     self.effect = RainbowEffect(self.signs.get_all_indexes()[::-1])
    def createEffects(self):

        one = self.flower.l1 + self.flower.l3 + self.flower.l5 + self.flower.l7 + self.flower.l9
        two = self.flower.l8 + self.flower.l10 + self.flower.l2 + self.flower.l4 + self.flower.l6
        self.effects = []
        self.effects.append(RainbowEffect(one[::-1]))
        self.effects.append(RainbowEffect(two))

        seeds_order = self.flower.seeds[:]
        random.shuffle(seeds_order)
        self.effects.append(RainbowEffect(seeds_order))

        if self.frame_counter % 2 == 0:
            self.hue = random.random()
        color = Colors.hls_to_rgb(self.hue, 1, 1)
        light_color = [x * 0.2 for x in color]

        gradient1_front = Colors.gradient_array(light_color, color,
                                                len(self.flower.line_front), 4)
        gradient2_front = Colors.gradient_array([30, 30, 30], [100, 100, 100],
                                                len(self.flower.line_front), 4)
        gradient1_back = Colors.gradient_array(light_color, color,
                                               len(self.flower.line_back), 4)
        gradient2_back = Colors.gradient_array([30, 30, 30], [100, 100, 100],
                                               len(self.flower.line_back), 4)

        if self.frame_counter % 2 == 0:
            self.effects.append(
                GoToColorsEffect(self.flower.line_front, gradient2_front,
                                 gradient1_front))
            self.effects.append(
                GoToColorsEffect(self.flower.line_back, gradient2_back,
                                 gradient1_back))
        else:
            self.effects.append(
                GoToColorsEffect(self.flower.line_front, gradient1_front,
                                 gradient2_front))
            self.effects.append(
                GoToColorsEffect(self.flower.line_back, gradient1_back,
                                 gradient2_back))

        gradient1_leaf1 = Colors.gradient_array(
            light_color, color,
            len(self.flower.leaf_right_front + self.flower.leaf_right_back), 4)
        gradient2_leaf1 = Colors.gradient_array(
            [30, 30, 30], [100, 100, 100],
            len(self.flower.leaf_right_front + self.flower.leaf_right_back), 4)
        gradient1_leaf2 = Colors.gradient_array(
            light_color, color,
            len(self.flower.leaf_left_front + self.flower.leaf_left_back), 4)
        gradient2_leaf2 = Colors.gradient_array(
            [30, 30, 30], [100, 100, 100],
            len(self.flower.leaf_left_front + self.flower.leaf_left_back), 4)

        if self.frame_counter % 2 == 0:
            self.effects.append(
                GoToColorsEffect(
                    self.flower.leaf_right_front + self.flower.leaf_right_back,
                    gradient2_leaf1, gradient1_leaf1))
            self.effects.append(
                GoToColorsEffect(
                    self.flower.leaf_left_front + self.flower.leaf_left_back,
                    gradient2_leaf2, gradient1_leaf2))
        else:
            self.effects.append(
                GoToColorsEffect(
                    self.flower.leaf_right_front + self.flower.leaf_right_back,
                    gradient1_leaf1, gradient2_leaf1))
            self.effects.append(
                GoToColorsEffect(
                    self.flower.leaf_left_front + self.flower.leaf_left_back,
                    gradient1_leaf2, gradient2_leaf2))