3
3
import random
4
4
import math
5
5
import time
6
- from animations import FadeAnimation
6
+ from animations import FadeAnimation
7
7
8
- #author: Harsh Singh
8
+ # author: Harsh Singh
9
+ light_count = 48
9
10
nice_pixels = [
10
- (1023.0 ,0.0 ,0.0 ),
11
- (0.0 ,1023.0 ,0.0 ),
12
- (0.0 ,0.0 ,1023.0 ),
13
- (0.0 ,1023.0 ,1023.0 ),
14
- (1023.0 ,0. ,1023.0 ),
15
- (1023.0 ,1023.0 ,0. ),
16
- (823.0 ,823.0 ,0.0 ),
17
- (823.0 ,0.0 ,823.0 ),
18
- (0.0 ,823.0 ,823.0 ),
11
+ (1023.0 , 0.0 , 0.0 ),
12
+ (0.0 , 1023.0 , 0.0 ),
13
+ (0.0 , 0.0 , 1023.0 ),
14
+ (0.0 , 1023.0 , 1023.0 ),
15
+ (1023.0 , 0. , 1023.0 ),
16
+ (1023.0 , 1023.0 , 0. ),
17
+ (823.0 , 823.0 , 0.0 ),
18
+ (823.0 , 0.0 , 823.0 ),
19
+ (0.0 , 823.0 , 823.0 ),
19
20
]
20
- bgColor = (0.0 ,0.0 ,0.0 )
21
- template = [[0 ,1 ,4 ,5 ],[2 ,3 ,6 ,7 ],[8 ,9 ,12 ,13 ],[10 ,11 ,14 ,15 ],[16 ,17 ,20 ,21 ],[18 ,19 ,22 ,23 ],[0 ,1 ,2 ,3 ,4 ,7 ,8 ,11 ,12 ,13 ,14 ,15 ],[5 ,6 ,9 ,10 ],]
21
+ bgColor = (0.0 , 0.0 , 0.0 )
22
+ template = [
23
+ [0 , 1 , 4 , 5 ], [2 , 3 , 6 , 7 ], [8 , 9 , 12 , 13 ], [
24
+ 10 , 11 , 14 , 15 ], [16 , 17 , 20 , 21 ],
25
+ [18 , 19 , 22 , 23 ], [0 , 1 , 2 , 3 , 4 , 7 , 8 , 11 , 12 , 13 , 14 , 15 ], [5 , 6 , 9 , 10 ], ]
22
26
out = FadeAnimation ()
23
27
out .start ()
24
- layout = [bgColor ]* 24
28
+ layout = [bgColor ] * light_count
25
29
26
30
27
31
def repeat (** options ):
@@ -30,124 +34,130 @@ def repeat(**options):
30
34
if (options .get ("times" ) > 1 ):
31
35
times = options .get ("times" )
32
36
if (options .get ("frames" )):
33
- while (n < times ):
37
+ while (n < times ):
34
38
options .get ("frames" )
35
- n += 1
39
+ n += 1
36
40
37
41
# set color in box 1,2,3,4 with .4 second interval
42
+
43
+
38
44
def frame1 ():
39
- rand = random .sample (nice_pixels ,5 )
40
- layout = [rand [4 ]]* 24
45
+ rand = random .sample (nice_pixels , 5 )
46
+ layout = [rand [4 ]] * light_count
41
47
out .write (layout )
42
- time .sleep (0.4 )
43
- for i in [0 ,1 , 3 , 2 ]:
48
+ time .sleep (0.4 )
49
+ for i in [0 , 1 , 3 , 2 ]:
44
50
for j in range (4 ):
45
51
layout [template [i ][j ]] = rand [i ]
46
- #printlayout(layout)
52
+ # printlayout(layout)
47
53
out .write (layout )
48
54
time .sleep (0.4 )
49
55
50
56
51
57
# set color outer box, then inner box .2 delay
52
58
def frame2 ():
53
- rand = random .sample (nice_pixels ,3 )
54
- layout = [rand [2 ]]* 24
55
- for i in [6 ,7 ]:
59
+ rand = random .sample (nice_pixels , 3 )
60
+ layout = [rand [2 ]] * light_count
61
+ for i in [6 , 7 ]:
56
62
for j in range (len (template [i ])):
57
- layout [template [i ][j ]] = rand [i - 6 ]
63
+ layout [template [i ][j ]] = rand [i - 6 ]
58
64
out .write (layout )
59
65
time .sleep (0.2 )
60
66
61
67
62
-
63
-
64
68
# spin colors at 5,6,9,10 at .1 second interval
65
69
def frame3 ():
66
- rand = random .sample (nice_pixels ,5 )
67
- layout = [rand [4 ]]* 24
68
- #printlayout(layout)
69
- #out.write(layout)
70
- #time.sleep(0.4)
71
- i = 0
70
+ rand = random .sample (nice_pixels , 5 )
71
+ layout = [rand [4 ]] * light_count
72
+ # printlayout(layout)
73
+ # out.write(layout)
74
+ # time.sleep(0.4)
75
+ i = 0
72
76
for j in range (len (template [i ])):
73
77
74
- #print "i= "+str(i)+" j ="+str(j)
78
+ # print "i= "+str(i)+" j ="+str(j)
75
79
layout [template [7 ][j ]] = rand [i ]
76
80
out .write (layout )
77
81
time .sleep (0.1 )
78
- i += 1
79
- #printlayout(layout)
80
-
82
+ i += 1
83
+ # printlayout(layout)
84
+
81
85
# spin colors at 5,6,9,10 at .1 second interval
86
+
87
+
82
88
def frame3 ():
83
- rand = random .sample (nice_pixels ,5 )
84
- layout = [rand [4 ]]* 24
85
- #printlayout(layout)
86
- #out.write(layout)
87
- #time.sleep(0.4)
88
- i = 0
89
+ rand = random .sample (nice_pixels , 5 )
90
+ layout = [rand [4 ]] * light_count
91
+ # printlayout(layout)
92
+ # out.write(layout)
93
+ # time.sleep(0.4)
94
+ i = 0
89
95
for j in range (len (template [i ])):
90
96
91
- #print "i= "+str(i)+" j ="+str(j)
97
+ # print "i= "+str(i)+" j ="+str(j)
92
98
layout [template [7 ][j ]] = rand [i ]
93
99
out .write (layout )
94
100
time .sleep (0.1 )
95
- i += 1
96
- #printlayout(layout)
101
+ i += 1
102
+ # printlayout(layout)
103
+
104
+ # spiral function from 0 to 9
105
+
97
106
98
- #spiral function from 0 to 9
99
107
def frame4 ():
100
- path = [0 ,1 , 2 , 3 , 7 , 11 ,15 ,14 ,13 ,12 ,8 , 4 , 5 , 6 , 10 ,9 ]
101
-
102
- rand = random .sample (nice_pixels ,4 )
108
+ path = [0 , 1 , 2 , 3 , 7 , 11 , 15 , 14 , 13 , 12 , 8 , 4 , 5 , 6 , 10 , 9 ]
109
+
110
+ rand = random .sample (nice_pixels , 4 )
103
111
for i in range (len (path )):
104
112
layout [path [i ]] = rand [0 ]
105
113
if (i != 0 ):
106
- layout [path [i - 1 ]] = rand [1 ]
114
+ layout [path [i - 1 ]] = rand [1 ]
107
115
# else:
108
116
# layout[path[len(path)-1]] = rand[1]
109
- #printlayout(layout)
117
+ # printlayout(layout)
110
118
out .write (layout )
111
119
time .sleep (0.05 )
112
120
for i in range (len (path )):
113
- layout [path [len (path )- 1 - i ]] = rand [2 ]
121
+ layout [path [len (path ) - 1 - i ]] = rand [2 ]
114
122
if (i != 0 ):
115
- layout [path [len (path )- i ]] = rand [3 ]
123
+ layout [path [len (path ) - i ]] = rand [3 ]
116
124
# else:
117
125
# layout[path[len(path)-1]] = rand[1]
118
- #printlayout(layout)
126
+ # printlayout(layout)
119
127
out .write (layout )
120
128
time .sleep (0.05 )
121
129
130
+
122
131
def color_picker ():
123
- r = random .random ()* 1000
132
+ r = random .random () * 1000
124
133
b , g = (0. , 0. )
125
134
while True :
126
135
if (b > 1000 ):
127
- r = random .random ()* 1000
136
+ r = random .random () * 1000
128
137
b = 0
129
- g = random .random ()* 1000
138
+ g = random .random () * 1000
130
139
if (g > 1000 ):
131
- r = random .random ()* 1000
132
- b = random .random ()* 1000
140
+ r = random .random () * 1000
141
+ b = random .random () * 1000
133
142
g = 0
134
143
if (r > 1000 ):
135
- g = random .random ()* 1000
136
- b = random .random ()* 1000
144
+ g = random .random () * 1000
145
+ b = random .random () * 1000
137
146
r = 0
138
147
139
- r += 10.
140
- b += 10.
141
- g += 10.
142
- layout = [(r ,g , b )]* 24
143
- print (r ,g , b )
148
+ r += 10.
149
+ b += 10.
150
+ g += 10.
151
+ layout = [(r , g , b )] * light_count
152
+ print (r , g , b )
144
153
out .write (layout )
145
154
time .sleep (.01 )
146
155
147
156
148
157
def printlayout (layout ):
149
- for i in range (0 ,5 ):
150
- print (str (layout [i * 4 + 0 ])+ " " + str (layout [i * 4 + 1 ])+ " " + str (layout [i * 4 + 2 ])+ " " + str (layout [i * 4 + 3 ]))
158
+ for i in range (0 , 5 ):
159
+ print (str (layout [i * 4 + 0 ]) + " " + str (layout [i * 4 + 1 ])
160
+ + " " + str (layout [i * 4 + 2 ]) + " " + str (layout [i * 4 + 3 ]))
151
161
print
152
162
153
163
if __name__ == "__main__" :
0 commit comments