1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
function xy($height, $taille_T, $font_TTF, $texte) {
$diag = sqrt(($height * $height) + ($height * $height));
$size = imagettfbbox($taille_T,-45,$font_TTF,$texte);
$LargeurTexte = abs($size[5]-$size[1]);
$HauteurTexte = abs($size[6]-$size[0]);
$X = ($height - $LargeurTexte) / 2;
$Y = ($height - $HauteurTexte) / 2;
$Angle = cos($height / $diag);
$tab = array("X"=>$X,"Y"=>$Y,"Angle"=>$Angle);
return $tab;
}
$texte = "Ici un joli texte dans une diagonale";
$tab = xy(500, 16, "fonts/Verdana.ttf", $texte);
$x = $tab['X'];
$y = $tab['Y'];
$Angle = $tab['Angle'];
imagettftext($dest, 16, -$Angle, $x, $y, $rouge, "fonts/Verdana.ttf", $texte); |
Partager