Method One:
<?php/* Chinese round seal class * @author lkk/lianq.net * @create on 10:03 2012-5-29 * @example: * $seal = new Circleseal (' You and me he
Take a stand to walk in the east and the West ', 75,6,24,0,0,16,40;
* $seal->doimg (); * * Class Circleseal {private $sealString; The character of the seal is private $strMaxLeng; Maximum characters length private $sealRadius; Seal RADIUS private $rimWidth; Border thickness private $innerRadius; Inner circle radius private $startRadius; Pentagram radius private $startAngle; The oblique angle of the pentagram is private $backGround; Seal color private $centerDot; Center coordinates private $IMG; Graphic resource handle private $font; The specified font is private $fontSize; Specifies the font size private $width; Picture width private $height; Picture height private $points; Each point coordinates of the pentagram private $charRadius; string radius private $charAngle; String tilt angle private $spacing; Character spacing angle//Construction method Public Function __construct ($str = ', $rad = $rmwidth = 6, $strad =, $stang = 0, $crang = 0, $fsize = $inrad =0) {$this->sealstring = empty ($STR)?
' Seal test string ': $str;
$this->strmaxleng = 12; $tHis->sealradius = $rad;
$this->rimwidth = $rmwidth;
$this->startradius = $strad;
$this->startangle = $stang;
$this->charangle = $crang;
$this->centerdot = Array (' x ' => $rad, ' y ' => $rad); $this->font = dirname (__file__). '
/simkai.ttf ';
$this->fontsize = $fsize; $this->innerradius = $inrad;
Default 0, no $this->spacing = 1;
//Create Picture resource Private Function createimg () {$this->width = 2 * $this->sealradius;
$this->height = 2 * $this->sealradius;
$this->img = imagecreate ($this->width, $this->height);
Imagecolorresolvealpha ($this->img,255,255,255,127);
$this->background = imagecolorallocate ($this->img,255,0,0); //Draw seal Border Private Function Drawrim () {for ($i =0; $i < $this->rimwidth; $i + +) {Imagearc ($this->img, $thi s->centerdot[' x '], $this->centerdot[' y '], $this->width-$i, $this->height-$i, 0,360, $this->
BackGround); Draw inner Circle Private Function drawinnercircle () {Imagearc ($this->img, $this->centerdot[' x '), $this->cen
terdot[' y '],2* $this->innerradius,2* $this->innerradius,0,360, $this->background);
//Draw string Private function drawstring () {//encoding processing $charset = mb_detect_encoding ($this->sealstring);
if ($charset!= ' UTF-8 ') {$this->sealstring = mb_convert_encoding ($this->sealstring, ' UTF-8 ', ' GBK '); ///related metering $this->charradius = $this->sealradius-$this->rimwidth-$this->fontsize; String Radius $leng = Mb_strlen ($this->sealstring, ' UTF8 ');
String length if ($leng > $this->strmaxleng) $leng = $this->strmaxleng; $avgAngle = 360/($this->strmaxleng); Average character gradient//split and write String $words = Array ();
Character array for ($i =0; $i < $leng; $i + +) {$words [] = Mb_substr ($this->sealstring, $i, 1, ' UTF8 '); $r = 630 + $this->charangle + $avgAngle * ($i-$leng/2) + $this->spacing* ($i-1); Coordinate angle $R = 720-$this->charangle + $avgAngle * ($leng -2* $i-1)/2 + $this->spacing* (1-$i); Character angle $x = $this->centerdot[' x '] + $this->charradius * cos (Deg2rad ($r)); The x-coordinate of the character $y = $this->centerdot[' y '] + $this->charradius * sin (Deg2rad ($r)); The y-coordinate of the character imagettftext ($this->img, $this->fontsize, $R, $x, $y, $this->background, $this->font, $words [$i
]);
//Draw the Pentagram Private function Drawstart () {$ang _out = + $this->startangle;
$ang _in = + $this->startangle;
$rad _out = $this->startradius;
$rad _in = $rad _out * 0.382; For ($i =0 $i <5; $i + +) {//five vertex coordinates $this->points[] = $rad _out * cos (2*m_pi/5* $i-deg2rad ($ang _out)) + $this-
>centerdot[' x '];
$this->points[] = $rad _out * sin (2*m_pi/5* $i-deg2rad ($ang _out)) + $this->centerdot[' y '];
Concave point coordinates $this->points[] = $rad _in * cos (2*m_pi/5* ($i + 1)-Deg2rad ($ang _in)) + $this->centerdot[' x ']; $this->points[] = $rad _in * Sin (2*m_pi/5* ($i + 1)-Deg2rad ($ang _in)) + $this->centerdot[' y '];
Imagefilledpolygon ($this->img, $this->points, $this->background);
//Outputs Private function output () {header (' content-type:image/png ');
Imagepng ($this->img);
Imagedestroy ($this->img);
The Public Function doimg () {$this->createimg () is generated externally;
$this->drawrim ();
$this->drawinnercircle ();
$this->drawstring ();
$this->drawstart ();
$this->output ();
}
}
Method Two:
<?php @ $hos =iconv ("GBK", "UTF-8", $_get["hos"]);
if (!isset ($hos)) exit;
$im =imagecreate (150,150);
$gray =imagecolorresolvealpha ($im, 200,200,200,127);
$red =imagecolorallocate ($im, 230,150,150);
For ($i =0 $i <6; $i + +) Imagearc ($im, 75,75,148-$i, 148-$i, 0,360, $red);
$stock = ' C:\WINDOWS\Fonts\simkai.ttf ';
$point = "★";
$size = 30;
Imagettftext ($im, $size, 0,72-$size/2,72+ $size/2, $red, $stock, $point);
$a =75 $b =-75;//Center Point coordinate $r =65 $m =40;//radius, angle $size =16;//font Size $r = $r-$size;
$word =array ();
$max = 18;
$count =mb_strlen ($hos, ' UTF8 ');
if ($count > $max) $count = $max;
if ($count >12) $m =floor (360/$count);
else if ($count >5) $m-= $count;
for ($i =0; $i < $count; $i + +) $word []=mb_substr ($hos, $i, 1, ' UTF8 ');
$j =floor ($count/2);
if ($j!= $count/2) {for ($i = $j; $i >=0; $i-) {$arc = $m * ($j-$i) + $size/2;
$x =round ($r *cos (90+ $arc) *m_pi/180) + $a;
$y =-1* (Round ($r *sin (90+ $arc) *m_pi/180)) + $b);
if ($arc <10) $arc = 0;
Imagettftext ($im, $size, $arc, $x, $y, $red, $stock, $word [$i]);
$arc = $m * ($j-$i)-$size/2; $x =round ($r *cos((90-$arc) *m_pi/180))
+ $a;
$y =-1* (Round ($r *sin (90-$arc) *m_pi/180)) + $b);
if ($arc <10) $arc = 0;
Imagettftext ($im, $size,-$arc, $x, $y, $red, $stock, $word [$j + $j-$i]);
} else {$j = $j-1;
for ($i = $j; $i >=0; $i-) {$arc = $m/2+ $m * ($j-$i) + $size/2;
$x =round ($r *cos (90+ $arc) *m_pi/180) + $a;
$y =-1* (Round ($r *sin (90+ $arc) *m_pi/180)) + $b);
Imagettftext ($im, $size, $arc, $x, $y, $red, $stock, $word [$i]);
$arc = $m/2+ $m * ($j-$i)-$size/2;
$x =round ($r *cos (90-$arc) *m_pi/180) + $a;
$y =-1* (Round ($r *sin (90-$arc) *m_pi/180)) + $b);
Imagettftext ($im, $size,-$arc, $x, $y, $red, $stock, $word [$j + $j +1-$i]);
} header (' Content-type:image/png '); Imagepng ($im);?>
The above is the entire contents of this article, I hope you can enjoy