Header ("Content-type: image/png ");
$ Txt = $ _ GET [txt]. "(I will change the color when refreshing )";
$ I = strlen ($ txt );
$ Width = 16 * strlen ($ txt );
$ Height = 42 * (int) ($ width/500 + 1 );
$ Im = imagecreate ($ width, $ height );
$ Background_color = imageColorAllocate ($ instant, 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, 255 );
$ Pink = imageColorAllocate ($ im, 128 );
$ Black = imageColorAllocate ($ im, 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 );
?> |
|