diff --git a/source/jdraw.cpp b/source/jdraw.cpp index 2df06df..71390d0 100644 --- a/source/jdraw.cpp +++ b/source/jdraw.cpp @@ -18,8 +18,10 @@ namespace draw surface *destination = nullptr; // Punter a la actual superficie de destí surface *source = nullptr; // Punter a la actual superficie de oritge - uint32_t palette[256]; // La paleta de colors - uint8_t transparent = 0; // El color transparent + uint32_t palette[256]; // La paleta de colors + uint8_t color_indices[256]; // Indices dels colors per defecte + uint8_t sel_color = 0; // Color seleccionat per defecte + uint8_t transparent = 0; // El color transparent // 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) @@ -37,7 +39,8 @@ namespace draw // Creem la superficie "screen" i la establim com a superficie destinació screen = createSurface(width, height); destination = screen; - transparent = 0; + sel_color = transparent = 0; + for (int i=0;i<256;++i) color_indices[i] = i; } // Finalització del sistema @@ -185,7 +188,7 @@ namespace draw // escriure el byte "color" on toca en el array de pixels de la superficie if (color != transparent && x >= 0 && y >= 0 && x < surface->w && y < surface->h) { - surface->pixels[x + y * surface->w] = color; + surface->pixels[x + y * surface->w] = color_indices[color]; } } @@ -247,6 +250,39 @@ namespace draw } } + void swapcol(const Uint8 c1, const Uint8 c2) + { + color_indices[c1] = c2; + } + + void color(const Uint8 col) + { + sel_color = col; + } + + void hline(const int x, const int y, const int w) + { + for (int i=x;i