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
|
/*
* Copyright 1994-2022 Olivier Girondel
*
* This file is part of lebiniou.
*
* lebiniou is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* lebiniou is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
*/
#include "context.h"
#include "images.h"
/*
* "Fade previous sequence" splash effect
*
* on_init: Store a copy of last sequence / current buffer
*
* Then on each run, mix the buffer at random with current,
* and decrease pixels from the copy.
*
* This splash will run for 64 frames.
*/
uint32_t version = 0;
uint32_t options = BO_SPLASH | BO_FIRST | BO_NORANDOM;
char desc[] = "Fade previous sequence";
char dname[] = "Sequence fadeout";
static Pixel_t splashing = 64;
static Buffer8_t *last = NULL;
void
on_switch_on(Context_t *ctx)
{
splashing = 64;
Buffer8_copy(active_buffer(ctx), last);
}
int8_t
create(Context_t *ctx)
{
last = Buffer8_new();
return 1;
}
void
destroy(Context_t *ctx)
{
Buffer8_delete(last);
}
static void
splash2(void)
{
Pixel_t *p = last->buffer;
for (uint32_t i = 0; i < BUFFSIZE; i++, p++) {
if (*p >= 20) {
*p *= 0.6;
} else {
if (*p >= 1) {
(*p)--;
}
}
}
splashing--;
}
void
run(Context_t *ctx)
{
if (splashing) {
splash2();
Buffer8_t *buffs[2] = { active_buffer(ctx), last };
Context_mix_buffers(ctx, buffs);
}
Buffer8_copy(active_buffer(ctx), passive_buffer(ctx));
}
|