-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatterns.py
142 lines (111 loc) · 2.99 KB
/
patterns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import time
from math import *
import random
NUM_PIXELS = 50
ORANGE = (238, 65, 25)
GREEN = (0, 255, 0)
WHITE = (255, 255, 175)
OFF = (0, 0, 0)
def off(fc):
pixels = [(0, 0, 0)] * NUM_PIXELS
put_symmetric(fc, pixels)
put_symmetric(fc, pixels)
def orange(fc):
pixels = [ORANGE] * NUM_PIXELS
put_symmetric(fc, pixels)
put_symmetric(fc, pixels)
def green(fc):
pixels = [GREEN] * NUM_PIXELS
put_symmetric(fc, pixels)
put_symmetric(fc, pixels)
def white(fc):
pixels = [WHITE] * NUM_PIXELS
put_symmetric(fc, pixels)
put_symmetric(fc, pixels)
def bacon_static(fc):
pixels = [(0, 0, 0)] * NUM_PIXELS
for i in range(NUM_PIXELS/2):
pixels[2*i] = ORANGE
pixels[2*i+1] = GREEN
put_symmetric(fc, pixels)
def bacon_static_inverse(fc):
pixels = [(0, 0, 0)] * NUM_PIXELS
for i in range(0, NUM_PIXELS, 2):
pixels[i] = GREEN
pixels[i+1] = ORANGE
put_symmetric(fc, pixels)
def twinkle(fc):
pixels = [(0, 0, 0)] * NUM_PIXELS * 2
for i in range(0, NUM_PIXELS*2, 2):
pixels[i] = ORANGE
pixels[i+1] = GREEN
for i in range(0, NUM_PIXELS*2):
if(random.randint(0, 100) < 5):
pixels[i] = (25, 255, 175)
fc.put_pixels(pixels)
time.sleep(0.05)
def strobe(fc):
orange(fc)
time.sleep(0.05)
off(fc)
time.sleep(0.05)
green(fc)
time.sleep(0.05)
off(fc)
time.sleep(0.05)
white(fc)
time.sleep(0.03)
off(fc)
time.sleep(0.05)
def chase(fc):
pixels = [GREEN] * NUM_PIXELS
for i in range(NUM_PIXELS):
pixels[i] = ORANGE
put_symmetric(fc, pixels)
time.sleep(0.1)
for i in range(NUM_PIXELS):
pixels[i] = GREEN
put_symmetric(fc, pixels)
time.sleep(0.1)
def stack(fc):
position = NUM_PIXELS
while(position > 0):
for i in range(position):
pixels = [GREEN] * NUM_PIXELS
for j in range(position, NUM_PIXELS):
pixels[j] = ORANGE
pixels[i] = ORANGE
put_symmetric(fc, pixels)
time.sleep(0.05)
position -= 1
position = NUM_PIXELS
while(position > 0):
for i in range(position):
pixels = [ORANGE] * NUM_PIXELS
for j in range(position, NUM_PIXELS):
pixels[j] = GREEN
pixels[i] = GREEN
put_symmetric(fc, pixels)
time.sleep(0.05)
position -= 1
def colorwheel(fc):
SCALE = 128
SEPARATION = 10
z = time.time() % 255
pixels = [OFF] * NUM_PIXELS * 2
for i in range(0, NUM_PIXELS*2):
pixels[i] = wheel(int(z * SCALE + SEPARATION * i) % 255)
fc.put_pixels(pixels)
def wheel(pos):
pos = int(pos) % 255
if pos < 85:
return (255 - pos * 3, 0, pos * 3)
if pos < 170:
pos -= 85
return (0, pos * 3, 255 - pos * 3)
pos -= 170
return (pos * 3, 255 - pos * 3, 0)
def put_symmetric(fc, input):
copy = list(input)
copy.extend(copy)
fc.put_pixels(copy)