Exemple #1
0
 def __init__(self, width, height, frame_delay=0.3):
     MatrixPixelEffect.__init__(self, width, height, 1, frame_delay)
     self.base_color = ColorRGB.random()
     self.new_base_color = ColorRGB.random()
     self.color = self.base_color
     self.color_conversion_progress = 0
     self.last_time = ''
     self.sprites = []
     self.sprites.append([[1, 1, 1], [1, 0, 1], [1, 0, 1], [1, 0, 1],
                          [1, 0, 1], [1, 0, 1], [1, 1, 1]])
     self.sprites.append([[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1],
                          [0, 0, 1], [0, 0, 1], [0, 0, 1]])
     self.sprites.append([[1, 1, 1], [0, 0, 1], [0, 0, 1], [1, 1, 1],
                          [1, 0, 0], [1, 0, 0], [1, 1, 1]])
     self.sprites.append([[1, 1, 1], [0, 0, 1], [0, 0, 1], [1, 1, 1],
                          [0, 0, 1], [0, 0, 1], [1, 1, 1]])
     self.sprites.append([[1, 0, 1], [1, 0, 1], [1, 0, 1], [1, 1, 1],
                          [0, 0, 1], [0, 0, 1], [0, 0, 1]])
     self.sprites.append([[1, 1, 1], [1, 0, 0], [1, 0, 0], [1, 1, 1],
                          [0, 0, 1], [0, 0, 1], [1, 1, 1]])
     self.sprites.append([[1, 1, 1], [1, 0, 0], [1, 0, 0], [1, 1, 1],
                          [1, 0, 1], [1, 0, 1], [1, 1, 1]])
     self.sprites.append([[1, 1, 1], [0, 0, 1], [0, 0, 1], [0, 1, 0],
                          [0, 1, 0], [1, 0, 0], [1, 0, 0]])
     self.sprites.append([[1, 1, 1], [1, 0, 1], [1, 0, 1], [1, 1, 1],
                          [1, 0, 1], [1, 0, 1], [1, 1, 1]])
     self.sprites.append([[1, 1, 1], [1, 0, 1], [1, 0, 1], [1, 1, 1],
                          [0, 0, 1], [0, 0, 1], [1, 1, 1]])
     self.sprites.append([[0, 0, 0], [0, 0, 0], [0, 1, 0], [0, 0, 0],
                          [0, 1, 0], [0, 0, 0], [0, 0, 0]])
 def __init__(self, drawer, steps, cycles, frame_delay=0):
     PixelEffect.__init__(self, drawer, frame_delay)
     self.steps = steps
     self.cycles = cycles
     self.current_step = 0
     self.current_cycle = 0
     self.transition_cycle = -1
     self.target_color = ColorRGB.random(2, drawer.intensity_min,
                                         drawer.intensity_max)
     self.target_transition_color = ColorRGB.random(2, drawer.intensity_min,
                                                    drawer.intensity_max)
Exemple #3
0
    def play_frame(self, drawer):
        t = datetime.now().strftime("%H:%M:%S")
        if self.last_time == t:
            return

        self.last_time = t

        self.color_conversion_progress = self.color_conversion_progress + 0.01

        if self.color_conversion_progress > 1:
            self.base_color = self.new_base_color
            self.new_base_color = ColorRGB.random()
            self.color_conversion_progress = 0

        self.color = self.base_color.convert(self.new_base_color,
                                             self.color_conversion_progress)

        sec = datetime.now().second
        i = 0
        drawer.clear(False)
        print(t)

        for s in t:
            if s == ':':
                if sec % 2 == 0:
                    self.print_symbol(drawer, 10, i)
            else:
                self.print_symbol(drawer, int(s), i)
            i = i + 1

        drawer.show()
    def play_frame(self):
        if self.current_cycle >= self.cycles:
            if self.current_cycle == self.cycles:
                self.target_transition_color = ColorRGB.random(
                    2, self.drawer.intensity_min, self.drawer.intensity_max)

            self.transition_cycle = self.current_cycle - self.cycles

            if self.transition_cycle == self.drawer.n_led:
                self.transition_cycle = -1
                self.target_color = self.target_transition_color
                self.current_cycle = 0

        self.current_cycle += 1
        self.current_step += 1

        for z in self.drawer.pixels_indexes:
            m = abs(math.sin((z + self.current_step) / self.steps))

            if z <= self.transition_cycle:
                c = self.target_transition_color
            else:
                c = self.target_color

            m_c = c.multiply(m, True)

            self.drawer.set_color(z, m_c)

        self.drawer.show()
    def play_frame(self):
        step_r = 0
        step_g = 0
        step_b = 0

        if self.current_step == self.steps - 30:
            self.bounce_direction = -1
        elif self.current_step == 0:
            self.bounce_direction = 1
            target_color = ColorRGB.random(2, self.drawer.intensity_min,
                                           self.drawer.intensity_max)

            step_r = target_color.r / float(self.steps)
            step_g = target_color.g / float(self.steps)
            step_b = target_color.b / float(self.steps)

        self.current_step += self.bounce_direction
        current_color = ColorRGB(step_r * self.current_step,
                                 step_g * self.current_step,
                                 step_b * self.current_step)

        for z in range(0, self.drawer.n_led - 1):
            self.drawer.set_color(z, current_color)

        self.drawer.show()
    def play_frame(self):
        drops_count = len(self.drops)
        if drops_count == 0:
            self.drops.append([
                0,
                ColorRGB.random(2, self.drawer.intensity_min,
                                self.drawer.intensity_max)
            ])
        elif self.drops[drops_count -
                        1][0] == self.tail_len + self.drops_distance:
            self.drops.append([
                0,
                ColorRGB.random(2, self.drawer.intensity_min,
                                self.drawer.intensity_max)
            ])

        delete_first = False

        for drop in self.drops:
            drop[0] = drop[0] + 1
            if drop[0] == self.drawer.n_led + self.tail_len:
                delete_first = True
            else:
                faid = self.tail_len
                for z in range(
                        drop[0] - self.tail_len - 1 - self.drops_distance,
                        drop[0]):
                    if 0 < z < self.drawer.n_led - 1:
                        if faid <= 0:
                            pixel = ColorRGB()
                        else:
                            pixel = drop[1].multiply(1 / float(faid))

                        self.drawer.set_color(z, pixel)
                        faid = faid - 1

        if delete_first:
            self.drops.remove(self.drops[0])

        self.drawer.show()
Exemple #7
0
 def __init__(self):
     self.altitude = 0
     self.speed = 1
     self.color = ColorRGB.random(3, 100, 200)
     self.radius = 3
     self.tail_pixels = []