forked from diodeface/ToasterBlaster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransitions.cpp
More file actions
272 lines (230 loc) · 8.86 KB
/
Transitions.cpp
File metadata and controls
272 lines (230 loc) · 8.86 KB
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#include "Transitions.h"
/**
* Define your transitions here. Read OverlaySequence.h for more info.
*/
using namespace Config::Displays;
namespace Transitions {
Translate* translateAll = new Translate (ALL, 0, 0);
Translate* vTranslate = new Translate(EYES, 0, 0);
Translate* hTranslate = new Translate(EYES, 0, 0);
Translate* translateLeft = new Translate(LEFT_SIDE, 0, 0);
Translate* translateRight = new Translate(RIGHT_SIDE, 0, 0);
Blink* blinkEyes = new Blink(EYES, 0);
Expand* expandEyes = new Expand(EYES, 0);
TVStatic* staticAll = new TVStatic(ALL, 0);
Glitch* glitchAll = new Glitch(ALL, 0, 0);
Expand* expandAll = new Expand(ALL, 0);
RandomizeFace* randomizeAll = new RandomizeFace (ALL, 10 MILLIS);
void crossfadeEffect (u8* buffer, Display* display) {{
u8 size = display->getSize();
for (u8 x = 0; x < size; x++) {
for (u8 y = 0; y < Config::DISPLAY_HEIGHT; y++) {
display->particleSystem->particles.push_back(
{(f32)x, (f32)y, 0, 0, 0, 0, (i32)random(150 MILLIS), size, getPixel(buffer, size, x, y)}
);
}
}
}}
LambdaEffect* crossfadeMouthNose = new LambdaEffect(MOUTH | NOSE, [](u8* buffer, Display* display) {crossfadeEffect(buffer, display);}, false);
// Blink ---------------------------------
Transition blink {
{
{
{
new Tween<u8>(&(blinkEyes->amount), 0, 5, 100 MILLIS, TWEEN_LINEAR),
new Tween<i8>(&(vTranslate->y), 0, 3, 100 MILLIS, TWEEN_LINEAR),
new Tween<u8>(&(expandEyes->iterations), 0, 3, 100 MILLIS, TWEEN_LINEAR, false),
vTranslate, expandEyes, blinkEyes
}, 100 MILLIS
},
{
{
crossfadeMouthNose,
new Tween<u8>(&(blinkEyes->amount), 5, 0, 100 MILLIS, TWEEN_LINEAR),
new Tween<i8>(&(vTranslate->y), 3, 0, 100 MILLIS, TWEEN_LINEAR),
new Tween<u8>(&(expandEyes->iterations), 3, 0, 100 MILLIS, TWEEN_LINEAR, false),
vTranslate, expandEyes, blinkEyes
}, 100 MILLIS
},
END_SEQUENCE
}, 2
};
// ---------------------------------------
// Pulse ---------------------------------
Transition pulse {
{
SKIP_FRAME, // skip frame so that particle edge can catch up with the new bitmap
{{new ParticleEdge(ALL, 1, 0, 1.9f, 0, 2.0f, 0)}, 0},
END_SEQUENCE
}
};
// ---------------------------------------
// Slide ---------------------------------
Transition slide {
{
{
{
new Tween<i8>(&(translateLeft->x), 0, -64, 350 MILLIS, TWEEN_IN_BACK),
new Tween<i8>(&(translateRight->x), 0, 64, 350 MILLIS, TWEEN_IN_BACK),
translateLeft, translateRight
},
500 MILLIS
},
{
{
new Tween<i8>(&(translateLeft->x), 32, 0, 1000 MILLIS, TWEEN_OUT_ELASTIC),
new Tween<i8>(&(translateRight->x), -32, 0, 1000 MILLIS, TWEEN_OUT_ELASTIC),
translateLeft, translateRight
},
1500 MILLIS
},
END_SEQUENCE
}, 2
};
// ---------------------------------------
// Drop ----------------------------------
Transition drop {
{
{{new Tween<i8>(&(vTranslate->y), 0, 8, 300 MILLIS, TWEEN_IN), vTranslate}, 300 MILLIS},
{
{
crossfadeMouthNose,
new Tween<i8>(&(vTranslate->y), -8, 0, 700 MILLIS, TWEEN_OUT_BOUNCE), vTranslate
}, 700 MILLIS
},
END_SEQUENCE
}, 2
};
// ---------------------------------------
// TV Static -----------------------------
Transition switchChannel {
{
{{new Tween<u8>(&(staticAll->intensity), 30, 0, 600 MILLIS, TWEEN_LINEAR), staticAll}, 600 MILLIS},
END_SEQUENCE
}
};
// ---------------------------------------
// Glitch --------------------------------
Transition glitch {
{
{
{
new Tween<u8>(&(glitchAll->intensity), 100, 0, 750 MILLIS, TWEEN_LINEAR),
new Tween<u8>(&(glitchAll->maxShift), 8, 1, 750 MILLIS, TWEEN_LINEAR),
glitchAll
}, 750 MILLIS
},
END_SEQUENCE
}, 0
};
// ---------------------------------------
// Expand --------------------------------
Transition expand {
{
{{new Tween<u8>(&(expandAll->iterations), 0, 6, 300 MILLIS, TWEEN_IN_EXPONENTIAL), expandAll}, 300 MILLIS},
{{new Tween<u8>(&(expandAll->iterations), 6, 0, 300 MILLIS, TWEEN_OUT_EXPONENTIAL), expandAll}, 300 MILLIS},
END_SEQUENCE
}, 2
};
// ---------------------------------------
// Explode -------------------------------
Transition explode {
{
{{new LambdaEffect(ALL, [](u8* buffer, Display* display) {
u8 size = display->getSize();
for (u8 x = 0; x < size; x++) {
for (u8 y = 0; y < Config::DISPLAY_HEIGHT; y++) {
display->particleSystem->emit(
1, size, (f32)x, (f32)y,
-0.4f, -1.0f,
0.4f, 0.0f,
0.0f, 0.01f,
0.0f, 0.01f,
getPixel(buffer, size, x, y)
);
}
}
})}, 0 MILLIS},
END_SEQUENCE
}, 1
};
// ---------------------------------------
// Doom-like melt ------------------------
Transition doomMelt {
{
{{new LambdaEffect(ALL, [](u8* buffer, Display* display) {
u8 size = display->getSize();
for (u8 x = 0; x < size; x++) {
f32 meltSpeed = 0.01 * (f32)random(1, 5);
for (u8 y = 0; y < Config::DISPLAY_HEIGHT; y++) {
display->particleSystem->emit(
1, size, (f32)x, (f32)y,
0, 0,
0, 0,
0.0f, meltSpeed,
0.0f, meltSpeed,
getPixel(buffer, size, x, y)
);
}
}
})}, 0 MILLIS},
END_SEQUENCE
}, 1
};
// ---------------------------------------
// Crossfade -----------------------------
Transition crossfade {
{
{{new LambdaEffect(ALL, [](u8* buffer, Display* display) {crossfadeEffect(buffer, display);})}, 0 MILLIS},
END_SEQUENCE
}, 1
};
// ---------------------------------------
// Shuffle -------------------------------
Transition shuffle {
{
{
{
new Tween<Timestamp>(&(randomizeAll->period), 10 MILLIS, 250 MILLIS, 1 SECONDS, TWEEN_LINEAR),
randomizeAll,
mirrorLeft
}, 1 SECONDS
},
END_SEQUENCE
}, 1
};
// ---------------------------------------
// Lose power ----------------------------
Transition losePower {
{
{{new LosePower(ALL, 10)}, 100 MILLIS},
{{new LosePower(ALL, 25)}, 100 MILLIS},
{{new LosePower(ALL, 50)}, 100 MILLIS},
{{new LosePower(ALL, 75)}, 100 MILLIS, -1, 3},
{{new LosePower(ALL, 25)}, 100 MILLIS, -1, 2},
END_SEQUENCE
}, 4
};
// ---------------------------------------
// Fizz ----------------------------------
namespace {
LambdaEffect* fizzEmitter = new LambdaEffect(ALL, [](u8* buffer, Display* display) {
u8 size = display->getSize();
for (u8 i = 0; i < size; i++) {
if (random(20) > 0) continue;
display->particleSystem->emit(1, size, i, 7, -0.1f, -0.5f, 0.1f, -2.0f);
}
});
}
Transition fizz {
{
{{new Tween<i8>(&(translateAll->y), 0, -6, 200 MILLIS, TWEEN_IN), translateAll, fizzEmitter}, 200 MILLIS},
{{new Tween<i8>(&(translateAll->y), 6, 0, 200 MILLIS, TWEEN_OUT), translateAll, fizzEmitter}, 200 MILLIS},
END_SEQUENCE
}, 2
};
// ---------------------------------------
// Special -------------------------------
// Choose randomly from the common and rare transitions provided to this sequence player
Transition any {{}};
}