#!/usr/bin/env python3
import sys, os, subprocess
from PIL import Image, ImageDraw, ImageFont
from pathlib import Path

base = Path(sys.argv[0]).parent
im = Image.new('RGB', (88, 31))

for x_ in range(87):
    for y_ in range(31):
        x = x_ * 8
        y = y_ * 8 + 16
        r = ((x   ) ^ (y   )) & 0xff
        g = ((x+11) ^ (y- 9)) & 0xff
        b = ((x+27) ^ (y-17)) & 0xff
        im.putpixel((x_,y_), (r,g,b))

font = ImageFont.truetype("Pillow/Tests/fonts/FreeMonoBold.ttf", 24)
d = ImageDraw.Draw(im)
d.text((40, 4), "x^y", font=font, fill=(0,0,0))
#d.text((37, 1), "x^y", font=font, fill=(0,0,0))
d.text((38, 2), "x^y", font=font, fill=(180,255,180))

path = base / "xor.png"
im.save(path)
subprocess.run(["optipng", path])