Exemple #1
0
    def update_at_progress(self, progress, new_loop, loop_instance):

	# (loud, pitch) = self.audio.audio_input()

        if new_loop:
            #self.foreground = random_color(luminosity="light")
            self.foreground = random_color()
            self.background = self.foreground.copy()
            self.background.h += 0.5

            self.color_list = morph.transition_list(self.foreground, self.background, steps=16)

            self.clear()

            # udpate mode every now and then
            if (loop_instance % 5 == 0):
                self.mode = (self.mode + 1) % 4
                print "Changing mode to %s" % self.mode

            if self.mode == 0:
                self._list = [[x for x in range(model.numLEDs)]]
            elif self.mode ==1:
                self._list = model.HOR_RINGS_TOP_DOWN
            elif self.mode ==2:
                self._list = model.HOR_RINGS_MIDDLE_OUT
            elif self.mode ==3:
                self._list = model.HOR_RINGS_TOP_DOWN
                self._list.reverse()
            else:
                self._list = [[x for x in range(model.numLEDs)]]

        # Because progress will never actually hit 1.0, this will always
        # produce a valid list index
        to_light = int(progress * len(self._list))

        for i in range(0, len(self._list)):
            c = self.background

            if i <= to_light:
                x = i
                if len(self._list) < len(self.color_list) / 2:
                    x = i * 2
                c_ix = x % len(self.color_list)

                #if self.cm.modifiers[2] and (loop_instance % 2 == 0):
                #    c_ix = len(self.color_list) - 1 - c_ix

                c = self.color_list[c_ix]

	    c.v = loud
            c = hsv_to_rgb(c.hsv)
            for i in self._list[i]:
                self.geometry.set_pixel(i, c)

        self.geometry.draw()
Exemple #2
0
    def update_at_progress(self, progress, new_loop, loop_instance):

        if new_loop:
            #if self.mode==0:
            self.foreground = random_color(luminosity="light")
            self.background = self.foreground.copy()
            self.background.h += 0.5
            self.background.s += 0.2
            '''
            else:
                # TBD
                self.background = self.cm.chosen_colors[1]
                self.foreground = self.cm.chosen_colors[0]
            '''

            self.color_list = morph.transition_list(self.foreground, self.background, steps=16)
            self.clear()


        #mode = self.step_mode(5)

        if self.mode == 1:
            _list = HOR_RINGS_TOP_DOWN
        elif self.mode == 0:
            _list = VERT_RINGS

        # Because progress will never actually hit 1.0, this will always
        # produce a valid list index
        to_light = int(progress * len(_list))

        for i in range(0, len(_list)):
            c = self.background

            if i <= to_light:
                x = i
                if len(_list) < len(self.color_list) / 2:
                    x = i * 2
                c_ix = x % len(self.color_list)

                #if self.cm.modifiers[2] and (loop_instance % 2 == 0):
                if (loop_instance % 2 == 0):
                   c_ix = len(self.color_list) - 1 - c_ix

                c = self.color_list[c_ix]

            el = _list[i]

            c = hsv_to_rgb(c.hsv)
            for i in el:
                self.geometry.set_pixel(i, c)

        self.geometry.draw()
Exemple #3
0
        def next_frame(self):   
                                        
                while (True):
                        
                        # Set background cells
                        
                        c = hsv_to_rgb(self.background.hsv)
                        for i in range(self.geometry.get_nof_pixels()):
                            self.geometry.set_pixel(i, c)
                        
                        # Draw paths
                        for p in self.paths:
                                p.draw_path(self.foreground, self.background)
                                p.move_path()

                        self.geometry.draw()

                        h = (self.foreground.h + 0.1) %1
                        self.foreground = HSV(h,1.0,1.0)
                        
                        yield self.speed
Exemple #4
0
    def clear(self):
        c = hsv_to_rgb(self.background.hsv)
        for i in range(self.geometry.get_nof_pixels()):
            self.geometry.set_pixel(i, c)

        self.geometry.draw()
Exemple #5
0
    def clear(self):
        c = hsv_to_rgb(self.background.hsv)
        for i in range(model.numLEDs):
            self.geometry.set_pixel(i, c)

        self.geometry.draw()
Exemple #6
0
        def draw_fader(self, fore_color, back_color):
                adj_color = morph_color(back_color, fore_color, self.life)
                adj_color = hsv_to_rgb(adj_color.hsv)

                self.geometry.set_pixel(self.cell, adj_color)