From 5f0f3146f9fea6e79136d32ee153b008e48791e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 02:02:55 +0000 Subject: [PATCH 1/4] Initial plan From a337bcfd5e082e667d42f789ded82f4bbf9c868d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 02:05:28 +0000 Subject: [PATCH 2/4] Add drawImage method to support drawing images with scaling Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> --- .gitignore | 4 +++- src/main/python/preponderous/graphik/graphik.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1de5659..dbd1181 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -target \ No newline at end of file +target +__pycache__ +*.pyc \ No newline at end of file diff --git a/src/main/python/preponderous/graphik/graphik.py b/src/main/python/preponderous/graphik/graphik.py index 331cc91..465ab2b 100644 --- a/src/main/python/preponderous/graphik/graphik.py +++ b/src/main/python/preponderous/graphik/graphik.py @@ -43,4 +43,9 @@ def drawButton(self, xpos, ypos, width, height, colorBox, colorText, sizeText, t if (xpos + width > mouse[0] > xpos and ypos + height > mouse[1] > ypos): click = pygame.mouse.get_pressed() if click[0] == 1: - function() \ No newline at end of file + function() + + def drawImage(self, file_path, xpos, ypos, width, height): + image = pygame.image.load(file_path) + image = pygame.transform.scale(image, (width, height)) + self.gameDisplay.blit(image, (xpos, ypos)) \ No newline at end of file From 54c45e9a8cf518eed55c65a2190152838c38ac8a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 02:06:42 +0000 Subject: [PATCH 3/4] Add error handling to drawImage method Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> --- src/main/python/preponderous/graphik/graphik.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/python/preponderous/graphik/graphik.py b/src/main/python/preponderous/graphik/graphik.py index 465ab2b..599e32c 100644 --- a/src/main/python/preponderous/graphik/graphik.py +++ b/src/main/python/preponderous/graphik/graphik.py @@ -46,6 +46,9 @@ def drawButton(self, xpos, ypos, width, height, colorBox, colorText, sizeText, t function() def drawImage(self, file_path, xpos, ypos, width, height): - image = pygame.image.load(file_path) - image = pygame.transform.scale(image, (width, height)) - self.gameDisplay.blit(image, (xpos, ypos)) \ No newline at end of file + try: + image = pygame.image.load(file_path) + image = pygame.transform.scale(image, (width, height)) + self.gameDisplay.blit(image, (xpos, ypos)) + except (pygame.error, FileNotFoundError) as e: + raise type(e)(f"Failed to load image from '{file_path}': {e}") \ No newline at end of file From 9ace29f77ff5156f91d8f4e9da069e2c40486eed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Feb 2026 02:19:33 +0000 Subject: [PATCH 4/4] Address PR feedback: rename parameter to filePath and improve exception handling Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com> --- src/main/python/preponderous/graphik/graphik.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/python/preponderous/graphik/graphik.py b/src/main/python/preponderous/graphik/graphik.py index 599e32c..9a2d8eb 100644 --- a/src/main/python/preponderous/graphik/graphik.py +++ b/src/main/python/preponderous/graphik/graphik.py @@ -45,10 +45,13 @@ def drawButton(self, xpos, ypos, width, height, colorBox, colorText, sizeText, t if click[0] == 1: function() - def drawImage(self, file_path, xpos, ypos, width, height): + def drawImage(self, filePath, xpos, ypos, width, height): try: - image = pygame.image.load(file_path) + image = pygame.image.load(filePath) image = pygame.transform.scale(image, (width, height)) self.gameDisplay.blit(image, (xpos, ypos)) - except (pygame.error, FileNotFoundError) as e: - raise type(e)(f"Failed to load image from '{file_path}': {e}") \ No newline at end of file + except FileNotFoundError as e: + # Preserve the original exception and chain it + raise FileNotFoundError(f"Failed to load image from '{filePath}': {e}") from e + except pygame.error as e: + raise pygame.error(f"Failed to load image from '{filePath}': {e}") from e \ No newline at end of file