<?php

if (!function_exists('imagecreatetruecolor')) {
    fwrite(STDERR, "PHP GD extension required\n");
    exit(1);
}

function makeIcon(int $size, string $path): void
{
    $img = imagecreatetruecolor($size, $size);
    $bg = imagecolorallocate($img, 26, 35, 126);
    $fg = imagecolorallocate($img, 255, 255, 255);
    imagefilledrectangle($img, 0, 0, $size, $size, $bg);
    imagestring($img, 5, (int) ($size * 0.28), (int) ($size * 0.42), 'KTE', $fg);
    imagepng($img, $path);
    imagedestroy($img);
}

$dir = dirname(__DIR__) . '/assets/icons';
makeIcon(192, $dir . '/icon-192.png');
makeIcon(512, $dir . '/icon-512.png');
echo "Icons created\n";
