<?php
/*PHP实现验证码*/
session_start();//开启会话
//创建画布
$image=imagecreatetruecolor(500,500);
//背景颜色
$bgcolor=imagecolorallocate($image,255,255,255);
//创建颜色
imagefill($image,0,0,$bgcolor);
$color = imagecolorallocate($image, 0, 0, 0);
// imagefilledarc($image, 255-$i, 255-$i, 255-$i, 255-$i,0, 360, $color,IMG_ARC_PIE);
$red = imagecolorallocate($image, 47,0,0);//红色 用于绘制椭圆
$white = imagecolorallocate($image, 255, 255, 255);//红色 用于绘制椭圆
$black = imagecolorallocate($image, 0, 0, 0);//红色 用于绘制椭圆
$yan = imagecolorallocate($image, 36,53,47);//红色 用于绘制椭圆
// 画椭圆
// imageellipse( $image , 200 , 100 , 200 , 200 , $red);
// imagefilledarc( image, cx, cy, w, h, s, int e, int color, int style )
// imagefilledarc($image, 50, 50, 35, 70, 0, 360, $black, IMG_ARC_PIE);
//手
for ($i = 0; $i <= 100; $i++) {
imagefilledarc($image, 40- ($i/2), 200+($i/3), 50-($i/10), 50-($i/10),0, 360, $color,IMG_ARC_PIE);
}
for ($i = 0; $i <= 100; $i++) {
imagefilledarc($image, 350+($i/3),200- ($i/2), 50-($i/10), 50-($i/10),0, 360, $color,IMG_ARC_PIE);
}
// 脚丫
$baisetouming=imagecolorallocate($image,203,203,203);
imagefilledarc($image, 150, 380,60 , 90, 0, 360, $baisetouming, IMG_ARC_PIE);
imagefilledarc($image, 250, 380,60 , 90, 0, 360, $baisetouming, IMG_ARC_PIE);
imagefilledarc($image, 150, 380,50 , 80, 0, 360, $black, IMG_ARC_PIE);
imagefilledarc($image, 250, 380,50 , 80, 0, 360, $black, IMG_ARC_PIE);
// 画身体
for ($i = 161; $i < 255; $i++) {
$baisetouming = imagecolorallocatealpha($image , $i, $i, $i,25);
imagefilledarc($image,200, 200, 305-$i+161, 355-$i+161 ,0, 360, $baisetouming,IMG_ARC_PIE);
}
$baisetouming=imagecolorallocatealpha($image,255,255,255, 75);
imagefilledarc($image,200, 200, 290, 355 ,0, 360, $baisetouming,IMG_ARC_PIE);
$baisetouming=imagecolorallocatealpha($image,255,255,255, 75);
imagefilledarc($image,200, 200, 280, 340 ,0, 360, $baisetouming,IMG_ARC_PIE);
$blackz[1]= imagecolorallocate($image, 26,166,183);//
$blackz[2]= imagecolorallocate($image, 0,45,64);//
// $blackz[1]= imagecolorallocate($image, 185,13,175);//
$blackz[3]= imagecolorallocate($image, 255,65,77);//
$blackz[4]= imagecolorallocate($image, 244,106,121);//
$blackz[5]= imagecolorallocate($image, 217,236,242);//
$blackz[6]= imagecolorallocate($image, 237,234,18);//
$baisetouming=imagecolorallocatealpha($image,0,0,0, 0);
for ($i = 255; $i >161 ; $i--) {
$baisetouming = imagecolorallocatealpha($image , $i, $i, $i,25);
// imagefilledarc($image,200, 200, 305-$i+161, 355-$i+161 ,0, 360, $baisetouming,IMG_ARC_PIE);
imagefilledarc($image, 200, 150,240-(255-$i) , 235-(255-$i) , 0, 360, $baisetouming, IMG_ARC_PIE);
}
// imagearc($image, 200 , 150 , 170+(10)+($i*5) , 150+( 10)+($i*5) , 0, 360, $blackz[$i]);
$baisetouming=imagecolorallocate($image,255,255,255);
imagefilledarc($image, 200, 150,220 , 200, 0, 360, $baisetouming, IMG_ARC_PIE);
for($j=0;$j<15;$j++){
for($i=1;$i<7;$i++){
// $z=mt_rand(0,7);
imagearc($image, 200 , 150 , 170+(10)+($i*5) , 150+( 10)+($i*5) , 0, 360, $blackz[$i]);
}
}
//左眼
// imagefilledarc($image, 160, 150,60 , 35, 0, 360, $black, IMG_ARC_PIE);
for ($i = 0; $i <= 50; $i++) {
imagefilledarc($image, 160+($i/3), 150- ($i/2), 50-($i/3), 50-($i/3),0, 360, $color,IMG_ARC_PIE);
imagefilledarc($image,160-($i/3),150+ ($i/2), 50-($i/3), 50-($i/3),0, 360, $color,IMG_ARC_PIE);
}
// 眼珠
imagefilledarc($image, 160, 150, 23, 23, 0, 360, $white, IMG_ARC_PIE);
imagefilledarc($image, 160, 150, 20, 20, 0, 360, $black, IMG_ARC_PIE);
imagefilledarc($image, 160, 150, 15, 15, 0, 360, $yan, IMG_ARC_PIE);
imagefilledarc($image, 160, 150, 10, 10, 0, 360, $black, IMG_ARC_PIE);
imagefilledarc($image, 160, 145, 5, 5, 0, 360, $white, IMG_ARC_PIE);
imagefilledarc($image, 155, 146, 2, 2, 0, 360, $white, IMG_ARC_PIE);
//右眼
for ($i = 0; $i <= 50; $i++) {
imagefilledarc($image, 240-($i/3), 150- ($i/2), 50-($i/3), 50-($i/3),0, 360, $color,IMG_ARC_PIE);
imagefilledarc($image,240+ ($i/3),150+ ($i/2), 50-($i/3), 50-($i/3),0, 360, $color,IMG_ARC_PIE);
}
// imagefilledarc($image, 240, 150,60 , 35, 0, 360, $black, IMG_ARC_PIE);
// 眼珠
imagefilledarc($image, 240, 150, 23, 23, 0, 360, $white, IMG_ARC_PIE);
imagefilledarc($image, 240, 150, 20, 20, 0, 360, $black, IMG_ARC_PIE);
imagefilledarc($image, 240, 150, 15, 15, 0, 360, $yan, IMG_ARC_PIE);
imagefilledarc($image, 240, 150, 10, 10, 0, 360, $black, IMG_ARC_PIE);
imagefilledarc($image, 240, 145, 5, 5, 0, 360, $white, IMG_ARC_PIE);
imagefilledarc($image, 235, 146, 2, 2, 0, 360, $white, IMG_ARC_PIE);
//鼻子
imagefilledarc($image, 200, 170,25 , 20, 0, 360, $black, IMG_ARC_PIE);
//嘴巴
imagearc($image, 200, 200,60 , 20, 0, 180, $red);
//耳朵
$baisetouming=imagecolorallocate($image,203,203,203);
imagefilledarc($image, 120, 60,40 , 40, 150, 330, $baisetouming, IMG_ARC_PIE);
imagefilledarc($image, 280, 60,40 , 40, 210, 390, $baisetouming, IMG_ARC_PIE);
imagefilledarc($image, 120, 60,30 , 30, 150, 330, $black, IMG_ARC_PIE);
imagefilledarc($image, 280, 60,30 , 30, 210, 390, $black, IMG_ARC_PIE);
//手
// $baisetouming=imagecolorallocate($image,203,203,203);
// imagefilledarc($image, 22, 200, 70, 40, 0, 360, $baisetouming, IMG_ARC_PIE);
// imagefilledarc($image, 380, 200, 70, 40 , 0, 360, $baisetouming, IMG_ARC_PIE);
// imagefilledarc($image, 400, 180,40 , 70 , 0, 360, $baisetouming, IMG_ARC_PIE);
// imagefilledarc($image, 22, 200, 60, 30, 0, 360, $black, IMG_ARC_PIE);
// imagefilledarc($image, 380, 200, 60, 30 , 0, 360, $black, IMG_ARC_PIE);
// imagefilledarc($image, 400, 180,30 , 60 , 0, 360, $black, IMG_ARC_PIE);
//输出格式
header('content-type:image.png');
imagepng($image);
//销毁图片
imagedestroy($image);