-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFxLines.ino
58 lines (47 loc) · 1.12 KB
/
FxLines.ino
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
//StripInvader (c) 2011 Michael Vogt <[email protected]> // pixelinvaders.ch
//
//Fancy lines effects
struct line {
uint8_t ofs;
uint8_t pos;
uint8_t del;
uint8_t length;
uint32_t col;
};
line lines;
//init effect
void setupLines() {
newAnimation();
}
//main loop
void loopLines() {
if ((lines.pos > 0 && lines.pos == lines.del) || lines.pos > strip.numPixels()) {
startFadeToRandomColor(128, 128, 128);
newAnimation();
return;
}
if (lines.pos > lines.length) {
lines.del++;
} else {
lines.pos++;
}
uint32_t clearCol = Color(clearColR, clearColG, clearColB);
for (int i=0; i < strip.numPixels(); i++) {
if (i>=lines.ofs+lines.del && i<lines.ofs+lines.pos) {
setTintPixelColor(i, lines.col);
} else {
setTintPixelColor(i, clearCol);
}
}
}
//init a new line animation
void newAnimation() {
lines.length = 0;
while (lines.length<16) {
lines.ofs = random(strip.numPixels());
lines.length = random( strip.numPixels()-lines.ofs );
}
lines.pos = 0;
lines.del = 0;
lines.col = Color(random(220), random(220), random(255));
}