diff --git a/source/jdraw.cpp b/source/jdraw.cpp index 9a281a6..c7d51f9 100644 --- a/source/jdraw.cpp +++ b/source/jdraw.cpp @@ -30,6 +30,9 @@ namespace draw SDL_Rect viewport; + bool fading_out = false; + bool fading_in = false; + // Inicialització de tot el que fa falta per a carregar gràfics i pintar en pantalla void init(const std::string &titol, const uint16_t width, const uint16_t height, const int zoom) { @@ -350,6 +353,26 @@ namespace draw vline(x+w-1,y,h); } + void fadein() + { + + } + + void fadeout() + { + fading_out = false; + for (int i=0; i<256; ++i) + { + // [TODO] ARREGLAR, les entrades en la paleta son uint32_t, hi ha que separar en rgba i decrementar cada canal per separat + if (palette[i] > 16) { + palette[i] = palette[i]-16; + fading_out = true; + } else { + palette[i] = 0; + } + } + } + void print(const char* text, const int x, const int y, const Uint8 color, const Uint8 borde) { surface* tmp = source; @@ -384,6 +407,9 @@ namespace draw int sdl_pitch; // Ací estarà guardat el pitch de la textura, com es de 32 bits, no m'afecta const uint32_t size = screen->w * screen->h; // tamany de la superficie + if (fading_in) fadein(); + if (fading_out) fadeout(); + // Bloquejem la textura SDL i agafem els seus pixels (son enters de 32 bits amb format 0xAARRGGBB) SDL_LockTexture(sdl_texture, NULL, (void **)&sdl_pixels, &sdl_pitch); diff --git a/source/jdraw.h b/source/jdraw.h index 9dc371c..f7cdad6 100644 --- a/source/jdraw.h +++ b/source/jdraw.h @@ -93,6 +93,9 @@ namespace draw void fillrect(const int x, const int y, const int w, const int h); void rect(const int x, const int y, const int w, const int h); + void fadein(); + void fadeout(); + void print(const char* text, const int x, const int y, const uint8_t color, const uint8_t borde); /// @brief Refresca la pantalla