Stefan Schuermans commited on 2016-12-30 14:08:32
Showing 1 changed files, with 44 additions and 3 deletions.
... | ... |
@@ -14,7 +14,8 @@ |
14 | 14 |
* @param[in,out] *pMovie pointer to old/new/changed movie |
15 | 15 |
* @param[in] str_format format of new video to generate, |
16 | 16 |
* may be NULL for appending to video |
17 |
- * @param[in] str_mode test movie mode: black, white, dots, lines, trans |
|
17 |
+ * @param[in] str_mode test movie mode: black, white, dots, lines, trans, |
|
18 |
+ * rainbow |
|
18 | 19 |
* @param[in] str_duration duration of each frame in ms (as string) |
19 | 20 |
*/ |
20 | 21 |
static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format, |
... | ... |
@@ -23,7 +24,7 @@ static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format, |
23 | 24 |
unsigned int height, width, channels, colors; |
24 | 25 |
enum { |
25 | 26 |
ModeNone, ModeBlack, ModeWhite, ModeGradient, |
26 |
- ModeDots, ModeLines, ModeTrans |
|
27 |
+ ModeDots, ModeLines, ModeTrans, ModeRainbow, |
|
27 | 28 |
} mode = ModeNone; |
28 | 29 |
int fmt_ok, append, duration; |
29 | 30 |
|
... | ... |
@@ -59,6 +60,8 @@ static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format, |
59 | 60 |
mode = ModeLines; |
60 | 61 |
else if (strcmp(str_mode, "trans") == 0) |
61 | 62 |
mode = ModeTrans; |
63 |
+ else if (strcmp(str_mode, "rainbow") == 0) |
|
64 |
+ mode = ModeRainbow; |
|
62 | 65 |
//check |
63 | 66 |
if (! fmt_ok) |
64 | 67 |
printf("invalid movie format \"%s\" for \"-t\" or \"-ta\"\n", str_format); |
... | ... |
@@ -202,6 +205,44 @@ static void gen_test_movie(stBlinkenMovie **ppMovie, const char *str_format, |
202 | 205 |
} |
203 | 206 |
break; |
204 | 207 |
|
208 |
+ case ModeRainbow: |
|
209 |
+ for (b = 0; b < width * height; b++) { |
|
210 |
+ pFrame = BlinkenFrameNew(height, width, channels, |
|
211 |
+ colors - 1, duration); |
|
212 |
+ for (yy = 0; yy < height; yy++) { |
|
213 |
+ for (xx = 0; xx < width; xx++) { |
|
214 |
+ for (cc = 0; cc < channels; cc++) { |
|
215 |
+ y = b + yy + xx + cc * 8; |
|
216 |
+ switch (y % 24) { |
|
217 |
+ case 0: oo = 0; break; |
|
218 |
+ case 1: oo = 1; break; |
|
219 |
+ case 2: oo = 2; break; |
|
220 |
+ case 3: oo = 3; break; |
|
221 |
+ case 4: oo = 4; break; |
|
222 |
+ case 5: oo = 4; break; |
|
223 |
+ case 6: oo = 4; break; |
|
224 |
+ case 7: oo = 4; break; |
|
225 |
+ case 8: oo = 4; break; |
|
226 |
+ case 9: oo = 4; break; |
|
227 |
+ case 10: oo = 4; break; |
|
228 |
+ case 11: oo = 4; break; |
|
229 |
+ case 12: oo = 4; break; |
|
230 |
+ case 13: oo = 3; break; |
|
231 |
+ case 14: oo = 2; break; |
|
232 |
+ case 15: oo = 1; break; |
|
233 |
+ default: oo = 0; break; |
|
234 |
+ } |
|
235 |
+ oo = oo * colors / 4; |
|
236 |
+ if (oo > colors - 1) |
|
237 |
+ oo = colors - 1; |
|
238 |
+ BlinkenFrameSetPixel(pFrame, yy, xx, cc, oo); |
|
239 |
+ } |
|
240 |
+ } |
|
241 |
+ } |
|
242 |
+ BlinkenMovieAppendFrame(*ppMovie, pFrame); |
|
243 |
+ } |
|
244 |
+ break; |
|
245 |
+ |
|
205 | 246 |
} // switch( mode ) |
206 | 247 |
|
207 | 248 |
printf("test movie generated, using format %ux%u-%u/%u and mode %s\n", |
... | ... |
@@ -435,7 +476,7 @@ int main(int argCnt, char **args) |
435 | 476 |
" mirror movie diagonally (/)\n" |
436 | 477 |
" -o <file>\n" |
437 | 478 |
" write movie to file (*.blm, *.bmm, *.bml, *.bbm" MNGEXT GIFEXT ")\n\n" |
438 |
- "test_modes: black, white, gradient, dots, lines, trans\n\n" |
|
479 |
+ "test_modes: black, white, gradient, dots, lines, trans, rainbow\n\n" |
|
439 | 480 |
"old syntax: %s <input-file> [<output-file>]\n\n", |
440 | 481 |
args[0], args[0]); |
441 | 482 |
return 0; |
442 | 483 |