请选择 进入手机版 | 继续访问电脑版
开启辅助访问
帐号登录 |立即注册

PHP画布中绘制干扰点和干扰线,适合验证码应用

 
<?php
header( ' Content-type: image/gif');
//创建画布
$res = imagec reatet ruecolor(500,500) ;
//配置颜色
$red = imageColorAllocate($res, 255, 0, 0);
$green= imageColorAllocate($res, 0, 255,0);
$blue = imageColorAllocate($res, 0, 0, 255);
$white = imageColorAllocate($res, 255, 255, 255);
//画布填充颜色
imageFill($res, 0, 0, $white);

//制作干扰点
for($i=0;$i<5000;$i++){
imagesetpixel($res, mt_ rand(0, 500), mt_ rand(0, 500), $red);
}


//制作干扰线
for($i=0;$i<5000;$i++){
imageline($res ,
mt_ rand(0, 500),
mt_ rand(0, 500) ,
mt_ rand(0,500) ,
mt_ rand(0,500),
$red
);
}


回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则