tiler.py
So I had to create a 1024*1024 background image consisting of 2 different 64x64 tiles. The script had to choose randomly between both tiles, with a preference for one over the other. Below is the resulting code. Enjoy!
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
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) |