/*
*生成印象风格鼠洞
*/
function holemouse(){
Header("Content-type: image/gif");
$im = @imagecreate(224, 40);
$bc = imagecolorallocate($im, 255, 255, 255);
$b = imagecolorallocate($im, 33, 99, 55);
$c = imagecolorallocate($im, 66, 55, 55);
for($i=2;$i<7 ;$i++ ){
$j=33*$i-6;
imagerectangle($im, $j, 5, $j+30, 34,$b);
imagerectangle($im, $j+rand(1,23), 4+rand(1,23), $j+rand(1,23), 4+rand(1,23),$c);
imagerectangle($im, $j+rand(1,23), 4+rand(1,23), $j+rand(1,23), 4+rand(1,23),$c);
imagerectangle($im, $j+rand(1,23), 4+rand(1,23), $j+rand(1,23), 4+rand(1,23),$c);
}
$r=rand(2,6);
$j=33*$r-5;
$_SESSION['holemouse']=$r;//只需要保存序号就可以了
$b = imagecolorallocate($im, 200, 99, 55);
//下面是缩放变形,看你的变化了了
imagecopyresized($im, $im, 5, 3, $j, 6, 37, 37, 28, 28);
imagerectangle($im, 4, 1,43, 38,$b);
imagegif($im);
imagedestroy($im);
}
/*
*老鼠进洞了---验证
*/
function mousehole(){
$r=$_SESSION['holemouse'];
if($r===null) return false;
$xy=explode(',',$_POST['xy']);//假设传入的参数在这里,形如63,20
$x=$xy[0]?$xy[0]:false;
$y=$xy[1]?$xy[1]:false;
if($x == false or $y == false) return false;
$j=33*$r-5;
if($x>=$j and $x<=$j+28 and $y>=6 and $y<=37){ return true;
}else
return false;
}
|