Created
August 9, 2018 13:50
-
-
Save Hoolean/3c09c598f4384904deccc60e7af0ed14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
import glob | |
import math | |
tiles = [pygame.image.load(tile) for tile in glob.glob('*.png')] | |
tile_length = max([max([tile.get_width(), tile.get_height()]) for tile in tiles]) | |
side = math.ceil(math.sqrt(len(tiles))) | |
stitched = pygame.surface([side * tile_length, side * tile_length], pygame.SRCALPHA, 32) | |
for index, tile in tiles: | |
x = index % side | |
y = int(index / side) | |
stitched.blit(tile, (x * tile_length, y * tile_length)) | |
pygame.image.save(stitched, 'stitched.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment