コード例 #1
0
ファイル: ClickCaptcha.class.php プロジェクト: Birjemin/Study
 /** 创建验证码 */
 public function create()
 {
     // 创建图象
     $this->_img_res = imagecreate($this->width, $this->height);
     // 填充背景
     ImageColorAllocate($this->_img_res, $this->backgroundColor[0], $this->backgroundColor[1], $this->backgroundColor[2]);
     // 分配颜色
     $col_ellipse = imagecolorallocate($this->_img_res, $this->iconColor[0], $this->iconColor[1], $this->iconColor[2]);
     $minArea = $this->iconSize / 2 + 3;
     // 混淆用图象,不完整的圆
     for ($i = 0; $i < $this->icon; $i++) {
         $x = mt_rand($minArea, $this->width - $minArea);
         $y = mt_rand($minArea, $this->height - $minArea);
         $s = mt_rand(0, 360);
         $e = $s + 330;
         imagearc($this->_img_res, $x, $y, $this->iconSize, $this->iconSize, $s, $e, $col_ellipse);
     }
     // 验证用图象,完整的圆
     $x = mt_rand($minArea, $this->width - $minArea);
     $y = mt_rand($minArea, $this->height - $minArea);
     $r = $this->iconSize / 2;
     imagearc($this->_img_res, $x, $y, $this->iconSize, $this->iconSize, 0, 360, $col_ellipse);
     // 记录圆心坐标及半径
     $this->captcha_session($this->sess_name, array($x, $y, $r));
     // 生成图象
     Header("Content-type: image/PNG");
     ImagePNG($this->_img_res);
     ImageDestroy($this->_img_res);
     exit;
 }
コード例 #2
0
function vCode($num = 4, $size = 20, $width = 0, $height = 0)
{
    !$width && ($width = $num * $size * 4 / 5 + 5);
    !$height && ($height = $size + 10);
    $str = "0123456789";
    //验证码字符全集
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    // 画图像
    $im = imagecreatetruecolor($width, $height);
    // 定义要用到的颜色
    $back_color = imagecolorallocate($im, 255, 255, 255);
    //    $boer_color = imagecolorallocate($im, 100, 100, 100);
    $text_color = imagecolorallocate($im, 50, 50, 50);
    // 画背景
    imagefilledrectangle($im, 0, 0, $width, $height, $back_color);
    // 画边框
    //    imagerectangle($im, 0, 0, $width-1, $height-1, $boer_color);
    // 画干扰线
    for ($i = 0; $i < 30; $i++) {
        $font_color = imagecolorallocate($im, 0, 0, 0);
        imagearc($im, mt_rand(-$width, $width), mt_rand(-$height, $height), mt_rand(30, $width * 2), mt_rand(20, $height * 2), mt_rand(0, 360), mt_rand(0, 360), $font_color);
    }
    // 画验证码
    @imagefttext($im, $size, 0, 5, $size + 3, $text_color, 'images/index/Callie-Mae.ttf', $code);
    $_SESSION["VerifyCode"] = $code;
    header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
    header("Content-type: image/png;charset=gb2312");
    imagepng($im);
    imagedestroy($im);
}
コード例 #3
0
ファイル: Black.php プロジェクト: momoim/momo-api
 /**
  * Outputs the Captcha image.
  *
  * @param   boolean  html output
  * @return  mixed
  */
 public function render($html)
 {
     // Creates a black image to start from
     $this->image_create(Captcha::$config['background']);
     // Add random white/gray arcs, amount depends on complexity setting
     $count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
     $count = $count / 5 * min(10, Captcha::$config['complexity']);
     for ($i = 0; $i < $count; $i++) {
         imagesetthickness($this->image, mt_rand(1, 2));
         $color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
         imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
     }
     // Use different fonts if available
     $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
     // Draw the character's white shadows
     $size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
     $angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
     $x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
     $y = (Captcha::$config['height'] - $size) / 2 + $size;
     $color = imagecolorallocate($this->image, 255, 255, 255);
     imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
     // Add more shadows for lower complexities
     Captcha::$config['complexity'] < 10 and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
     Captcha::$config['complexity'] < 8 and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 6 and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 4 and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
     Captcha::$config['complexity'] < 2 and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
     // Finally draw the foreground characters
     $color = imagecolorallocate($this->image, 0, 0, 0);
     imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
     // Output
     return $this->image_render($html);
 }
コード例 #4
0
ファイル: gauge.class.php プロジェクト: SuichiesS/homewatch
 function gauge()
 {
     // Prepare image
     $this->img = imagecreate(100, 100);
     $this->white = imagecolorallocate($this->img, 255, 255, 255);
     $this->black = imagecolorallocate($this->img, 0, 0, 0);
     $this->red = imagecolorallocate($this->img, 150, 0, 0);
     $this->yellow = imagecolorallocate($this->img, 150, 150, 0);
     $this->green = imagecolorallocate($this->img, 0, 150, 0);
     // Set parameters
     $this->center = 50;
     $this->min = 0;
     $this->maxred = 50;
     $this->maxyellow = 80;
     $this->max = 100;
     $this->pos = 90;
     $this->legend = "";
     // Draw Gauge
     imagearc($this->img, $this->center, $this->center, 100, 100, 0, 360, $this->black);
     imagearc($this->img, $this->center, $this->center, 10, 10, 0, 360, $this->black);
     imagearc($this->img, $this->center, $this->center, 86, 86, 0 + 180, 180 + 180, $this->black);
     imagearc($this->img, $this->center, $this->center, 56, 56, 0 + 180, 180 + 180, $this->black);
     $this->addLine($this->min);
     $this->addLine($this->maxred);
     imagefill($this->img, 25, 25, $this->red);
     //check this point if you move the arcs
     $this->addLine($this->maxyellow);
     imagefill($this->img, 55, 15, $this->yellow);
     //check this point if you move the arcs
     $this->addLine($this->max);
     imagefill($this->img, 85, 30, $this->green);
     //check this point if you move the arcs
     imagefill($this->img, 50, 75, $this->black);
 }
コード例 #5
0
ファイル: APCImages.php プロジェクト: Tjorriemorrie/app
 public static function fill_arc($im, $centerX, $centerY, $diameter, $start, $end, $color1, $color2, $text = '', $placeindex = 0)
 {
     $r = $diameter / 2;
     $w = deg2rad((360 + $start + ($end - $start) / 2) % 360);
     if (function_exists("imagefilledarc")) {
         // exists only if GD 2.0.1 is avaliable
         imagefilledarc($im, $centerX + 1, $centerY + 1, $diameter, $diameter, $start, $end, $color1, IMG_ARC_PIE);
         imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2, IMG_ARC_PIE);
         imagefilledarc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color1, IMG_ARC_NOFILL | IMG_ARC_EDGED);
     } else {
         imagearc($im, $centerX, $centerY, $diameter, $diameter, $start, $end, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($start + 1)) * $r, $centerY + sin(deg2rad($start)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end - 1)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
         imageline($im, $centerX, $centerY, $centerX + cos(deg2rad($end)) * $r, $centerY + sin(deg2rad($end)) * $r, $color2);
         imagefill($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $color2);
     }
     if ($text) {
         if ($placeindex > 0) {
             imageline($im, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $diameter, $placeindex * 12, $color1);
             imagestring($im, 4, $diameter, $placeindex * 12, $text, $color1);
         } else {
             imagestring($im, 4, $centerX + $r * cos($w) / 2, $centerY + $r * sin($w) / 2, $text, $color1);
         }
     }
 }
コード例 #6
0
ファイル: plot.php プロジェクト: Hepic/web-class
function draw_axes()
{
    global $im, $black, $gray;
    for ($x = -1.1; $x <= 1.1; $x += 0.2) {
        imagearc($im, transform_x($x), transform_y(y), 3, 3, 0, 360, $black);
        imagettftext($im, 10, 0, transform_x($x) - 10, transform_y(0) - 4, $black, FONT, $x);
        for ($y = 0; $y <= HEIGHT; $y += 30) {
            imageline($im, transform_x($x), $y, transform_x($x), $y + 10, $gray);
        }
        imagearc($im, transform_x($x), transform_y(f($x)), 3, 3, 0, 360, $black);
        for ($xprime = 0; $xprime <= transform_x($x); $xprime += 30) {
            imageline($im, $xprime, transform_y(f($x)), $xprime + 10, transform_y(f($x)), $gray);
        }
        imagettftext($im, 10, 0, transform_x($x) + 4, transform_y(f($x)), $black, FONT, round(f($x), 2));
    }
    // x axis
    imageline($im, 0, HEIGHT / 2, WIDTH, HEIGHT / 2, $black);
    // y axis
    imageline($im, WIDTH / 2, 0, WIDTH / 2, HEIGHT, $black);
    // box
    imageline($im, 0, 0, WIDTH, 0, $black);
    imageline($im, 0, 0, 0, HEIGHT, $black);
    imageline($im, 0, HEIGHT - 1, WIDTH - 1, HEIGHT - 1, $black);
    imageline($im, WIDTH - 1, 0, WIDTH - 1, HEIGHT - 1, $black);
}
コード例 #7
0
ファイル: gd_rectangle.php プロジェクト: Sajaki/addons
/**
 * GD Rectangle Function
 *
 * @param class $siggen
 * @param array $data
 * 		int x
 * 		int y
 * 		int x2
 * 		int y2
 * 		bool filled
 * 		int radius
 * 		string color
 * 		int alpha
 *
 * @return bool
 */
function gd_rectangle($siggen, $data)
{
    // Get our color index
    $color = $this->set_color($data['color'], $data['alpha']);
    // Make sure radius is a positive number
    $data['radius'] = abs($data['radius']);
    // Only do this "massive" drawing if we have rounded corners
    if ($data['radius'] > 0) {
        if ($data['filled'] == 1) {
            imagefilledrectangle($siggen->im, $data['x'] + $data['radius'], $data['y'], $data['x2'] - $data['radius'], $data['y2'], $color);
            imagefilledrectangle($siggen->im, $data['x'], $data['y'] + $data['radius'], $data['x'] + $data['radius'] - 1, $data['y2'] - $data['radius'], $color);
            imagefilledrectangle($siggen->im, $data['x2'] - $data['radius'] + 1, $data['y'] + $data['radius'], $data['x2'], $data['y2'] - $data['radius'], $color);
            imagefilledarc($siggen->im, $data['x'] + $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 180, 270, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x2'] - $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 270, 360, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x'] + $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 90, 180, $color, IMG_ARC_PIE);
            imagefilledarc($siggen->im, $data['x2'] - $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 360, 90, $color, IMG_ARC_PIE);
        } else {
            imageline($siggen->im, $data['x'] + $data['radius'], $data['y'], $data['x2'] - $data['radius'], $data['y'], $color);
            imageline($siggen->im, $data['x'] + $data['radius'], $data['y2'], $data['x2'] - $data['radius'], $data['y2'], $color);
            imageline($siggen->im, $data['x'], $data['y'] + $data['radius'], $data['x'], $data['y2'] - $data['radius'], $color);
            imageline($siggen->im, $data['x2'], $data['y'] + $data['radius'], $data['x2'], $data['y2'] - $data['radius'], $color);
            imagearc($siggen->im, $data['x'] + $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 180, 270, $color);
            imagearc($siggen->im, $data['x2'] - $data['radius'], $data['y'] + $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 270, 360, $color);
            imagearc($siggen->im, $data['x'] + $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 90, 180, $color);
            imagearc($siggen->im, $data['x2'] - $data['radius'], $data['y2'] - $data['radius'], $data['radius'] * 2, $data['radius'] * 2, 360, 90, $color);
        }
    } else {
        if ($data['filled'] == 1) {
            imagefilledrectangle($siggen->im, $data['x'], $data['y'], $data['x2'], $data['y2'], $color);
        } else {
            imagerectangle($siggen->im, $data['x'], $data['y'], $data['x2'], $data['y2'], $color);
        }
    }
    return TRUE;
}
コード例 #8
0
ファイル: captcha.php プロジェクト: phpsa/CoreCMS
 /**
  * renders the current captcha image
  */
 function showImage()
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $width = imagesx($image);
     $height = imagesy($image);
     $black = imagecolorallocate($image, 0, 0, 0);
     $white = imagecolorallocate($image, 250, 250, 250);
     $red = imagecolorallocatealpha($image, 225, 225, 225, 75);
     $green = imagecolorallocatealpha($image, 150, 150, 150, 75);
     $blue = imagecolorallocatealpha($image, 200, 200, 200, 75);
     imagefilledrectangle($image, 0, 0, $width, $height, $white);
     imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
     $points = array(rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50));
     imagefilledpolygon($image, $points, 4, $blue);
     imagefilledpolygon($image, array_reverse($points), 6, $green);
     imagefilledrectangle($image, 0, 0, $width, 0, $black);
     imagefilledrectangle($image, $width - 1, 0, $width - 1, $height - 1, $black);
     imagefilledrectangle($image, 0, 0, 0, $height - 1, $black);
     imagefilledrectangle($image, 0, $height - 1, $width, $height - 1, $black);
     for ($i = 0; $i < 50; $i++) {
         //imagefilledrectangle($im, $i + $i2, 5, $i + $i3, 70, $black);
         imagesetthickness($image, rand(1, 5));
         imagearc($image, rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(0, 1) ? $green : $red);
     }
     if (function_exists("imagettftext")) {
         $font = DIR_ROOT . 'view/fonts/Duality.ttf';
         imagettftext($image, 24, rand(-5, 5), intval(($width - strlen($this->code) * 10) / 2), intval(($height + 10) / 2), $black, $font, $this->code);
     } else {
         imagestring($image, 5, intval(($width - strlen($this->code) * 9) / 2), intval(($height - 15) / 2), $this->code, $black);
     }
     header('Content-type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
コード例 #9
0
ファイル: piechart.class.php プロジェクト: patmark/care2x-tz
 function createimage()
 {
     $this->calculate();
     $r = $this->radius;
     //$image=imagecreate($r*3,$r*2); // Modified by Elpidio Latorilla 2003-04-23
     $image = imagecreate($r * 2, $r * 2);
     $white = imagecolorallocate($image, 255, 255, 255);
     $black = imagecolorallocate($image, 0, 0, 0);
     imagecolorTransparent($image, $white);
     for ($k = 0; $k < count($this->colors); $k++) {
         $fillcolor[$k] = imagecolorallocate($image, $this->colornames[$this->colors[$k]][0], $this->colornames[$this->colors[$k]][1], $this->colornames[$this->colors[$k]][2]);
     }
     imagearc($image, $r, $r, $r * 2 - 1, $r * 2 - 1, 0, 360, $black);
     imagefill($image, $r, $r, $fillcolor[0]);
     for ($j = 0; $j < count($this->elements); $j++) {
         $degree += 360 * $this->fractions[$j];
         if ($this->elements[$j]) {
             imageline($image, $r, $r, $r + $r * cos($degree * pi() / 180), $r + $r * sin($degree * pi() / 180), $black);
             imagefill($image, $r + 15 * cos(($degree + 5) * pi() / 180), $r + 15 * sin(($degree + 5) * pi() / 180), $fillcolor[$j]);
         }
         // Modified by Elpidio Latorilla 2003-04-23
         //imagefilledrectangle($image,2.1*$r,.7*$r+($r/15)*$j,2.12*$r+($r/25),.7*$r+5+($r/15)*$j,$fillcolor[$j]);
         //imagestring($image,0,2.13*$r+$r/20,.71*$r+($r/15)*$j-2,$this->elements[$j]."-".$this->elementnames[$j],$black);
     }
     $this->final = $image;
 }
コード例 #10
0
ファイル: Image.class.php プロジェクト: fengxiangyun/diary
 /**
  * 
  * @brief 图片处理 验证码
  * @param unknown_type $length
  * @param unknown_type $mode
  * @param unknown_type $type
  * @param unknown_type $width
  * @param unknown_type $height
  * @param unknown_type $verifyName
  */
 public static function buildImageVerify($length = 4, $mode = 1, $type = 'png', $width = 48, $height = 22, $verifyName = 'verify')
 {
     $randval = self::randString($length, $mode);
     $_SESSION[$verifyName] = md5($randval);
     $width = $length * 10 + 10 > $width ? $length * 10 + 10 : $width;
     if ($type != 'gif' && function_exists('imagecreatetruecolor')) {
         $im = imagecreatetruecolor($width, $height);
     } else {
         $im = imagecreate($width, $height);
     }
     $r = array(225, 255, 255, 223);
     $g = array(225, 236, 237, 255);
     $b = array(225, 236, 166, 125);
     $key = mt_rand(0, 3);
     $backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]);
     //背景色(随机)
     $borderColor = imagecolorallocate($im, 100, 100, 100);
     //边框色
     imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
     imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
     $stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
     // 干扰
     for ($i = 0; $i < 10; $i++) {
         imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(200, 300), mt_rand(35, 200), 55, 44, $stringColor);
     }
     for ($i = 0; $i < 25; $i++) {
         imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $stringColor);
     }
     for ($i = 0; $i < $length; $i++) {
         imagestring($im, 5, $i * 10 + 5, mt_rand(1, 8), $randval[$i], $stringColor);
     }
     Image::output($im, $type);
 }
コード例 #11
0
ファイル: captcha.class.php プロジェクト: phphonor/companycms
 /**
  * +----------------------------------------------------------
  * 图片上传的处理函数
  * +----------------------------------------------------------
  */
 function create_captcha()
 {
     $word = $this->create_word();
     // 把验证码字符串写入session
     $_SESSION['captcha'] = md5($word . DOU_SHELL);
     // 绘制基本框架
     $im = imagecreatetruecolor($this->captcha_width, $this->captcha_height);
     $bg_color = imagecolorallocate($im, 235, 236, 237);
     imagefilledrectangle($im, 0, 0, $this->captcha_width, $this->captcha_height, $bg_color);
     $border_color = imagecolorallocate($im, 118, 151, 199);
     imagerectangle($im, 0, 0, $this->captcha_width - 1, $this->captcha_height - 1, $border_color);
     // 添加干扰
     for ($i = 0; $i < 5; $i++) {
         $rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($im, mt_rand(-$this->captcha_width, $this->captcha_width), mt_rand(-$this->captcha_height, $this->captcha_height), mt_rand(30, $this->captcha_width * 2), mt_rand(20, $this->captcha_height * 2), mt_rand(0, 360), mt_rand(0, 360), $rand_color);
     }
     for ($i = 0; $i < 50; $i++) {
         $rand_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($im, mt_rand(0, $this->captcha_width), mt_rand(0, $this->captcha_height), $rand_color);
     }
     // 生成验证码图片
     $text_color = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
     imagestring($im, 6, 18, 5, $word, $text_color);
     // header
     header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
     header("Content-type: image/png;charset=utf-8");
     /* 绘图结束 */
     imagepng($im);
     imagedestroy($im);
     return true;
 }
コード例 #12
0
ファイル: Drawer.php プロジェクト: nicodmf/Imagine
 /**
  * (non-PHPdoc)
  * @see Imagine\Draw\DrawerInterface::arc()
  */
 public function arc(PointInterface $center, BoxInterface $size, $start, $end, Color $color)
 {
     if (false === imagearc($this->resource, $center->getX(), $center->getY(), $size->getWidth(), $size->getHeight(), $start, $end, $this->getColor($color))) {
         throw new RuntimeException('Draw arc operation failed');
     }
     return $this;
 }
コード例 #13
0
ファイル: Image.class.php プロジェクト: princehaku/flowphp
 public static function buildVerifyImage($length = 4, $width = 48, $height = 22, $verifyName = 'verify')
 {
     $randval = substr(md5(time() . microtime()), 5, $length);
     header('Content-Type: image/gif');
     $_SESSION[$verifyName] = md5($randval);
     $width = $length * 9 + 10 > $width ? $length * 9 + 10 : $width;
     $im = @imagecreate($width, $height);
     $r = array(225, 255, 255, 223);
     $g = array(225, 236, 237, 255);
     $b = array(225, 236, 166, 125);
     $key = mt_rand(0, 3);
     $backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]);
     //背景色(随机)
     $borderColor = imagecolorallocate($im, 100, 100, 100);
     //边框色
     $pointColor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
     //点颜色
     @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
     //@imagerectangle($im, 0, 0, $width-1, $height-1, $borderColor);
     $stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
     //干扰
     for ($i = 0; $i < 5; $i++) {
         $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $fontcolor);
     }
     for ($i = 0; $i < 10; $i++) {
         $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $pointColor);
     }
     @imagestring($im, 5, 5, 3, $randval, $stringColor);
     imagegif($im);
 }
コード例 #14
0
 /**
  * Draws this object onto an image
  *
  * @param   img.Image image
  * @return  var
  */
 public function draw($image)
 {
     if (FALSE !== $this->fill) {
         return imagefilledarc($image->handle, $this->cx, $this->cy, $this->w, $this->h, $this->s, $this->e, $this->col->handle, $this->fill);
     } else {
         return imagearc($image->handle, $this->cx, $this->cy, $this->w, $this->h, $this->s, $this->e, $this->col->handle);
     }
 }
コード例 #15
0
ファイル: image-2.php プロジェクト: Atiragram/poit-labs
	function draw_data($x,$y,$rad,$color, $isCore = false)
	{
		global $im,$x0,$y0,$black, $maxX, $maxY;
		
		//рисуем точку
		imagefilledarc($im,$x0 + $x,$maxY-$y,$rad,$rad,0,360,$color,IMG_ARC_PIE);
		if ($isCore) imagearc($im,$x0 + $x,$maxY-$y,$rad,$rad,0,360,$black);
	}
コード例 #16
0
ファイル: Captcha.php プロジェクト: tsoftware-org/captcha
 private function drawLines()
 {
     $lineCnt = mt_rand(4, 8);
     for ($i = 0; $i < $lineCnt; $i++) {
         imagesetthickness($this->tmpImage, rand(1, 3));
         imagearc($this->tmpImage, mt_rand(-10, $this->width), mt_rand(-10, $this->height), mt_rand(30, 300), mt_rand(20, 200), mt_rand(80, 360), mt_rand(0, 300), $this->textColor);
     }
 }
コード例 #17
0
ファイル: Circle.php プロジェクト: XanderKon/Exercises
 public function draw($data)
 {
     $img = $this->prepare_image($data);
     if (!empty($data['fill_color'])) {
         imagefilledellipse($img, $this->padding + $data['radius'], $this->padding + $data['radius'], $data['radius'], $data['radius'], $this->get_line_color($img, $data['fill_color']));
     }
     imagearc($img, $this->padding + $data['radius'], $this->padding + $data['radius'], $data['radius'], $data['radius'], 0, 360, $this->get_line_color($img, $data['line_color']));
     $this->_draw($img);
 }
コード例 #18
0
ファイル: secimage.php プロジェクト: startrekfinalfrontier/UI
function circle_sectioned($x, $y, $radius, $color)
{
    global $image;
    for ($rad = $radius - 4; $rad <= $radius; $rad++) {
        for ($sections = 0; $sections < 6; $sections++) {
            imagearc($image, $x, $y, $rad, $rad, $sections * 60, $sections * 60 + 40, $color);
        }
    }
}
コード例 #19
0
ファイル: Images.php プロジェクト: rendix2/QW_MVS
 public function arc(Point $center, $width, $height, $start, $end, $style = NULL, $filled = FALSE, Color $color = NULL)
 {
     if (!$center->isInImage($this)) {
         throw new IllegalArgumentException();
     }
     if ($filled == TRUE && $style == NULL) {
         throw new IllegalArgumentException();
     }
     $filled == TRUE ? imagefilledarc($this->imageResource, $center->getX(), $center->getY(), $width, $height, $start, $end, $this->prepareColor($color), $style) : imagearc($this->imageResource, $center->getX(), $center->getY(), $width, $height, $start, $end, $this->prepareColor($color));
 }
コード例 #20
0
ファイル: class.php プロジェクト: AJLoveChina/PHPVerifyCode
 public function mkCode($num = 4, $size = 20, $width = 0, $height = 0)
 {
     // $num => 验证码字符数目
     // $size => 字符大小(注意单位是pt不是px)
     // $width这只是大概的图像宽度,因为不同字体的同样font-size所占width也是有微小差距的
     !$width && ($width = $num * $size);
     //根据要显示验证码字符长度设置验证码图像长度
     !$height && ($height = $size + 10);
     //设置图像的高度
     $font_url = dirname(dirname(__FILE__)) . "/font/mywanderingheart.ttf";
     //如果字体路径错误:会无法显示验证码,但是有图像(后面这一点得看情况)
     // 我们要显示的验证码字符集合
     $str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVW";
     //要显示的验证码
     $code = '';
     for ($i = 0; $i < $num; $i++) {
         $code .= $str[mt_rand(0, strlen($str) - 1)];
     }
     // 画图像,新建一个真彩色图像,并返回一个图像标识符赋值给 $im
     $im = imagecreatetruecolor($width, $height);
     // 定义要用到的颜色
     $background_color = imagecolorallocate($im, 255, 255, 255);
     //这里默认白色背景
     $border_color = imagecolorallocate($im, 255, 255, 255);
     //这里默认白色边框
     $text_color = imagecolorallocate($im, 50, 50, 50);
     //这里默认淡黑色字体颜色
     // 画背景
     imagefilledrectangle($im, 0, 0, $width, $height, $background_color);
     // 画边框(该函数事实上是画一个矩形)
     imagerectangle($im, 0, 0, $width - 1, $height - 1, $border_color);
     // 画干扰点
     for ($i = 0; $i < 10 * $num; $i++) {
         $font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $font_color);
     }
     // 默认画4条干扰线
     //这地方可以自己研究一下
     for ($i = 0; $i < 4; $i++) {
         $font_color = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($im, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, 360), mt_rand(0, 360), $font_color);
         // imagearc($im, 0, 0, $width*2, $height, 0, 90, $font_color);
     }
     //好吧,是时候把验证码字符画上去了
     @imagefttext($im, $size, 0, 10, $size + 5, $text_color, $font_url, $code);
     // 喂,浏览器!我给你发的这个东西不要从你的缓存中拿啊。还有啊,这是一个png图像,不要解析错了。
     header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
     header("Content-type: image/png;charset=utf-8");
     // imagepng 以 PNG 格式将图像输出到浏览器,如果指定了第二个参数 filename 将保存图像到文件
     // 例如imagepng( $im, '1.png' ); 将图像保存到同级目录下的1.png文件(如果该文件已存在则覆盖)
     imagepng($im);
     imagedestroy($im);
     return $code;
     //把验证码字符返回
 }
コード例 #21
0
ファイル: indexControl.class.php プロジェクト: sujinw/tcphp
 public function imagetest()
 {
     ob_end_clean();
     header("Content-type: image/png");
     $im = @imagecreate(200, 200) or die("创建图像资源失败");
     $bg = imagecolorallocate($im, 204, 204, 204);
     $red = imagecolorallocate($im, 255, 0, 0);
     imagearc($im, 100, 100, 150, 150, 0, 360, $red);
     imagepng($im);
     imagedestroy($im);
 }
コード例 #22
0
 /**
  * 给验证码画干扰线
  */
 public function plotLine()
 {
     for ($i = 0; $i < 15; $i++) {
         $fontcolor = imagecolorallocate($this->img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($this->img, mt_rand(-10, $this->wildth), mt_rand(-10, $this->height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $fontcolor);
     }
     for ($i = 0; $i < 255; $i++) {
         $fontcolor = imagecolorallocate($this->img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($this->img, mt_rand(0, $this->wildth), mt_rand(0, $this->height), $fontcolor);
     }
 }
コード例 #23
0
ファイル: image.class.php プロジェクト: 994724435/church
 public function verify($mode = 1, $length = 4, $width = 60, $height = 22)
 {
     session_start();
     $img = imagecreatetruecolor($width, $height);
     //创建颜色
     $bgcolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
     //画一个矩形并填充
     imagefilledrectangle($img, 0, 0, $width - 1, $height - 1, $bgcolor);
     //画点
     for ($i = 0; $i < 60; $i++) {
         $pointcolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($img, mt_rand(0, $width), mt_rand(0, $height), $pointcolor);
     }
     //画线段
     for ($i = 0; $i < 10; $i++) {
         $linecolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imageline($img, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $linecolor);
     }
     //画弧线
     for ($i = 0; $i < 10; $i++) {
         $hucolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagearc($img, mt_rand(10, $width - 10), mt_rand(10, $height - 10), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, 360), mt_rand(0, 360), $hucolor);
     }
     //产生一个随机字符串
     $num = '0123456789';
     $zimu = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $str = '';
     switch ($mode) {
         case 1:
             $str = $num;
             break;
         case 2:
             $str = $zimu;
             break;
         case 3:
             $str = $num . $zimu;
     }
     //将字符串当做数组
     $str2 = '';
     for ($i = 0; $i < $length; $i++) {
         $str2 .= $str[mt_rand(0, strlen($str) - 1)];
     }
     //存session中
     $_SESSION['verify'] = md5($str2);
     for ($i = 0; $i < strlen($str2); $i++) {
         //水平的画一个字符串
         $strcolor = imagecolorallocate($img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         //imagestring($img, 5, 0, 0, $str2, $strcolor);
         $x = 10 + ($width - 10 * 2) / 4 * $i;
         imagettftext($img, 15, mt_rand(-10, 10), $x, $height, $strcolor, 'consola.ttf', substr($str2, $i, 1));
     }
     //输出并销毁
     $this->putout($img);
 }
コード例 #24
0
ファイル: vcode.class.php プロジェクト: elaine96/message
 private function setdisturbcolor()
 {
     for ($i = 0; $i < 90; $i++) {
         $color = imagecolorallocate($this->img, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($this->img, rand(1, $this->width - 2), rand(1, $this->height - 2), $color);
     }
     for ($i = 0; $i < 10; $i++) {
         $color = imagecolorallocate($this->img, rand(128, 225), rand(128, 225), rand(128, 225));
         imagearc($this->img, rand(-10, $this->width + 10), rand(-10, $this->height + 10), rand(30, 300), rand(30, 300), 55, 44, $color);
     }
 }
コード例 #25
0
 private function setDisturbColor()
 {
     for ($i = 0; $i < $this->disturbColorNum; $i++) {
         $color = imagecolorallocate($this->image, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($this->image, rand(1, $this->width - 2), rand(1, $this->height - 2), $color);
     }
     for ($i = 0; $i < 10; $i++) {
         $color = imagecolorallocate($this->image, rand(200, 255), rand(200, 255), rand(200, 255));
         imagearc($this->image, rand(-10, $this->width), rand(-10, $this->height), rand(30, 300), rand(20, 200), 55, 44, $color);
     }
 }
コード例 #26
0
function imageroundedrectangle($image, $x1, $y1, $x2, $y2, $radius, $color)
{
    imageline($image, $x1 + $radius, $y1, $x2 - $radius, $y1, $color);
    imageline($image, $x1 + $radius, $y2, $x2 - $radius, $y2, $color);
    imageline($image, $x1, $y1 + $radius, $x1, $y2 - $radius, $color);
    imageline($image, $x2, $y1 + $radius, $x2, $y2 - $radius, $color);
    imagearc($image, $x1 + $radius, $y1 + $radius, $radius * 2, $radius * 2, 180, 270, $color);
    imagearc($image, $x2 - $radius, $y1 + $radius, $radius * 2, $radius * 2, 270, 360, $color);
    imagearc($image, $x1 + $radius, $y2 - $radius, $radius * 2, $radius * 2, 90, 180, $color);
    imagearc($image, $x2 - $radius, $y2 - $radius, $radius * 2, $radius * 2, 0, 90, $color);
}
コード例 #27
0
ファイル: verify_code.php プロジェクト: marche147/nsc-website
 private function drawDummy()
 {
     for ($i = 0; $i < 100; $i++) {
         $pcolor = imagecolorallocate($this->img, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
         imagesetpixel($this->img, rand(1, $this->codeWidth - 3), rand(1, $this->codeHeight - 3), $pcolor);
     }
     for ($i = 0; $i < 10; $i++) {
         $lcolor = imagecolorallocate($this->img, mt_rand(0, 255), mt_rand(0, 128), mt_rand(0, 255));
         imagearc($this->img, mt_rand(-10, $this->codeWidth + 10), mt_rand(-10, $this->codeHeight + 10), mt_rand(30, 300), mt_rand(30, 300), 55, 44, $lcolor);
     }
     return;
 }
コード例 #28
0
ファイル: verifycode.php プロジェクト: ZinChen2014/breeze
function verifyImg()
{
    session_start();
    $length = empty($_REQUEST['length']) ? 5 : intval($_REQUEST['length']);
    $width = empty($_REQUEST['width']) ? 68 : intval($_REQUEST['width']);
    $height = empty($_REQUEST['height']) ? 28 : intval($_REQUEST['height']);
    $chs = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';
    $code = '';
    for ($i = 0; $i < $length; $i++) {
        $sn = rand(0, 34);
        $code .= substr($chs, $sn, 1);
    }
    $_SESSION["verifycode"] = $code;
    $w = $length * 10 + 10;
    if ($w > $width) {
        $width = $w;
    }
    if (function_exists('imagecreatetruecolor')) {
        $im = @imagecreatetruecolor($width, $height);
    } else {
        $im = @imagecreate($width, $height);
    }
    $r = array(225, 255, 255, 223);
    $g = array(225, 236, 237, 255);
    $b = array(225, 236, 166, 125);
    $key = mt_rand(0, 3);
    $backColor = imagecolorallocate($im, $r[$key], $g[$key], $b[$key]);
    //±³¾°É«£¨Ëæ»ú£©
    $borderColor = imagecolorallocate($im, 100, 100, 100);
    //±ß¿òÉ«
    $pointColor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
    //µãÑÕÉ«
    @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
    @imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
    $stringColor = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    // ¸ÉÈÅ
    for ($i = 0; $i < 10; $i++) {
        $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
        imagearc($im, mt_rand(-10, $width), mt_rand(-10, $height), mt_rand(30, 300), mt_rand(20, 200), 55, 44, $fontcolor);
    }
    for ($i = 0; $i < 25; $i++) {
        $fontcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
        imagesetpixel($im, mt_rand(0, $width), mt_rand(0, $height), $pointColor);
    }
    for ($i = 0; $i < $length; $i++) {
        imagestring($im, 5, $i * 10 + 5, mt_rand(1, 8), $code[$i], $stringColor);
    }
    ob_clean();
    header('Content-type: image/png');
    imagepng($im);
    imagedestroy($im);
}
コード例 #29
0
ファイル: BLHN_Baptcha.php プロジェクト: blrik/bWorld
 private function setDisturb()
 {
     $area = $this->width * $this->height / 20;
     $disturbNum = $area > 250 ? 250 : $area;
     for ($i = 0; $i < $disturbNum; $i++) {
         $color = imagecolorallocate($this->im, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($this->im, rand(1, $this->width - 2), rand(1, $this->height - 2), $color);
     }
     for ($i = 0; $i <= 5; $i++) {
         $color = imagecolorallocate($this->im, rand(128, 255), rand(125, 255), rand(100, 255));
         imagearc($this->im, rand(0, $this->width), rand(0, $this->height), rand(30, 300), rand(20, 200), 50, 30, $color);
     }
 }
コード例 #30
0
function roundedRectangle($image, $x1, $y1, $x2, $y2, $curveDepth, $color)
{
    // Draw the four sides
    imageline($image, $x1 + $curveDepth, $y1, $x2 - $curveDepth, $y1, $color);
    imageline($image, $x1 + $curveDepth, $y2, $x2 - $curveDepth, $y2, $color);
    imageline($image, $x1, $y1 + $curveDepth, $x1, $y2 - $curveDepth, $color);
    imageline($image, $x2, $y1 + $curveDepth, $x2, $y2 - $curveDepth, $color);
    // Draw the four corners
    imagearc($image, $x1 + $curveDepth, $y1 + $curveDepth, 2 * $curveDepth, 2 * $curveDepth, 180, 270, $color);
    imagearc($image, $x2 - $curveDepth, $y1 + $curveDepth, 2 * $curveDepth, 2 * $curveDepth, 270, 360, $color);
    imagearc($image, $x2 - $curveDepth, $y2 - $curveDepth, 2 * $curveDepth, 2 * $curveDepth, 0, 90, $color);
    imagearc($image, $x1 + $curveDepth, $y2 - $curveDepth, 2 * $curveDepth, 2 * $curveDepth, 90, 180, $color);
}