from pathlib import Path
from PIL import Image, ImageDraw, ImageFont

root = Path(__file__).resolve().parents[1]
scale = 2
im = Image.new('RGB', (512 * scale, 512 * scale), '#111b27')
d = ImageDraw.Draw(im)
font_path = '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf'
def font(size): return ImageFont.truetype(font_path, size * scale)
def rect(box, fill, radius=0, outline=None, width=1):
    d.rounded_rectangle(tuple(int(x * scale) for x in box), radius=radius * scale,
        fill=fill, outline=outline, width=width * scale)
def text(x,y,content,size,fill='#f5e6c7'):
    d.text((x*scale,y*scale), content, font=font(size), fill=fill, anchor='mt')

rect((13,13,499,499), None, 26, '#354450', 2)
rect((29,29,483,70), '#e3ae52', 10)
text(256,37,'RANDOM-ONLY CO-OP',20,'#111b27')
text(256,86,'ONE DEATH',49)
text(256,143,'RANDOM',59)
text(256,210,'TOGETHER',35,'#9cb5bb')
# A procedural die and a reset arc: exact, reusable graphic primitives.
box=(208,277,304,373)
rect(box,'#f5e6c7',20)
for x,y in [(231,300),(281,300),(256,325),(231,350),(281,350)]:
    d.ellipse(((x-6)*scale,(y-6)*scale,(x+6)*scale,(y+6)*scale), fill='#14202d')
d.arc((170*scale,239*scale,342*scale,410*scale),15,310,fill='#e3ae52',width=8*scale)
d.polygon([(318*scale,254*scale),(346*scale,269*scale),(320*scale,282*scale)], fill='#e3ae52')
rect((38,426,174,477),'#a33e35',10)
rect((188,426,324,477),'#315d63',10)
rect((338,426,474,477),'#253646',10)
text(106,438,'3s RESET',20)
text(256,438,'5s REVEAL',17)
text(406,438,'NO WES',19)
im.resize((512,512),Image.Resampling.LANCZOS).save(root/'workshop_preview.png')
print(root/'workshop_preview.png')
