#!/usr/bin/env python3
"""Create a 640x360 PNG with warm orange-to-dark gradient and centered HERMES SDK text."""

from PIL import Image, ImageDraw, ImageFont

width, height = 640, 360
img = Image.new("RGB", (width, height))
pixels = img.load()

# Draw warm orange-to-dark gradient (top = warm orange, bottom = dark)
for y in range(height):
    ratio = y / (height - 1)
    # Top (orange): ~255, 140, 0 → Bottom (dark): ~10, 10, 20
    r = int(255 * (1 - ratio) + 10 * ratio)
    g = int(140 * (1 - ratio) + 10 * ratio)
    b = int(0 * (1 - ratio) + 20 * ratio)
    for x in range(width):
        pixels[x, y] = (r, g, b)

# Draw centered text
draw = ImageDraw.Draw(img)
try:
    font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 48)
except (IOError, OSError):
    try:
        font = ImageFont.load_default()
    except Exception:
        font = ImageFont.load_default()

# Measure text and center it
bbox = draw.textbbox((0, 0), "HERMES SDK", font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
x = (width - text_width) // 2
y = (height - text_height) // 2 - bbox[1]

draw.text((x, y), "HERMES SDK", fill="white", font=font)

img.save("/home/hermes/hermes_banner.png")
print("Saved /home/hermes/hermes_banner.png")
