From 83302a9797fa810e79560a54d04e08d16adfe01b Mon Sep 17 00:00:00 2001 From: eBrnd Date: Tue, 22 Sep 2015 17:11:18 +0200 Subject: [PATCH 1/3] spectrum: make second to last color less red --- animations/spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/animations/spectrum.py b/animations/spectrum.py index d1621bd..e887cf9 100644 --- a/animations/spectrum.py +++ b/animations/spectrum.py @@ -25,7 +25,7 @@ BOX_MAP = [ COLORS = [ [50, 255, 50], [50, 255, 120], [50, 251, 255], [50, 120, 255], - [50, 50, 255], [180, 50, 255], [255, 50, 137], [255, 50, 50] + [50, 50, 255], [180, 50, 255], [255, 50, 198], [255, 50, 50] ] From 43e77835941ca14e1110149078856f27316e8188 Mon Sep 17 00:00:00 2001 From: eBrnd Date: Tue, 22 Sep 2015 17:11:36 +0200 Subject: [PATCH 2/3] spectrum animation: fade out slowly --- animations/spectrum.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/animations/spectrum.py b/animations/spectrum.py index e887cf9..17b177e 100644 --- a/animations/spectrum.py +++ b/animations/spectrum.py @@ -31,6 +31,7 @@ COLORS = [ channels = {} + def set_box(x,y,r,g,b): if x >= 0 and y >= 0 and x < WIDTH and y < HEIGHT: base_address = BOX_MAP[y][x] @@ -39,6 +40,16 @@ def set_box(x,y,r,g,b): channels[base_address + 2] = b +def get_box(x, y): + base_address = BOX_MAP[y][x] + try: + res = [ channels[base_address], channels[base_address + 1], channels[base_address + 2] ] + except KeyError, e: + # If the array is still uninitialized, just return [0,0,0] + res = [ 0, 0, 0 ] + return res + + def output_channels(): for channel, value in channels.items(): print("%d : %d" % (channel, value)) @@ -75,7 +86,11 @@ class Background: for x in range(0, WIDTH): for y in range(0, HEIGHT): - set_box(x, y, self._current_bg_color[0], self._current_bg_color[1], self._current_bg_color[2]) + color = get_box(x, y) + color[0] = 0.9 * color[0] + 0.1 * self._current_bg_color[0] + color[1] = 0.9 * color[1] + 0.1 * self._current_bg_color[1] + color[2] = 0.9 * color[2] + 0.1 * self._current_bg_color[2] + set_box(x, y, color[0], color[1], color[2]) def audio_from_raw(raw): From 99793726fbce62eb96e11a9360d355291c49a299 Mon Sep 17 00:00:00 2001 From: eBrnd Date: Tue, 22 Sep 2015 18:02:48 +0200 Subject: [PATCH 3/3] spectrum animation: "upward flowing" effect --- animations/spectrum.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/animations/spectrum.py b/animations/spectrum.py index 17b177e..b418c7a 100644 --- a/animations/spectrum.py +++ b/animations/spectrum.py @@ -84,12 +84,20 @@ class Background: self._target_bg_color[i] = random.randint(0, 128) self._bg_time = 0 - for x in range(0, WIDTH): - for y in range(0, HEIGHT): + for x in range(WIDTH): + for y in range(HEIGHT): color = get_box(x, y) - color[0] = 0.9 * color[0] + 0.1 * self._current_bg_color[0] - color[1] = 0.9 * color[1] + 0.1 * self._current_bg_color[1] - color[2] = 0.9 * color[2] + 0.1 * self._current_bg_color[2] + + if y != HEIGHT - 1: + color_below = get_box(x, y + 1) + else: + color_below = self._current_bg_color + + for i in range(3): + # fade into BG by adding just a little of the current BG color, + # add color from pixel below for a "upward flowing" effect + color[i] = 0.744 * color[i] + 0.056 * self._current_bg_color[i] + 0.2 * color_below[i] + set_box(x, y, color[0], color[1], color[2])