Ejemplo n.º 1
0
    def apply(self, time_percent):
        for effect in self.effects:
            effect.apply(time_percent, self.sheep.get_array())

        leg12color = self.sheep.get_array(
        )[self.sheep.get_leg12_connection_index() *
          3:self.sheep.get_leg12_connection_index() * 3 + 3]
        legs12Effect = AlwaysOnEffect(self.sheep.get_leg12_indexes(),
                                      leg12color)
        legs12Effect.apply(time_percent, self.sheep.get_array())

        leg34color = self.sheep.get_array(
        )[self.sheep.get_leg34_connection_index() *
          3:self.sheep.get_leg34_connection_index() * 3 + 3]
        legs34Effect = AlwaysOnEffect(self.sheep.get_leg34_indexes(),
                                      leg34color)
        legs34Effect.apply(time_percent, self.sheep.get_array())

        inner_ear_color = self.sheep.get_array(
        )[self.sheep.get_inner_ear_connection_index() *
          3:self.sheep.get_inner_ear_connection_index() * 3 + 3]
        inner_ear_effect = AlwaysOnEffect(self.sheep.get_inner_ear_indexes(),
                                          inner_ear_color)
        inner_ear_effect.apply(time_percent, self.sheep.get_array())

        outer_ear_color = self.sheep.get_array(
        )[self.sheep.get_outer_ear_connection_index() *
          3:self.sheep.get_outer_ear_connection_index() * 3 + 3]
        outer_ear_effect = AlwaysOnEffect(self.sheep.get_outer_ear_indexes(),
                                          outer_ear_color)
        outer_ear_effect.apply(time_percent, self.sheep.get_array())
Ejemplo n.º 2
0
    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
        for effect in self.effects:
            effect.apply(relativePercent, self.flower.get_array())

        seedColor = self.flower.get_array()[self.flower.get_leaves()[0] *
                                            3:self.flower.get_leaves()[0] * 3 +
                                            3]
        seedColor = AlwaysOnEffect(self.flower.get_seeds(), seedColor)
        seedColor.apply(time_percent, self.flower.get_array())
Ejemplo n.º 3
0
class NaturalLakeAnimation(LakeAnimation):
    def __init__(self, lake, props):
        LakeAnimation.__init__(self, lake, props)
        self.effects = []
        self.previous_time = 1

        self.hue = 0.67
        if self.props != None:
            if 'hue_start' in self.props:
                self.hue = self.props['hue_start']       
        

        self.base_effect = AlwaysOnEffect(self.lake.whole_lake, Colors.hls_to_rgb(self.hue, 1, 1))

        self.start_times = []
        self.speeds = []
        self.create_effects()

    def create_effects(self): 
        self.effects = []
        self.start_times = []
        self.speeds = []

        for i in range(len(self.lake.waves_arr)):
            start_time = random.uniform(0, 0.2)
            speed = 0.8
            self.start_times.append(start_time)
            self.speeds.append(speed)

            wave = self.lake.waves_arr[i]
            self.effects.append(DarkPointEffect(wave, 10))

    
    def apply(self, time_percent):
        if (time_percent < self.previous_time):
            self.create_effects()
        self.previous_time = time_percent

        self.base_effect.apply(time_percent, self.lake.get_array())
      
        for i in range(len(self.lake.waves_arr)):
            if (time_percent < self.start_times[i] or time_percent > self.start_times[i]+self.speeds[i]):
                continue
            relative_pos = (time_percent - self.start_times[i]) / self.speeds[i]
            self.effects[i].apply(relative_pos, self.lake.get_array())
Ejemplo n.º 4
0
    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
        for effect in self.effects:
            effect.apply(relativePercent, self.sheep.get_array())

        leg12color = self.sheep.get_array(
        )[self.sheep.get_leg12_connection_index() *
          3:self.sheep.get_leg12_connection_index() * 3 + 3]
        legs12Effect = AlwaysOnEffect(self.sheep.get_leg12_indexes(),
                                      leg12color)
        legs12Effect.apply(time_percent, self.sheep.get_array())

        leg34color = self.sheep.get_array(
        )[self.sheep.get_leg34_connection_index() *
          3:self.sheep.get_leg34_connection_index() * 3 + 3]
        legs34Effect = AlwaysOnEffect(self.sheep.get_leg34_indexes(),
                                      leg34color)
        legs34Effect.apply(time_percent, self.sheep.get_array())

        inner_ear_color = self.sheep.get_array(
        )[self.sheep.get_inner_ear_connection_index() *
          3:self.sheep.get_inner_ear_connection_index() * 3 + 3]
        inner_ear_effect = AlwaysOnEffect(self.sheep.get_inner_ear_indexes(),
                                          inner_ear_color)
        inner_ear_effect.apply(time_percent, self.sheep.get_array())

        outer_ear_color = self.sheep.get_array(
        )[self.sheep.get_outer_ear_connection_index() *
          3:self.sheep.get_outer_ear_connection_index() * 3 + 3]
        outer_ear_effect = AlwaysOnEffect(self.sheep.get_outer_ear_indexes(),
                                          outer_ear_color)
        outer_ear_effect.apply(time_percent, self.sheep.get_array())