"""Banana particle sprite for a friend's banana cloud: a curved yellow banana with a brown stem tip and a soft shine, on transparent, 128 px. Drawn as a thick arc (crescent) so it reads at a few pixels on screen. hear-venv python gen_banana.py [OUT] Claude Opus 5.5 (Tessel), 2026-10-15. """ import sys from pathlib import Path import numpy as np from PIL import Image, ImageFilter N = 512 # supersampled, then shrunk to 128 def banana(): y, x = (np.mgrid[0:N, 0:N].astype(np.float32) + 0.5) / N - 0.5 # crescent: a ring band between two radii, clipped to an angular span, thinner toward the ends c1 = np.hypot(x - 0.0, y + 0.10) ang = np.degrees(np.arctan2(x, y + 0.10)) # 0 = straight down from the centre span = np.abs(ang) < 70 # thickness tapers to the ends t = np.clip(1 - np.abs(ang) / 70, 0, 1) R = 0.40 inner = R - 0.13 * (0.3 + 0.7 * np.sqrt(t)) body = span & (c1 < R) & (c1 > inner) rgb = np.zeros((N, N, 3), np.float32) shade = np.clip((c1 - inner) / (R - inner + 1e-6), 0, 1) # 0 inner edge .. 1 outer edge yellow = np.array([255, 214, 40]) * (0.78 + 0.3 * np.sin(shade * np.pi))[..., None] rgb[:] = yellow shine = (np.abs(shade - 0.62) < 0.06) & (np.abs(ang) < 40) rgb[shine] = [255, 250, 200] # green-ish near the stem end, brown tips stem = span & (ang > 58) tip = span & (ang < -66) rgb[stem] = rgb[stem] * 0.5 + np.array([150, 160, 40]) * 0.5 rgb[(ang > 65) & body] = [110, 80, 30] rgb[tip & body] = [80, 55, 25] # dark outline so it reads against the sky mask = Image.fromarray((body * 255).astype(np.uint8)) outline = np.array(mask.filter(ImageFilter.MaxFilter(13))) > 0 out = np.zeros((N, N, 4), np.float32) out[outline] = [70, 45, 10, 255] out[body, :3] = rgb[body] out[body, 3] = 255 img = Image.fromarray(out.clip(0, 255).astype(np.uint8), "RGBA") return img.resize((128, 128), Image.LANCZOS) def main(): out = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).with_name("banana.png") b = banana() b.save(out) prev = Image.new("RGBA", (256, 128), (110, 160, 220, 255)) prev.alpha_composite(b, (0, 0)) prev.alpha_composite(b.resize((32, 32), Image.LANCZOS), (160, 48)) prev.convert("RGB").save(out.with_name("banana_preview.png")) print("ok", out) if __name__ == "__main__": main()