-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPatternStatic_X_Swirl.h
61 lines (43 loc) · 1.92 KB
/
PatternStatic_X_Swirl.h
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
#ifndef PatternStaticSwirl_H
#define PatternStaticSwirl_H
class PatternStaticSwirl : public Drawable {
private:
uint8_t counter = 0 ;
public:
PatternStaticSwirl() {
name = (char *)"Swirl";
id = "W";
enabled = true;
}
// ------------------ start -------------------
void start(uint8_t _pattern) {
counter = 0 ;
}
// --------------------- draw frame -------------------------
unsigned int drawFrame(uint8_t _pattern, uint8_t _total) {
// Use two out-of-sync sine waves
uint8_t i = beatsin8( 7, 0, MATRIX_WIDTH - 1);
uint8_t j = beatsin8( 9, 0, MATRIX_HEIGHT - 1);
// Also calculate some reflections
uint8_t ni = (MATRIX_WIDTH - 1) - i;
uint8_t nj = (MATRIX_HEIGHT - 1) - j;
// The color of each point shifts over time, each at a different speed.
uint16_t ms = millis();
effects.leds[XY( i, j)] += CHSV( ms / 11, 255, 255);
effects.leds[XY( j, i)] += CHSV( ms / 13, 255, 255);
effects.leds[XY(ni, nj)] += CHSV( ms / 17, 255, 255);
effects.leds[XY(nj, ni)] += CHSV( ms / 29, 255, 255);
effects.leds[XY( i, nj)] += CHSV( ms / 37, 255, 255);
effects.leds[XY(ni, j)] += CHSV( ms / 41, 255, 255);
effects.BresLine(i, j, j, i, 16, 128, LINEARBLEND);
effects.BresLine(ni, nj, nj, ni, 32, 255, LINEARBLEND);
effects.BresLine(i, nj, j, ni, 64, 128, LINEARBLEND);
effects.BresLine(ni, j, nj, i, 80, 128, LINEARBLEND);
effects.BresLine(ni, j, j, ni, 64, 128, LINEARBLEND);
effects.BresLine(ni, j, j, ni, 64, 128, LINEARBLEND);
effects.BresLine(i, nj, nj, i, 64, 128, LINEARBLEND);
effects.BresLine(i, nj, nj, i, 64, 128, LINEARBLEND);
return 0;
}
};
#endif