-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheye.js
257 lines (242 loc) · 4.26 KB
/
eye.js
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
const COLOR_GREEN = 0;
const COLOR_RED = 1;
const COLOR_YELLOW = 2;
let colorCycle = 0;
const cpArr = from => {
return from.map(bmp => bmp.map(line => line));
}
const bmp_0 = [1,3,1,9,31,63,127,255];
const bmp_1 = [1,3,7,9,25,63,127,255];
const bmp_2 = [0,1,3,1,9,31,63,127];
const bmp_3 = [0,0,1,1,1,15,31,63];
const bmp_4 = [0,0,0,1,1,7,15,31];
const bmp_5 = [0,0,0,0,1,3,7,15];
const bmp_6 = [0,0,0,0,0,1,3,7];
const bmp_7 = [0,0,0,0,0,0,0,1];
const bmp_8 = [0,0,0,0,0,0,0,0];
const bmp_9 = bmp_7;
const bmp_10 = bmp_6;
const bmp_11 = bmp_11;
const bmp_12 = bmp_4;
const bmp_13 = bmp_3;
const bmp_14 = bmp_2;
const bmp_15 = bmp_1;
const bmp_16 = [1,3,7,15,25,57,127,255];
const bmp_17 = [1,3,7,15,31,57,121,255];
const bmp_18 = [1,3,7,15,31,51,115,255];
const bmp_19 = [1,3,7,15,31,39,103,255];
const bmp_20 = [1,3,7,15,31,15,79,255];
const bmp_21 = bmp_19;
const bmp_22 = [1,3,7,15,19,51,127,255];
const bmp_23 = bmp_17;
const bmp_24 = bmp_16;
const bmp_25 = bmp_1;
const evil_0 = [60,126,207,199,227,243,126,60];
const evil_1 = [60,102,227,241,249,255,126,60];
const evil_2 = [60,126,255,159,143,199,102,60];
const evil_3 = [12,62,127,31,143,198,100,48];
const evil_4 = [4,30,63,30,14,196,96,0];
const evil_5 = [0,6,30,30,12,64,64,0];
const evil_6 = [0,2,14,28,8,0,64,0];
const evil_7 = [0,0,12,24,0,0,0,0];
const evil_8 = [0,0,0,0,0,0,0,0];
let tea = [
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_0,
bmp_1,
bmp_2,
bmp_3,
bmp_4,
bmp_5,
bmp_6,
bmp_7,
bmp_8,
bmp_9,
bmp_10,
bmp_11,
bmp_12,
bmp_13,
bmp_14,
bmp_15,
bmp_16,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_17,
bmp_18,
bmp_19,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_20,
bmp_21,
bmp_22,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_23,
bmp_24,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25,
bmp_25
];
let lea = [
evil_0,
evil_0,
evil_0,
evil_0,
evil_0,
evil_0,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_1,
evil_0,
evil_0,
evil_0,
evil_0,
evil_0,
evil_0,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_2,
evil_3,
evil_4,
evil_5,
evil_6,
evil_7,
evil_8
];
let typeOfEyes = "lizardEyes";
let animation = cpArr(lea);
let animationIndex = 0;
let positiveDirection = true;
let lastBmp = [];
function updateIndex() {
if (positiveDirection) {
animationIndex++;
} else {
animationIndex--;
}
}
function linefor(line) {
let newLine;
switch (colorCycle) {
case COLOR_GREEN:
newLine = [line, 0];
break;
case COLOR_RED:
newLine = [0, line];
break;
case COLOR_YELLOW:
newLine = [line, line];
break;
}
colorCycle += 1;
if(colorCycle > 2) colorCycle = 0;
return newLine;
}
export const animate = matrix => {
setInterval(function () {
const bmp = animation[animationIndex];
const multiColorBmp = bmp.map(line => linefor(line));
matrix.render(multiColorBmp);
lastBmp = bmp;
updateIndex();
if (animationIndex === animation.length || animationIndex < 0) {
positiveDirection = !positiveDirection;
updateIndex();
}
}, 50);
};