#!/usr/bin/env python3 """Draws the two images that replace Google-branded ones in the Maze game of Block Coding Games: maze-marker.png the 20x34 goal marker (the original is the Google Maps pin): a flag on a pole; maze-icon.png the 100x100 icon of Maze on the index page (the original shows Pegman and the pin): two tiles of the astronaut skin's pipes with the astronaut and the flag. Both are made from the repository's own astro.png / tiles_astro.png plus shapes drawn here (CC0, ours). usage: make-icons.py (needs Pillow)""" import os, sys from PIL import Image, ImageDraw maze, out = sys.argv[1], sys.argv[2] S = 8 # supersampling # --- marker: 20 x 34, pole at x = 10 so the base sits on the middle of the square def flag(w, h, pole_x, top, bottom): im = Image.new('RGBA', (w * S, h * S), (0, 0, 0, 0)) d = ImageDraw.Draw(im) d.rectangle([(pole_x - 1) * S, top * S, (pole_x + 0.5) * S, bottom * S], fill=(70, 70, 80, 255)) d.polygon([(pole_x + 0.5) * S, top * S, (pole_x + 9.5) * S, (top + 4.5) * S, (pole_x + 0.5) * S, (top + 9) * S], fill=(228, 60, 52, 255), outline=(150, 25, 25, 255)) d.ellipse([(pole_x - 3) * S, (bottom - 2.5) * S, (pole_x + 2) * S, (bottom + 0.5) * S], fill=(70, 70, 80, 255)) return im.resize((w, h), Image.LANCZOS) flag(20, 34, 9, 3, 32).save(os.path.join(out, 'maze-marker.png'), optimize=True) # --- icon tiles = Image.open(os.path.join(maze, 'tiles_astro.png')).convert('RGBA') sprite = Image.open(os.path.join(maze, 'astro.png')).convert('RGBA') icon = Image.new('RGBA', (100, 100), (0, 0, 0, 0)) for col in (0, 1): # a lamp end and a straight pipe, side by side t = tiles.crop((col * 50, 100, col * 50 + 50, 150)) icon.paste(t, (col * 50, 48), t) man = sprite.crop((0, 0, 49, 51)) icon.paste(man, (14, 5), man) f = flag(20, 34, 9, 3, 32) icon.paste(f, (68, 22), f) icon.save(os.path.join(out, 'maze-icon.png'), optimize=True)