From 043d54652fc529504a61fdb46c5cc1992763721d Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 14 Jul 2024 16:18:21 +0100 Subject: x,y scale and docs --- README.md | 5 +++++ sspreview | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index beff533..7784df5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ sspreview spritesheet.png Example +Tips: + +* in "scale", provide two numbers separated with a comma in case you want a different scale factor for x and y (e.g. `20,10`) +* if your spritesheet changes, press `Update` and it will reload the image + Caveats: * my first tinker app diff --git a/sspreview b/sspreview index 7f81684..b407b3d 100755 --- a/sspreview +++ b/sspreview @@ -132,7 +132,14 @@ class Preview(object): self.error("Invalid height") try: - scale = int(self.scale.get()) + scale = self.scale.get() + if "," in scale: + scale = scale.split(",") + if len(scale) != 2: + self.error("Invalid x,y scale factor") + else: + scale = (scale, scale) + scale = [int(x) for x in scale] except Exception: self.error("Invalid scale") @@ -158,7 +165,7 @@ class Preview(object): for x in range(0, w, width): frames.append( image.crop((x, y, x + width, y + height)).resize( - (width * scale, height * scale), None + (width * scale[0], height * scale[1]), None ) ) -- cgit v1.2.3