forked from jaildesigner-jailgames/jaildoctors_dilemma
Transició a surface: barallantme amb tots els Color que hi ha pel codi
This commit is contained in:
@@ -278,7 +278,7 @@ void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip
|
||||
}
|
||||
|
||||
// Copia una región de la SurfaceData de origen a la SurfaceData de destino reemplazando un color por otro
|
||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8 target_color = 0, SDL_Rect *clip = nullptr, SDL_RendererFlip flip = SDL_FLIP_NONE)
|
||||
void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, SDL_Rect *srcRect, SDL_RendererFlip flip)
|
||||
{
|
||||
if (!surface_data_ || !surface_data_dest_)
|
||||
{
|
||||
@@ -286,10 +286,10 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color = 0, Uint8
|
||||
}
|
||||
|
||||
// Determina la región de origen (clip) a renderizar
|
||||
int sx = (clip) ? clip->x : 0;
|
||||
int sy = (clip) ? clip->y : 0;
|
||||
int w = (clip) ? clip->w : surface_data_->width;
|
||||
int h = (clip) ? clip->h : surface_data_->height;
|
||||
int sx = (srcRect) ? srcRect->x : 0;
|
||||
int sy = (srcRect) ? srcRect->y : 0;
|
||||
int w = (srcRect) ? srcRect->w : surface_data_->width;
|
||||
int h = (srcRect) ? srcRect->h : surface_data_->height;
|
||||
|
||||
// Limitar la región para evitar accesos fuera de rango
|
||||
w = std::min(w, surface_data_->width - sx);
|
||||
|
||||
Reference in New Issue
Block a user