Example #1
0
 def run(self):
     while(self.stopping == False):
         for i, color in enumerate(self.particles):
            if self.stopping:
                break
            if random.random() < self.chance:
                 if self.particles[i] <= 10:
                      self.particles[i] = 511
            elif color > 256+128+64:
                 self.particles[i] -= 1
                 self.frame.brightness[(i//8)][(i%8)][:] =[int (f) for f in
                         self.colormap[0]*(-color+512.)/64.]
            elif color > 256:
                 self.particles[i] -= 1
                 self.frame.brightness[(i//8)][(i%8)][:] = [int (f) for f in
                         self.colormap[448-color]]
            elif color >= 128:
                 self.particles[i] -= 1
                 self.frame.brightness[i//8][i%8][:] = [int (f) for f in
                         self.colormap[255]*(color-128.)/128.]
            elif color > 0:
                 self.particles[i] -= 1
                 self.frame.brightness[i//8][i%8][:] = [0,0,0]
         if not self.stopping:
             shytlight.add_frame(self.rep, self.frame)
 def run(self):
     while(self.stopping == False):
         self.tpf = int(1/(self.bpm/4.)*60./100.*122.)
         for j in range(100):
           # create image on large basis
           circles = np.zeros((50,80, 3), np.uint8)
           circles[:,:]= np.flipud(self.base_color) # numpy ordering is reversed, BGR
           # draw a line
           endpoint = ((np.sin(np.pi*j/50.)*1000+80).astype(np.int),(np.cos(np.pi*j/50.)*1000+50).astype(np.int))
           inv_endpoint = ((np.sin(np.pi*j/50.)*-1000+80).astype(np.int),(np.cos(np.pi*j/50.)*-1000+50).astype(np.int))
           if (j>=0) and (j<25):
               startp = (0,0)
           if (j>=25) and (j<50):
               startp = (80, 0)
           if (j>= 50) and (j<75):
               startp = (80,50)
           if (j>=75):
               startp = (0, 50)
           cv2.line(circles, (startp), (endpoint), self.highlight_color, 10)
           cv2.line(circles, (startp), (inv_endpoint), self.highlight_color, 10)
           # blur circle
           bl_circles = cv2.blur(circles, (11,11))
           # resize image to our real led size
           test_geometry = cv2.resize(bl_circles,(8,5))
           # add frame to buffer
           shytlight.add_frame(self.tpf, test_geometry)
Example #3
0
    def raindrops(self, current_color):
        brightness = np.zeros((self.n_rows, self.n_led, 3))
        is_drop = np.zeros((self.n_rows, self.n_led))

        n_drops = 0
        while (not ((n_drops == 20) and (brightness == 0).all())
               and (self.stopping == False)):
            where_drop = np.where(is_drop)

            brightness[where_drop] = current_color

            is_drop[where_drop] = 0
            rows, leds = where_drop[0], where_drop[1]
            mask = leds < self.n_led - 1
            rows = rows[mask]
            leds = leds[mask] + 1
            where_drop = (rows, leds)
            is_drop[where_drop] = 1

            if ((np.random.random() < 0.10) or
                (brightness == 0).all()) and (n_drops < 20):
                random_row = np.random.randint(self.n_rows)
                if (is_drop[random_row, :2] == 0).all():
                    is_drop[random_row, 0] = 1
                    n_drops += 1

            for __ in range(4):
                brightness[brightness > 0] -= np.log10(
                    brightness[brightness > 0])
                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)
                brightness[brightness < 1.5] = 0
Example #4
0
 def run(self):
     while (self.stopping == False):
         self.tpf = int(1 / (self.bpm / 4.) * 60. / 100. * 122.)
         for j in range(100):
             # create image on large basis
             circles = np.zeros((50, 80, 3), np.uint8)
             circles[:, :] = np.flipud(
                 self.base_color)  # numpy ordering is reversed, BGR
             # draw a line
             endpoint = ((np.sin(np.pi * j / 50.) * 1000 + 80).astype(
                 np.int), (np.cos(np.pi * j / 50.) * 1000 + 50).astype(
                     np.int))
             inv_endpoint = ((np.sin(np.pi * j / 50.) * -1000 + 80).astype(
                 np.int), (np.cos(np.pi * j / 50.) * -1000 + 50).astype(
                     np.int))
             if (j >= 0) and (j < 25):
                 startp = (0, 0)
             if (j >= 25) and (j < 50):
                 startp = (80, 0)
             if (j >= 50) and (j < 75):
                 startp = (80, 50)
             if (j >= 75):
                 startp = (0, 50)
             cv2.line(circles, (startp), (endpoint), self.highlight_color,
                      10)
             cv2.line(circles, (startp), (inv_endpoint),
                      self.highlight_color, 10)
             # blur circle
             bl_circles = cv2.blur(circles, (11, 11))
             # resize image to our real led size
             test_geometry = cv2.resize(bl_circles, (8, 5))
             # add frame to buffer
             shytlight.add_frame(self.tpf, test_geometry)
Example #5
0
 def run(self):
     while (self.stopping == False):
         self.tlp = int(1 / (self.bpm / 4.) * 60. / 100. * 122.)
         for j in range(100):
             # create image on large basis
             circles = np.zeros((50, 80, 3), np.uint8)
             circles[:, :] = np.flipud(
                 self.base_color)  # numpy ordering is reversed, BGR
             # draw a line
             endpoint = ((np.sin(np.pi * j / 50) * 100 + 40).astype(np.int),
                         (np.cos(np.pi * j / 50) * 100 + 25).astype(np.int))
             inv_endpoint = ((np.sin(np.pi * j / 50) * -100 + 40).astype(
                 np.int), (np.cos(np.pi * j / 50) * -100 + 25).astype(
                     np.int))
             cv2.line(circles, (40, 25), (endpoint), self.highlight_color,
                      8)
             cv2.line(circles, (40, 25), (inv_endpoint),
                      self.highlight_color, 8)
             # blur circle
             bl_circles = cv2.blur(circles, (11, 11))
             # resize image to our real led size
             test_geometry = cv2.resize(bl_circles, (8, 5))[::, :, :]
             # add frame to buffer
             if self.stopping:
                 break
             shytlight.add_frame(2, test_geometry)
    def raindrops(self, current_color):
        brightness = np.zeros((self.n_rows, self.n_led, 3))
        is_drop = np.zeros((self.n_rows, self.n_led)) 

        n_drops = 0 
        while (not ((n_drops == 20) and (brightness == 0).all()) and (self.stopping == False)):
            where_drop = np.where(is_drop)

            brightness[where_drop] = current_color

            is_drop[where_drop] = 0
            rows, leds = where_drop[0], where_drop[1]
            mask = leds < self.n_led - 1
            rows = rows[mask]
            leds = leds[mask] + 1
            where_drop = (rows, leds) 
            is_drop[where_drop] = 1

            if ((np.random.random() < 0.10) or (brightness == 0).all()) and (n_drops < 20):
                random_row = np.random.randint(self.n_rows)
                if (is_drop[random_row, :2] == 0).all():
                    is_drop[random_row, 0] = 1
                    n_drops += 1 

            for __ in range(4):
                brightness[brightness > 0] -= np.log10(brightness[brightness > 0])
                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)
                brightness[brightness < 1.5] = 0
 def run(self):
     while not self.stopping:
         for i, color in enumerate(self.particles):
                if self.stopping:
                    break
                if random.random() < self.chance:
                     if self.particles[i] >= self.period:
                          self.particles[i] = 0
                if (color>=0 and color<self.period):
                    self.particles[i]+=1
                    envelope = self.get_brightness(self.particles[i])
                    self.frame.brightness[(i//8)][(i%8)][:] = [int (f) for f in self.get_color(color)*envelope]
         if not self.stopping:
             shytlight.add_frame(self.rep, self.frame)
Example #8
0
    def mr_clean(self, current_color):

        is_active = np.zeros((self.n_rows, self.n_led), dtype=bool)
        for _ in range(self.n_rows):
            is_active[_, _ % 2::2] = True

        for _ in range(100):
            brightness = np.zeros((self.n_rows, self.n_led, 3))
            brightness[is_active] = current_color
            is_active = is_active == False
            for __ in range(self.rep_rate):
                shytlight.add_frame(rep=1, frame=brightness)

            if self.stopping:
                return
Example #9
0
 def run(self):
     while not self.stopping:
         tpf = int(1 / (self.bpm / 4.) * 60. / 90. * 122.)
         for j in range(90):
             if not self.stopping:
                 # create image on large basis
                 circles = np.zeros((50, 80, 3), np.uint8)
                 circles[:, :] = np.flipud(
                     self.base_color)  # numpy ordering is reversed, BGR
                 # draw a line
                 cv2.line(circles, (j, 0), (j, 50), self.highlight_color,
                          10)
                 # blur circle
                 bl_circles = cv2.blur(circles, (21, 21))
                 # resize image to our real led size
                 test_geometry = cv2.resize(bl_circles, (8, 5))[:, :, :]
                 # add frame to buffer
                 shytlight.add_frame(tpf, test_geometry)
 def run(self):
     while (self.stopping == False):
         self.color = self.random_color()
         for j in range(70):
             if self.inv:
                 x = int(((69 - j) / 10.)**2)
             else:
                 x = int(((j) / 10.)**2)
             # create image on large basis
             circles = np.zeros((50, 80, 3))
             # draw a circle with increasing radius
             cv2.circle(circles, (40, 25), x, self.color, 8)
             # blur circle
             bl_circles = cv2.blur(circles, (21, 21))
             # resize image to our real led size
             test_geometry = cv2.resize(bl_circles, (8, 5))
             # add frame to buffer
             if not self.stopping:
                 shytlight.add_frame(1, test_geometry)
 def run(self):
     while (self.stopping == False):
         self.color = self.random_color()
         for j in range(70):
           if self.inv:
              x = int(((69-j)/10.)**2)
           else:
              x = int(((j)/10.)**2)
           # create image on large basis
           circles = np.zeros((50,80,3))
           # draw a circle with increasing radius
           cv2.circle(circles, (40,25),x, self.color, 8)
           # blur circle
           bl_circles = cv2.blur(circles, (21,21))
           # resize image to our real led size
           test_geometry = cv2.resize(bl_circles,(8,5))
           # add frame to buffer
           if not self.stopping:
               shytlight.add_frame(1, test_geometry)
 def run(self):
     while(self.stopping == False):
         self.tlp = int(1/(self.bpm/4.)*60./100.*122.)
         for j in range(100):
             # create image on large basis
             circles = np.zeros((50,80, 3), np.uint8)
             circles[:,:]= np.flipud(self.base_color) # numpy ordering is reversed, BGR
             # draw a line
             endpoint = ((np.sin(np.pi*j/50)*100+40).astype(np.int),(np.cos(np.pi*j/50)*100+25).astype(np.int))
             inv_endpoint = ((np.sin(np.pi*j/50)*-100+40).astype(np.int),(np.cos(np.pi*j/50)*-100+25).astype(np.int))
             cv2.line(circles, (40,25), (endpoint), self.highlight_color, 8)
             cv2.line(circles, (40,25), (inv_endpoint), self.highlight_color, 8)
             # blur circle
             bl_circles = cv2.blur(circles, (11,11))
             # resize image to our real led size
             test_geometry = cv2.resize(bl_circles,(8,5))[::,:,:]
             # add frame to buffer
             if self.stopping:
                 break
             shytlight.add_frame(2, test_geometry)
    def unicolor(self, current_color):
        brightness = np.zeros((self.n_rows, self.n_led, 3))
        brightness[:, :] = current_color

        new_color = self.random_color()
        while new_color == current_color:
            new_color = self.random_color()

        transitions = np.array(new_color) - np.array(current_color)
        red_transition = np.linspace(0, transitions[0], 50)
        green_transition = np.linspace(0, transitions[1], 50)
        blue_transition = np.linspace(0, transitions[2], 50)

        for _ in range(50):
            brightness[:, :, 0] = current_color[0] + red_transition[_]
            brightness[:, :, 1] = current_color[1] + green_transition[_]
            brightness[:, :, 2] = current_color[2] + blue_transition[_]
            if self.stopping == False:
                shytlight.add_frame(rep=4, frame=brightness)
            
        current_color = new_color

        return current_color
    def unicolor(self, current_color):
        brightness = np.zeros((self.n_rows, self.n_led, 3))
        brightness[:, :] = current_color

        new_color = self.random_color()
        while new_color == current_color:
            new_color = self.random_color()

        transitions = np.array(new_color) - np.array(current_color)
        red_transition = np.linspace(0, transitions[0], 50)
        green_transition = np.linspace(0, transitions[1], 50)
        blue_transition = np.linspace(0, transitions[2], 50)

        for _ in range(50):
            brightness[:, :, 0] = current_color[0] + red_transition[_]
            brightness[:, :, 1] = current_color[1] + green_transition[_]
            brightness[:, :, 2] = current_color[2] + blue_transition[_]
            if self.stopping == False:
                shytlight.add_frame(rep=4, frame=brightness)

        current_color = new_color

        return current_color
Example #15
0
def one_flash(current_color):
    random_row = np.random.randint(N_ROWS)
    random_led = np.random.randint(N_LED)
    brightness = np.zeros((5, 8, 3))
    brightness[random_row, random_led, :] = current_color

    offset = 0
    decreasing = False
    while not decreasing:
        decreasing = True
        rep = 1
        if random_row + offset < N_ROWS:
            brightness[random_row + offset, random_led, :] = current_color
            rep = 5
            decreasing = False

        if random_row - offset >= 0:
            brightness[random_row - offset, random_led, :] = current_color
            rep = 5
            decreasing = False

        if random_led + offset < N_LED:
            brightness[random_row, random_led + offset, :] = current_color
            rep = 5
            decreasing = False

        if random_led - offset >= 0:
            brightness[random_row, random_led - offset, :] = current_color
            rep = 5
            decreasing = False

        for _ in range(rep):
            shytlight.add_frame(rep=1, frame=brightness)
            brightness[brightness > 0] -= np.log10(brightness[brightness > 0])
            brightness[brightness < 10] = 0

        offset += 1

    while (brightness > 0).any():
        rep = 1
        if random_row + offset < N_ROWS and offset >= 0:
            brightness[random_row + offset, random_led, :] = current_color
            rep = 5

        if random_row - offset >= 0 and offset >= 0:
            brightness[random_row - offset, random_led, :] = current_color
            rep = 5

        if random_led + offset < N_LED and offset >= 0:
            brightness[random_row, random_led + offset, :] = current_color
            rep = 5

        if random_led - offset >= 0 and offset >= 0:
            brightness[random_row, random_led - offset, :] = current_color
            rep = 5

        for _ in range(rep):
            shytlight.add_frame(rep=1, frame=brightness)
            brightness[brightness > 0] -= np.log10(brightness[brightness > 0])
            brightness[brightness < 10] = 0

        offset -= 1
    def one_flash(self, current_color):
        random_row = np.random.randint(self.n_rows)
        random_row = 3
        random_led = np.random.randint(self.n_led)
        brightness = np.zeros((5, 8, 3))
        brightness[random_row, random_led, :] = current_color

        offset = 0
        decreasing = False

        if not self.stopping:
            shytlight.add_frame(rep=1, frame=brightness, on_beat=True)

        while not decreasing:
            decreasing = True
            rep = 1
            if random_row + offset < self.n_rows:
                brightness[random_row + offset, random_led, :] = current_color
                rep = 5
                decreasing = False

            if random_row - offset >= 0:
                brightness[random_row - offset, random_led, :] = current_color
                rep = 5
                decreasing = False

            if random_led + offset < self.n_led:
                brightness[random_row, random_led + offset, :] = current_color
                rep = 5
                decreasing = False

            if random_led - offset >= 0:
                brightness[random_row, random_led - offset, :] = current_color
                rep = 5
                decreasing = False

            for _ in range(rep):

                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)

                brightness[brightness > 0] -= np.log10(
                    brightness[brightness > 0])
                brightness[brightness < 10] = 0

            offset += 1

        while (brightness > 0).any():
            rep = 1
            if random_row + offset < self.n_rows and offset >= 0:
                brightness[random_row + offset, random_led, :] = current_color
                rep = 5

            if random_row - offset >= 0 and offset >= 0:
                brightness[random_row - offset, random_led, :] = current_color
                rep = 5

            if random_led + offset < self.n_led and offset >= 0:
                brightness[random_row, random_led + offset, :] = current_color
                rep = 5

            if random_led - offset >= 0 and offset >= 0:
                brightness[random_row, random_led - offset, :] = current_color
                rep = 5

            for _ in range(rep):

                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)
                brightness[brightness > 0] -= np.log10(
                    brightness[brightness > 0])
                brightness[brightness < 10] = 0

            offset -= 1
Example #17
0
# make all leds on platine 0 red
for j in range(2):
    for i in range(8):
        test_green.brightness[j][i][0] = 0x00
        test_green.brightness[j][i][1] = 0x00
        test_green.brightness[j][i][2] = 0xff
        test_red.brightness[j][i][0] = 0x00
        test_red.brightness[j][i][1] = 0x00
        test_red.brightness[j][i][2] = 0xff
        test_blue.brightness[j][i][0] = 0xff
        test_blue.brightness[j][i][1] = 0x00
        test_blue.brightness[j][i][2] = 0x00

# add frame to thread
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
shytlight.add_frame(4, test_green)
    def one_flash(self, current_color):
        random_row = np.random.randint(self.n_rows)
        random_row = 3
        random_led = np.random.randint(self.n_led)
        brightness = np.zeros((5, 8, 3))
        brightness[random_row, random_led, :] = current_color

        offset = 0
        decreasing = False

        if not self.stopping:
            shytlight.add_frame(rep=1, frame=brightness, on_beat=True)

        while not decreasing:
            decreasing = True
            rep = 1
            if random_row + offset < self.n_rows:
                brightness[random_row+offset, random_led, :] = current_color
                rep = 5
                decreasing = False
           
            if random_row - offset >= 0:
                brightness[random_row-offset, random_led, :] = current_color
                rep = 5
                decreasing = False

            if random_led + offset < self.n_led:
                brightness[random_row, random_led+offset, :] = current_color
                rep = 5
                decreasing = False

            if random_led - offset >= 0:
                brightness[random_row, random_led-offset, :] = current_color
                rep = 5
                decreasing = False

            for _ in range(rep):

                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)

                brightness[brightness > 0] -= np.log10(brightness[brightness > 0])
                brightness[brightness < 10] = 0

            offset += 1

        while (brightness > 0).any():
            rep = 1
            if random_row + offset < self.n_rows and offset >= 0:
                brightness[random_row+offset, random_led, :] = current_color
                rep = 5
           
            if random_row - offset >= 0 and offset >= 0:
                brightness[random_row-offset, random_led, :] = current_color
                rep = 5

            if random_led + offset < self.n_led and offset >= 0:
                brightness[random_row, random_led+offset, :] = current_color
                rep = 5

            if random_led - offset >= 0 and offset >= 0:
                brightness[random_row, random_led-offset, :] = current_color
                rep = 5

            for _ in range(rep):
                
                if not self.stopping:
                    shytlight.add_frame(rep=1, frame=brightness)
                brightness[brightness > 0] -= np.log10(brightness[brightness > 0])
                brightness[brightness < 10] = 0

            offset -= 1