Created
May 7, 2019 21:32
-
-
Save coltonoscopy/7fbf4ba033b57651541caa9b4eef6fd2 to your computer and use it in GitHub Desktop.
Spritesheet numbering script
This file contains 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
''' | |
Adds numbers to a sprite sheet for easy reference. | |
''' | |
from PIL import Image | |
from PIL import ImageFont | |
from PIL import ImageDraw | |
if __name__ == '__main__': | |
TILE_SIZE = 16 | |
img = Image.open('spritesheet.png') | |
draw = ImageDraw.Draw(img) | |
font = ImageFont.truetype('font.ttf', 8) | |
counter = 1 | |
for y in range(img.height / TILE_SIZE): | |
for x in range(img.width / TILE_SIZE): | |
draw.text((x * TILE_SIZE + 1, y * TILE_SIZE), str(counter), (0, 0, 0), font=font) | |
draw.text((x * TILE_SIZE, y * TILE_SIZE + 1), str(counter), (0, 0, 0), font=font) | |
draw.text((x * TILE_SIZE, y * TILE_SIZE), str(counter), (255, 0, 255), font=font) | |
counter += 1 | |
img.save('spritesheet_numbered.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment