From d26bb2858ccbf9bf5b30749d5b62a09252c388aa Mon Sep 17 00:00:00 2001 From: fanta Date: Tue, 3 Mar 2026 12:35:12 +0100 Subject: [PATCH] f1 para activar transicion backtoblack fader --- presentator.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/presentator.c b/presentator.c index c525a91..d08addc 100644 --- a/presentator.c +++ b/presentator.c @@ -5,7 +5,7 @@ #include // Fanta 2026 -// Presentator 0.1 +// Presentator 0.2 // Variables int modPlaying; @@ -13,7 +13,7 @@ char * modName = NULL; int modVolume = 100; int iv; char *imgVol[] = {"res/vol100.png","res/vol090.png","res/vol080.png","res/vol070.png","res/vol060.png","res/vol050.png","res/vol040.png","res/vol030.png","res/vol020.png","res/vol010.png","res/vol000.png"}; -char windowTitle[16] = "Presentator 0.1"; +char windowTitle[16] = "Presentator 0.2"; int windowWidth = 1024; int windowHeight = 768; char * slidesIndex = "slides/index.txt"; @@ -27,6 +27,8 @@ SDL_Texture *textureSlide = NULL; SDL_Texture *textureProgressRect = NULL; SDL_Event evento; xmp_context ctx; +int transition_active = 0; + // Functions int createWindow(void){ @@ -105,6 +107,23 @@ int loadSlide(int nslide){ return 0; } +int transition_BackToBlack(void){ + SDL_SetRenderDrawBlendMode(render, SDL_BLENDMODE_BLEND); + SDL_Rect barra = { 0, 0, windowWidth, windowHeight }; + + int z; + for (z = 250; z > 0; z = z -10) { + loadSlide(actualNSlide); + refreshVolumeArea(iv); + SDL_SetRenderDrawColor(render, 0, 0, 0, z); + SDL_RenderFillRect(render, &barra); + SDL_RenderPresent(render); + } + + return 0; +} + + int renderAll(void){ loadSlide(actualNSlide); refreshVolumeArea(iv); @@ -112,6 +131,8 @@ int renderAll(void){ return 0; } + + // Main int main(int argc, char ** argv) { createWindow(); @@ -120,6 +141,10 @@ int main(int argc, char ** argv) { refreshVolumeArea(0); SDL_RenderPresent(render); + + + + while (!quit) { SDL_WaitEvent(&evento); @@ -184,12 +209,21 @@ int main(int argc, char ** argv) { break; case SDLK_RIGHT: actualNSlide = actualNSlide + 1; + if (transition_active == 1 ){ transition_BackToBlack(); }; renderAll(); break; case SDLK_LEFT: actualNSlide = actualNSlide - 1; + if (transition_active == 1 ){ transition_BackToBlack(); }; renderAll(); break; + case SDLK_F1: + if (transition_active == 0){ + transition_active = 1; + }else{ + transition_active = 0; + } + break; } break; }