<?php
/**
 * Generate PWA Icons
 * Creates simple colored square icons for PWA
 */

function createIcon($size, $filename) {
    $image = imagecreatetruecolor($size, $size);
    
    // Blue background #2563eb (37, 99, 235)
    $bgColor = imagecolorallocate($image, 37, 99, 235);
    imagefill($image, 0, 0, $bgColor);
    
    // White color for text
    $textColor = imagecolorallocate($image, 255, 255, 255);
    
    // Calculate font size based on icon size
    $fontSize = $size * 0.5;
    
    // Use built-in font and calculate position
    $font = 5; // Large built-in font
    $text = 'D';
    $textWidth = imagefontwidth($font) * strlen($text);
    $textHeight = imagefontheight($font);
    $x = ($size - $textWidth) / 2;
    $y = ($size - $textHeight) / 2;
    
    // Draw the letter
    imagestring($image, $font, $x, $y, $text, $textColor);
    
    // Save the image
    imagepng($image, $filename);
    imagedestroy($image);
}

// Create icons directory if it doesn't exist
if (!file_exists('assets/images')) {
    mkdir('assets/images', 0755, true);
}

// Generate 192x192 icon
createIcon(192, 'assets/images/icon-192.png');

// Generate 512x512 icon
createIcon(512, 'assets/images/icon-512.png');

echo "Icons generated successfully!<br>";
echo "192x192 icon: assets/images/icon-192.png<br>";
echo "512x512 icon: assets/images/icon-512.png<br>";
?>

