<?php
header("Content-type: image/png");
$im = @imagecreatefrompng("images/capa.png"); // из картинки с лого
//$im = @imagecreatetruecolor(209, 87); //можно и пустую
imageantialias($im, true); // размытость
switch(mt_rand(0, 2)){
case 0:
$orange = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
$red = imagecolorallocate($im, 0x44, 0xAA, 0xFF);
break;
case 1:
$orange = imagecolorallocate($im, 0xFF, 0x00, 0xFF);
$red = imagecolorallocate($im, 0x0, 0xFF, 0x0);
break;
case 2:
$orange = imagecolorallocate($im, 0x0, 0xFF, 0xFF);
$red = imagecolorallocate($im, 0xFF, 0x0, 0x0);
break;
default:
break;
}
$h_padding = 0;
$v_padding = 0;
$num = "";
for($i = 0; $i < mt_rand(3, 6); ++$i){
$h_padding += 33;
$v_padding = 25 + mt_rand(-3, 3);
if(mt_rand(0, 10) > 5){
$height = 50 + mt_rand(-6, 6);
$width = 14 + mt_rand(-6, 6);
$x1 = $h_padding + mt_rand(-4, 4);
$x2 = $h_padding + mt_rand(-4, 4);
$y1 = $v_padding + mt_rand(-4, 4);
$y2 = $v_padding + $height + mt_rand(-4, 4);
imageline($im, $x1, $y1, $x2, $y2, $orange);
imageline($im, $x1, $y1 + 1, $x2, $y2 + 1, $orange);
imageline($im, $x1, $y1 - 1, $x2, $y2 - 1, $orange);
imageline($im, $x1, $y1, $x1-$width, $y1+$height/2, $orange);
imageline($im, $x1, $y1 + 1, $x1-$width, $y1+$height/2 + 1, $orange);
imageline($im, $x1, $y1 - 1, $x1-$width, $y1+$height/2 - 1, $orange);
$num .= "1";
}
else {
$height = 50 + mt_rand(-6, 6);
$width = 14 + mt_rand(-5, 5);
$x1 = $h_padding + mt_rand(-4, 1);
$x2 = $h_padding + mt_rand(-4, 1);
$y1 = $v_padding + mt_rand(-4, 4);
$y2 = $v_padding + $height + mt_rand(-4, 4);
imageline($im, $x1, $y1, $x2, $y2, $orange);
imageline($im, $x1, $y1 + 1, $x2, $y2 + 1, $orange);
imageline($im, $x1, $y1 - 1, $x2, $y2 - 1, $orange);
imageline($im, $x1, $y1+$height/2, $x1-$width+3, $y1+$height/2, $orange);
imageline($im, $x1, $y1+$height/2 + 1, $x1-$width, $y1+$height/2 + 1, $orange);
imageline($im, $x1, $y1+$height/2 - 1, $x1-$width, $y1+$height/2 - 1, $orange);
imageline($im, $x1-$width, $y1+$height/2, $x1-$width+2, $y1, $orange);
imageline($im, $x1-$width, $y1+$height/2 + 1, $x1-$width+2, $y1 + 1, $orange);
imageline($im, $x1-$width, $y1+$height/2 - 1, $x1-$width+2, $y1 - 1, $orange);
$num .= "4";
}
}
imagestring($im, 5, mt_rand(0, 150), mt_rand(0, 50), "($num)", $red); // дебаггинг, можно закомментить
imagepng($im);
imagedestroy($im);
?>