Skip to content

Instantly share code, notes, and snippets.

@coltonoscopy
Created May 7, 2019 21:32
Show Gist options
  • Save coltonoscopy/7fbf4ba033b57651541caa9b4eef6fd2 to your computer and use it in GitHub Desktop.
Save coltonoscopy/7fbf4ba033b57651541caa9b4eef6fd2 to your computer and use it in GitHub Desktop.
Spritesheet numbering script
'''
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