git repos / sago_multi_scrambler_puzzle2

commit 4d672c23

Poul Sander · 2025-11-19 18:55
4d672c236baf517e251e898b3f08b64b0a85cb50 patch · browse files
parent 0c4ab5aa2988517b6f93780a0d41aed0921ecb9e

Add picture in the background during rectangle mode

Changed files

M src/PuzzleSingleImageState.cpp before
diff --git a/src/PuzzleSingleImageState.cpp b/src/PuzzleSingleImageState.cpp index d87ce0a..5e7ea89 100644 --- a/src/PuzzleSingleImageState.cpp +++ b/src/PuzzleSingleImageState.cpp
@@ -82,6 +82,30 @@ void PuzzleSingleImageState::Draw(SDL_Renderer* target) {
SDL_RenderCopy(target, this->pictureTex, NULL, &rect);
}
else {
+ // In rectangular mode, draw the original image as background with cutouts
+ if (rectangularMode) {
+ // Draw a black background first
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &rect);
+
+ // Draw the full background image slightly dimmed
+ SDL_SetTextureAlphaMod(this->pictureTex, 128);
+ SDL_RenderCopy(target, this->pictureTex, NULL, &rect);
+ SDL_SetTextureAlphaMod(this->pictureTex, 255);
+
+ // Draw black rectangles where the pieces should go (cutouts)
+ for (size_t i = 0; i < pieces_physical.size(); ++i) {
+ const SDL_Rect& piece = pieces_physical[i];
+ SDL_Rect cutout;
+ cutout.x = rect.x + piece.x;
+ cutout.y = rect.y + piece.y;
+ cutout.w = piece.w;
+ cutout.h = piece.h;
+ SDL_SetRenderDrawColor(target, 0, 0, 0, 255);
+ SDL_RenderFillRect(target, &cutout);
+ }
+ }
+
for (size_t i = 0; i < pieces_physical.size(); ++i) {
SDL_Rect destination = pieces_physical[i];
destination.x += rect.x;