Skip to content

Instantly share code, notes, and snippets.

@ramdyne
Last active December 30, 2016 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramdyne/7b9cb00c60fb626773f6045f00d52d1b to your computer and use it in GitHub Desktop.
Save ramdyne/7b9cb00c60fb626773f6045f00d52d1b to your computer and use it in GitHub Desktop.
from PIL import Image
from random import randint
default_image_name = "tile_default.png"
attention_image_name = "tile_attention.png"
output_image_name = "tile_output.png"
tile_size_pixels = 64
new_image = Image.new("RGB", (1024, 1024))
default_tile = Image.open(default_image_name)
attention_tile = Image.open(attention_image_name)
for row in range(0,16) :
for column in range(0,16) :
dice = randint(0,15)
if dice >=14 :
paste_image = attention_tile
else :
paste_image = default_tile
new_image.paste(paste_image, (row*64, column*64))
new_image.save(output_image_name)
@ramdyne
Copy link
Author

ramdyne commented Dec 30, 2016

So I had to create an image of 1024x1024 pixels , consisting of loads of 64x64 pixel tiles. The tiles had to be randomly chosen from 2 tiles (default and attention in the code) with a preference for the default image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment