/*---------------------------------------------------------------*/
|
/*
|
Titre : Texte ombré en police TrueType
|
|
URL : https://phpsources.net/code_s.php?id=960
|
Date édition : 15 Fév 2019
|
*/
|
/*---------------------------------------------------------------*/
|
|
function txt_ttf_ombre(&$im , $size , $angle , $x , $y , $dx , $dy , $col_txt ,
|
$col_ombre , $font , $str){
|
|
/* Paramètre :
|
* $im : ressource image obtenue par imagecreate()
|
* $size : taille de police en pixels
|
* $angle : angle d'inclinaison du texte
|
* $x : abscisse
|
* $y : ordonnée
|
* $dx : décalage entre le texte et son ombre en abscisse
|
* ($dx<0 -> decalage a gauche, $dx>0 -> decalage a droite)
|
* $dy : décalage entre le texte et son ombre en ordonnée
|
* ($dy<0 -> decalage vers le haut, $dy>0 -> decalage vers le bas)
|
* $col_txt : tableau RGB de la couleur du texte : array('r'=>0-255,
|
'g'=>0-255, 'b'=>0-255)
|
* $col_ombre : tableau RGB de la couleur de l'ombre : array('r'=>0-255,
|
'g'=>0-255, 'b'=>0-255)
|
* $font : fichier de police TTF
|
* $str : texte a ecrire
|
*/
|
|
if (!is_array($col_txt) || !is_array($col_ombre) || $size == 0)
|
return;
|
if ($col_txt['r'] > 255)
|
$col_txt['r'] = 255;
|
if ($col_txt['g'] > 255)
|
$col_txt['g'] = 255;
|
if ($col_txt['b'] > 255)
|
$col_txt['b'] = 255;
|
if ($col_txt['r'] < 0)
|
$col_txt['r'] = 0;
|
if ($col_txt['g'] < 0)
|
$col_txt['g'] = 0;
|
if ($col_txt['b'] < 0)
|
$col_txt['b'] = 0;
|
$col_fg = imagecolorallocate($im, $col_txt['r'], $col_txt['g'], $col_txt['b'])
|
;
|
|
if ($col_ombre['r'] > 255)
|
$col_ombre['r'] = 255;
|
if ($col_ombre['g'] > 255)
|
$col_ombre['g'] = 255;
|
if ($col_ombre['b'] > 255)
|
$col_ombre['b'] = 255;
|
if ($col_ombre['r'] < 0)
|
$col_ombre['r'] = 0;
|
if ($col_ombre['g'] < 0)
|
$col_ombre['g'] = 0;
|
if ($col_ombre['b'] < 0)
|
$col_ombre['b'] = 0;
|
$col_bg = imagecolorallocate($im, $col_ombre['r'], $col_ombre['g'], $col_ombre
|
['b']);
|
|
imagettftext($im, $size, $angle, $x+$dx, $y+$dy, $col_bg, $font, $str);
|
imagettftext($im, $size, $angle, $x, $y, $col_fg, $font, $str);
|
}
|
|
| ?> |