#!/usr/bin/env python3 """Draws the chili pepper icons (wi_chilirun.png 58x58, wis_chilirun.png 16x16) that replace the Ravenmore icon of Zatacka X, whose licence is not stated. Original drawing by FredyGames, released under CC0 1.0. Usage: python3 -I make-chili.py (needs Pillow).""" import math, sys from PIL import Image, ImageDraw def pepper(size): s = 16 big = size * s im = Image.new('RGBA', (big, big), (0, 0, 0, 0)) d = ImageDraw.Draw(im) # centre line of the body: a curve from the stem (top right) down to the tip (bottom left) pts = [] n = 60 for i in range(n + 1): t = i / n x = (0.66 - 0.50 * t - 0.10 * math.sin(t * math.pi)) * big y = (0.20 + 0.66 * t) * big pts.append((x, y)) def width(t): return (0.17 * (1 - t) ** 0.7 + 0.012) * big * (1 if t > 0.04 else 0.4 + t * 15) left, right = [], [] for i, (x, y) in enumerate(pts): t = i / n if i == 0: dx, dy = pts[1][0] - x, pts[1][1] - y else: dx, dy = x - pts[i - 1][0], y - pts[i - 1][1] l = math.hypot(dx, dy) or 1 nx, ny = -dy / l, dx / l w = width(t) left.append((x + nx * w, y + ny * w)) right.append((x - nx * w, y - ny * w)) poly = left + right[::-1] d.polygon(poly, fill=(214, 40, 30, 255), outline=(120, 12, 20, 255)) d.line(poly + [poly[0]], fill=(120, 12, 20, 255), width=max(1, int(0.035 * big))) # highlight hl = [(x + 0.04 * big * 0.5, y) for (x, y) in left[8:34]] d.line(hl, fill=(255, 140, 110, 255), width=max(1, int(0.03 * big))) # stem and cap cx, cy = pts[0] cap = [(cx - 0.20 * big, cy - 0.02 * big), (cx + 0.10 * big, cy - 0.06 * big), (cx + 0.14 * big, cy + 0.05 * big), (cx - 0.12 * big, cy + 0.09 * big)] d.polygon(cap, fill=(70, 150, 40, 255), outline=(30, 80, 20, 255)) stem = [(cx + 0.00 * big, cy - 0.04 * big), (cx + 0.07 * big, cy - 0.20 * big), (cx + 0.14 * big, cy - 0.24 * big), (cx + 0.17 * big, cy - 0.20 * big), (cx + 0.10 * big, cy - 0.15 * big), (cx + 0.08 * big, cy - 0.03 * big)] d.polygon(stem, fill=(70, 150, 40, 255), outline=(30, 80, 20, 255)) return im.resize((size, size), Image.LANCZOS) out = sys.argv[1] pepper(58).save(out + '/wi_chilirun.png', optimize=False) pepper(16).save(out + '/wis_chilirun.png', optimize=False)