<?php header("content-type: image/png");
$txt=$_get['txt']."(刷新我会变色哦)"; $i=strlen($txt); $width=16*strlen($txt); $height=42*(int)($width/500+1); $im = imagecreate($width,$height);
$background_color=imagecolorallocate($im,223,223,223); $white=imagecolorallocate($im,255,255,255); $color1=imagecolorallocate($im,255,128,128); $red=imagecolorallocate($im,255,0,0); $color3=imagecolorallocate($im,128,64,64); $yellow=imagecolorallocate($im,255,255,0); $color4=imagecolorallocate($im,255,128,0); $color5=imagecolorallocate($im,128,128,0); $green=imagecolorallocate($im,0,255,0); $color6=imagecolorallocate($im,0,128,0); $blue=imagecolorallocate($im,0,0,255); $pink=imagecolorallocate($im,255,0,128); $black=imagecolorallocate($im,0,0,0);
$array=array($color1,$red,$color3,$color4,$color5,$green,$color6,$blue,$pink,$black,$white);
$x=1; $y=40; $count=1;
for($t=0;$t<$i;$t++) { $temp=rand(0,10); $color=$array[$temp]; if (ord($txt[$t]) >= 128) { if($x+32>500) { $x=1; $y=40+$count*41; $count++; } $temp=$txt[$t++].$txt[$t]; $temp=mb_convert_encoding($temp, "utf-8", "gb2312"); imagettftext($im,24, 0, $x, $y, $color,"tupian/finish/simsun.ttc",$temp); $x+=32;
} else { if($x+8>500) { $x=1; $y=40+$count*41; $count++; } imagettftext($im,24, 0, $x, $y, $color,"tupian/finish/simsun.ttc",$txt[$t]); $x+=16; } } imagepng($im); imagedestroy($im);
?> |
|