1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| <?
function sq($x)
{
return $x * $x;
}
function convrad ()
{
return pi() / 180;
}
function convdeg ()
{
return 180 / pi();
}
function circleWrite($image, $color, $font, $size, $r, $phrase, $cx, $cy, $phy = 180)
{
$tab = imagettfbbox($size , 0 , $font , 'X' );
$lenX = $tab[4] - $tab[0];
$lenY = $tab[5] - $tab[1];
$len = sqrt(sq($lenX) + sq($lenY));
$step = atan($len / $r) * convdeg();
$nbrLettres = strlen($phrase);
for ($i=0;$i<$nbrLettres;$i++)
{
$angle = $phy + $i * $step;
$angleRAD = $angle * convrad();
$x = $cx + cos($angleRAD)*$r;
$y = $cy + sin($angleRAD)*$r;
imagettftext($image, $size, 270 - $angle , $x, $y, $color, $font, $phrase[$i]);
}
}
$dx = 290;
$dy = 290;
$image=imagecreate($dx,$dy);
$white = imagecolorallocate($image, 255,255,255);
$black = imagecolorallocate($image, 0,0,0);
$font = 'c:\freefont\FreeMono.ttf';
$image=imagecreatefromjpeg("images/imagestelephone.jpeg");
circleWrite($image, $black, $font, 15, min($dx / 3, $dy / 3), 'Recherche par le numéro de téléphone', $dx / 2, $dy / 2);
header("Content-type:image/jpeg");
imagejpeg($image);
imagedestroy($image);
?> |
Partager