Created
December 26, 2019 19:22
-
-
Save adventureloop/cf5ba9ea1ef7e380166b7ef9af9d84a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import colorsys | |
import time | |
from sys import exit | |
try: | |
import numpy as np | |
except ImportError: | |
exit('This script requires the numpy module\nInstall with: sudo pip install numpy') | |
import blinkt | |
blinkt.clear() | |
start = 0 | |
end = 60 | |
DELAY=0.01 | |
while True: | |
wait = np.random.choice(np.random.noncentral_chisquare(5, 1, 1000), 1)[0] / 50 | |
n = np.random.choice(np.random.noncentral_chisquare(5, 0.1, 1000), 1) | |
limit = int(n[0]) | |
if limit > blinkt.NUM_PIXELS: | |
limit = blinkt.NUM_PIXELS | |
for pixel in range(blinkt.NUM_PIXELS): | |
if pixel > limit: | |
r, g, b = 0, 0, 0 | |
else: | |
hue = start + (((end - start) / float(blinkt.NUM_PIXELS)) * pixel) | |
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue / 360.0, 1.0, 1.0)] | |
blinkt.set_pixel(pixel, r, g, b) | |
if pixel < limit: | |
time.sleep(DELAY / (pixel + 1)) | |
blinkt.show() | |
if pixel == blinkt.NUM_PIXELS-1: | |
blinkt.show() | |
time.sleep(wait) | |
#blinkt.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment