#!/usr/bin/env python3
"""Generate PWA icons for NEOG OS"""

from PIL import Image, ImageDraw, ImageFont
import os

def create_icon(size, output_path):
    """Create a square icon with NEOG text"""
    # Create image with green background
    img = Image.new('RGB', (size, size), color='#00ff41')
    draw = ImageDraw.Draw(img)

    # Add black text "NEOG"
    text = "NEOG"

    # Try to use a system font, fallback to default
    try:
        font_size = size // 4
        font = ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", font_size)
    except:
        font = ImageFont.load_default()

    # Calculate text position (center)
    bbox = draw.textbbox((0, 0), text, font=font)
    text_width = bbox[2] - bbox[0]
    text_height = bbox[3] - bbox[1]
    position = ((size - text_width) // 2, (size - text_height) // 2)

    # Draw text
    draw.text(position, text, fill='#000000', font=font)

    # Save image
    img.save(output_path, 'PNG')
    print(f"✓ Created {output_path} ({size}x{size})")

# Create icons directory
os.makedirs('/Users/neog/static/pwa', exist_ok=True)

# Generate icons
create_icon(192, '/Users/neog/static/pwa/icon-192.png')
create_icon(512, '/Users/neog/static/pwa/icon-512.png')

print("✓ All icons generated successfully!")
