From 4b5e044214ba3897a3056fa4edb7ada7504bfa36 Mon Sep 17 00:00:00 2001 From: Kyle Benesch <4b796c65+github@gmail.com> Date: Tue, 6 May 2025 01:24:30 -0700 Subject: [PATCH 1/2] Fix incorrect imageio calls in examples --- .vscode/settings.json | 1 + tcod/tileset.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a6f96553..78327ad2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -189,6 +189,7 @@ "iinfo", "IJKL", "imageio", + "imread", "INCOL", "INROW", "interactable", diff --git a/tcod/tileset.py b/tcod/tileset.py index 56213fe7..f2a5ac33 100644 --- a/tcod/tileset.py +++ b/tcod/tileset.py @@ -126,20 +126,20 @@ def set_tile(self, codepoint: int, tile: ArrayLike | NDArray[np.uint8]) -> None: # Normal usage when a tile already has its own alpha channel. # The loaded tile must be the correct shape for the tileset you assign it to. # The tile is assigned to a private use area and will not conflict with any exiting codepoint. - tileset.set_tile(0x100000, imageio.load("rgba_tile.png")) + tileset.set_tile(0x100000, imageio.imread("rgba_tile.png")) # Load a greyscale tile. - tileset.set_tile(0x100001, imageio.load("greyscale_tile.png"), pilmode="L") + tileset.set_tile(0x100001, imageio.imread("greyscale_tile.png"), mode="L") # If you are stuck with an RGB array then you can use the red channel as the input: `rgb[:, :, 0]` # Loads an RGB sprite without a background. - tileset.set_tile(0x100002, imageio.load("rgb_no_background.png", pilmode="RGBA")) + tileset.set_tile(0x100002, imageio.imread("rgb_no_background.png", mode="RGBA")) # If you're stuck with an RGB array then you can pad the channel axis with an alpha of 255: # rgba = np.pad(rgb, pad_width=((0, 0), (0, 0), (0, 1)), constant_values=255) # Loads an RGB sprite with a key color background. KEY_COLOR = np.asarray((255, 0, 255), dtype=np.uint8) - sprite_rgb = imageio.load("rgb_tile.png") + sprite_rgb = imageio.imread("rgb_tile.png") # Compare the RGB colors to KEY_COLOR, compress full matches to a 2D mask. sprite_mask = (sprite_rgb != KEY_COLOR).all(axis=2) # Generate the alpha array, with 255 as the foreground and 0 as the background. From 484b6a250aaeb17f7b1dc4268a8e4ee4c560a107 Mon Sep 17 00:00:00 2001 From: Kyle Benesch <4b796c65+github@gmail.com> Date: Tue, 6 May 2025 01:25:54 -0700 Subject: [PATCH 2/2] Pre-commit update --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f044c36..00cc1d41 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,7 +17,7 @@ repos: - id: fix-byte-order-marker - id: detect-private-key - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.4 + rev: v0.11.8 hooks: - id: ruff args: [--fix-only, --exit-non-zero-on-fix]