-
Notifications
You must be signed in to change notification settings - Fork 0
/
effects.h
181 lines (165 loc) · 5.63 KB
/
effects.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
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
#ifndef EFFECTS_H
#define EFFECTS_H
void setOuterHeart(int r,int g,int b){
for (int i = 0; i < OUTERHEART_COUNT; i++) {
outerheart[i].setClr(r,g,b);
}
}
void setInnerHeart(int r,int g,int b){
for (int i = 0; i < INNERHEART_COUNT; i++) {
innerheart[i].setClr(r,g,b);
}
}
void setJewelHeart(int r,int g,int b){
for (int i = 0; i < JEWELHEART_COUNT; i++) {
jewelheart[i].setClr(r,g,b);
}
}
void setHeart(int r,int g,int b){
setOuterHeart(r,g,b);
setInnerHeart(r,g,b);
setJewelHeart(r,g,b);
}
void setBodice(int r,int g,int b){
for (int i = 0; i < BODICE_COUNT; i++) {
bodice[i].setClr(r,g,b);
}
}
void stripOutput(){
for (int i = 0; i < 6; i++) {
strips[i].show();
}
}
void heartSleepThrob(int bright,int maxVal,int intervalVal,float rbal,float gbal, float bbal){
int inbright,outbright,jbright;
inbright = bright;
if (inbright > maxVal) {
inbright = maxVal;
}
if (bright > intervalVal) {
outbright = bright - intervalVal;
if (outbright > maxVal) {
outbright = maxVal;
}
} else
outbright = 0;
if (bright > intervalVal*2) {
jbright = bright - (intervalVal*2);
if (jbright > maxVal) {
jbright = maxVal;
}
} else
jbright = 0;
setOuterHeart(outbright*rbal,outbright*gbal,outbright*bbal);
setInnerHeart(inbright*rbal,inbright*gbal,inbright*bbal);
setJewelHeart(jbright*rbal,jbright*gbal,jbright*bbal);
}
void heartSleepThrob2(int bright,int maxVal,int intervalVal,float rbal,float gbal, float bbal){
int inbright,outbright,jbright;
jbright = bright;
if (jbright > maxVal) {
jbright = maxVal;
}
if (bright > intervalVal) {
inbright = bright - intervalVal;
if (inbright > maxVal) {
inbright = maxVal;
}
} else
inbright = 0;
if (bright > intervalVal*2) {
outbright = bright - (intervalVal*2);
if (outbright > maxVal) {
outbright = maxVal;
}
} else
outbright = 0;
setOuterHeart(outbright*rbal,outbright*gbal,outbright*bbal);
setInnerHeart(inbright*rbal,inbright*gbal,inbright*bbal);
setJewelHeart(jbright*rbal,jbright*gbal,jbright*bbal);
}
void heartSleepThrob3(int bright,int maxVal,int intervalVal,float rbal,float gbal, float bbal){
int inbright,outbright,jbright;
outbright = bright;
if (outbright > maxVal) {
outbright = maxVal;
}
if (bright > intervalVal) {
inbright = bright - intervalVal;
if (inbright > maxVal) {
inbright = maxVal;
}
} else
inbright = 0;
if (bright > intervalVal*2) {
jbright = bright - (intervalVal*2);
if (jbright > maxVal) {
jbright = maxVal;
}
} else
jbright = 0;
setOuterHeart(outbright*rbal,outbright*gbal,outbright*bbal);
setInnerHeart(inbright*rbal,inbright*gbal,inbright*bbal);
setJewelHeart(jbright*rbal,jbright*gbal,jbright*bbal);
}
void bodiceWave(int effect_position,int startpos,int totalcount,float balance,float weight){
if (effect_position == 0){
for (int i =0; i<TUTU_COUNT; i++){
tutuindex[i]=random(355);
}
}
for (int i = 0; i < BODICE_COUNT; i++) {
int effect_rg = 0;
int effect_b = 0;
int rampup=totalcount*balance;
int rampdown=totalcount-rampup;
float curpos=float(effect_position-startpos)-(float)bodice[i].delta_heart/(float)(355.0/(float)totalcount);
if (curpos >= 0.0 && curpos < rampup) {
effect_rg=(255 - ((float)bodice[i].delta_heart*0.718))*(curpos/(float)rampup);
effect_b=255*(curpos/(float)rampup);
}
if (curpos >= rampup && curpos <=totalcount ) {
effect_rg=(255 - ((float)bodice[i].delta_heart*.718))*(1.0-((float)(curpos-rampup)/(float)rampdown));
effect_b=255*(1.0-((float)(curpos-rampup)/(float)rampdown));
}
bodice[i].setClr( effect_rg*weight, effect_rg*weight, effect_b*weight);
}
for (int i = 0; i < TUTU_COUNT; i++) {
int effect_rg = 0;
int effect_b = 0;
int rampup=totalcount*balance;
int rampdown=totalcount-rampup;
float curpos=float(effect_position-startpos)-(float)tutuindex[i]/(float)(355.0/(float)totalcount);
if (curpos >= 0.0 && curpos < rampup && tutuindex[i] > 255) {
effect_rg=(255 - ((float)tutuindex[i]*0.718))*(curpos/(float)rampup);
effect_b=255*(curpos/(float)rampup);
}
if (curpos >= rampup && curpos <=totalcount && tutuindex[i] > 100) {
effect_rg=(255 - ((float)tutuindex[i]*.718))*(1.0-((float)(curpos-rampup)/(float)rampdown));
effect_b=255*(1.0-((float)(curpos-rampup)/(float)rampdown));
}
tutu[i].setClr( effect_rg/2, effect_rg/2, effect_b/2);
}
}
void bodiceWave2(int effect_position,int startpos,int totalcount,float balance){
for (int i = 0; i < BODICE_COUNT; i++) {
int effect_r = 0;
int effect_g = 0;
int effect_b = 0;
int rampup=totalcount*balance;
int rampdown=totalcount-rampup;
float curpos=float(effect_position-startpos)-(float)bodice[i].delta_heart/(float)(255.0/(float)totalcount);
if (curpos >= 0.0 && curpos < rampup) {
effect_g=(255 - bodice[i].delta_heart)*(curpos/(float)rampup);
effect_r=255*(curpos/(float)rampup);
effect_b=255*(curpos/(float)rampup);
}
if (curpos >= rampup && curpos <=totalcount ) {
effect_g=(255 - bodice[i].delta_heart)*(1.0-((float)(curpos-rampup)/(float)rampdown));
effect_b=255*(1.0-((float)(curpos-rampup)/(float)rampdown));
effect_r=255*(1.0-((float)(curpos-rampup)/(float)rampdown));
}
bodice[i].setClr( effect_r, effect_g, effect_b);
}
}
#endif //EFFECTS_H