<?php
/**
 * Project:        M.VuiZ.Net
 * Author:         nampt.me <admin@vuiz.net>
 * Copyright:      © 2025 vuiz.net All rights reserved.
 */
header('Content-Type: image/png');
//header('Content-disposition: attachment;filename="logo.png"');
$text = empty($_GET['text']) ? 'VuiZ.Net' : $_GET['text'];
$type = empty($_GET['type']) ? 1 : $_GET['type'];

$size= 40;
$angel= 0;
$font= __DIR__.'/LithosPro-Bold.ttf';


if($type == 1)
{
    $ico = 'pink.png';
    $vien = 'ed348e';
}elseif($type == 2)
{
    $ico = 'red.png';
    $vien = 'ff0000';
}elseif($type == 3)
{
    $ico = 'babyblue.png';
    $vien = '00a0c8';
}elseif($type == 4)
{
    $ico = 'green.png';
    $vien = '1eeb0f';
}else
{
    $ico = 'blue.png';
    $vien = '33f';
}
 
$bbox = imagettfbbox($size,$angel,$font,$text);
$w = $bbox[2] + 10;
$h = 80;


// Create image
$im  = imagecreatetruecolor($w,$h);
//transparent
imagesavealpha($im, true);
$transparent = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $transparent);

// Font color
switch ($type) {
    case 1:
        $borderOutline = imagecolorallocate($im, 237, 52, 142);
        break;
    case 2:
        $borderOutline = imagecolorallocate($im, 255, 0, 0);
        break;
    case 3:
        $borderOutline = imagecolorallocate($im, 0, 160, 200);
        break;
    case 4:
        $borderOutline = imagecolorallocate($im, 30, 235, 15);
        break;
    case 5:
        $borderOutline = imagecolorallocate($im, 51, 51, 255);
        break;
    
    default:
        $borderOutline = imagecolorallocate($im, 237, 52, 142);
        break;
}


//create text from font
$font_color = imagecolorallocate($im, 255, 255, 255);

//icon tim
imagettftext($im, 20, $angel, $w-48, 28, $borderOutline, $font, "¶");
// Text with border
imagettfstroketext($im, $size, $angel, 5, $h-10, $font_color, $borderOutline, $font, $text, 2);

// finally
imagepng($im);
imagedestroy($im);



function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, &$strokecolor, $fontfile, $text, $px) {
    for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
        for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
            $bg = imagettftext($image, $size, $angle, $c1, $c2, $strokecolor, $fontfile, $text);
   return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
}
?>