aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-07-14 16:18:21 +0100
committerJuan J. Martinez <jjm@usebox.net>2024-07-14 16:18:21 +0100
commit043d54652fc529504a61fdb46c5cc1992763721d (patch)
tree86eab2653896c95910dbdeb51aa4d4f7ae9bef53
parent95c26349d6b2f34214e6b069cb6328705b87133c (diff)
downloadsspreview-043d54652fc529504a61fdb46c5cc1992763721d.tar.gz
sspreview-043d54652fc529504a61fdb46c5cc1992763721d.zip
x,y scale and docs
-rw-r--r--README.md5
-rwxr-xr-xsspreview11
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
<img src="https://git.usebox.net/sspreview/plain/example.png" alt="Example" style="width:auto;">
+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
)
)