Файл: vkolhoze.com/pandcar/gradient.php
Строк: 22
<?
function strlen_mod($str){
$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
return strlen(str_replace($rus, '0', $str));
}
function str_split_mod($str){
$a =preg_split("/(.)/u",$str,-1,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
return $a;
}
function text_gradient($text,$from='',$to='', $mode="hex")
{
if($mode=="hex")
{
$to = hexdec($to[0].$to[1]).",".hexdec($to[2].$to[3]).",".hexdec($to[4].$to[5]);
$from= hexdec($from[0].$from[1]).",".hexdec($from[2].$from[3]).",".hexdec($from[4].$from[5]);
}
if( empty($text) )
return '';
else
$levels=strlen_mod($text);
$text_ss = str_split_mod($text);
if (empty($from))
$from = array(0,0,255);
else
$from = explode(",", $from);
if (empty($to))
$to = array(255,0,0);
else
$to = explode(",", $to);
$output = "";
for ($i=1;$i<=$levels;$i++)
{
for ($ii=0;$ii<3;$ii++)
{
$tmp[$ii] = $from[$ii] - $to[$ii];
$tmp[$ii] = floor($tmp[$ii] / $levels);
$rgb[$ii] = $from[$ii] - ($tmp[$ii] * $i);
if ($rgb[$ii] > 255) $rgb[$ii] = 255;
$rgb[$ii] = dechex($rgb[$ii]);
$rgb[$ii] = strtoupper($rgb[$ii]);
if (strlen_mod($rgb[$ii]) < 2) $rgb[$ii] = "0$rgb[$ii]";
}
$output .= '<span style="color:#'.$rgb[0].$rgb[1].$rgb[2].';">'.$text_ss[$i-1].'</span>';
}
return $output;
}
echo text_gradient('MJTGP..gadm.g,€$]%g.рьшмИ.Бам.АМ.ЙНШМР^¡', 'B8860B', 'FF0000');
echo '<hr>';
echo text_gradient("Привет, я Градиент!", "FF0000", "FFCC00");
echo "<hr />n";
echo text_gradient("Привет, я Градиент в режиме rgb!", "255,255,0", "150,150,0", "rgb");
?>