From 30646ec2361a782a2bd82d2b9659a8f4fb3035df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ribeiro?= Date: Wed, 18 Nov 2015 01:24:10 -0500 Subject: [PATCH] bugfix on the position of the frames --- generator | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/generator b/generator index a6451c8..f899358 100755 --- a/generator +++ b/generator @@ -60,19 +60,21 @@ def resize_image(filename, size): def generate_sprite_from_images(framesPath, columns, size, output): framesMap = sorted(glob.glob(framesPath + "*.png")) images = [Image.open(filename) for filename in framesMap] - print "%d frames will be combined." % len(images) masterWidth = size[0] * columns masterHeight = size[1] * int(math.ceil(float(len(images)) / columns)) finalImage = Image.new(mode='RGBA', size=(masterWidth, masterHeight), color=(0,0,0,0)) merge_frames(images, finalImage, columns, size, output) def merge_frames(images, finalImage, columns, size, output): - line = 0 - for i, image in enumerate(images): - locationX = size[0] * i + line, column = 0, 0 + for image in images: + locationX = size[0] * column locationY = size[1] * line finalImage.paste(image, (locationX, locationY)) - if i != 0 and i % columns == 0: line += 1 + column += 1 + if column == columns: + line += 1 + column = 0 finalImage.save(output, transparency=0) shutil.rmtree(TMP_FRAMES_PATH, ignore_errors=True)