diff options
Diffstat (limited to 'src/sliceitoff/images')
-rw-r--r-- | src/sliceitoff/images/__init__.py | 1 | ||||
-rw-r--r-- | src/sliceitoff/images/images.py | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/sliceitoff/images/__init__.py b/src/sliceitoff/images/__init__.py new file mode 100644 index 0000000..16d361a --- /dev/null +++ b/src/sliceitoff/images/__init__.py @@ -0,0 +1 @@ +from .images import images, load_images diff --git a/src/sliceitoff/images/images.py b/src/sliceitoff/images/images.py new file mode 100644 index 0000000..102ca0f --- /dev/null +++ b/src/sliceitoff/images/images.py @@ -0,0 +1,19 @@ +import os +import pygame + +DEBUG = os.getenv("DEBUG") + +images = {} + +def load_images(scale): + if not images: + with open("assets/images.lst") as image_list_file: + for line in image_list_file: + name, *path = line.strip().split() + filename = os.path.join(*path) + if DEBUG: + print(f"Loading images {name = }, {filename = }") + image = pygame.image.load(filename) + images[name] = pygame.transform.smoothscale_by( + pygame.Surface.convert_alpha(image), + scale) |