当前位置: 首页>>代码示例>>PHP>>正文


PHP imagerectangle函数代码示例

本文整理汇总了PHP中imagerectangle函数的典型用法代码示例。如果您正苦于以下问题:PHP imagerectangle函数的具体用法?PHP imagerectangle怎么用?PHP imagerectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imagerectangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * 以指定图片为模板,生成随机的验证码,存放在session库中
  */
 public static function generate()
 {
     header('Content-Type:image/jpeg');
     //加载画布
     $captcha = TOOL_PATH . '/captcha/' . mt_rand(1, 8) . '.jpg';
     $image = imagecreatefromjpeg($captcha);
     //在画布设置颜色
     $white = imagecolorallocate($image, 255, 255, 255);
     $black = imagecolorallocate($image, 0, 0, 0);
     $color = mt_rand(1, 2) == 1 ? $white : $black;
     //待画的字符串
     $code = self::getRandStr();
     //保存在session库中
     SessionTool::getInstance();
     $_SESSION['code'] = $code;
     //在画布中画矩形
     imagerectangle($image, 0, 0, 199, 79, $white);
     //在画布中写字
     imagestring($image, 5, 52, 3, $code, $color);
     //设置header头为图片
     //输出图片
     imagejpeg($image);
     //销毁图片
     imagedestroy($image);
 }
开发者ID:dower-d,项目名称:shop,代码行数:28,代码来源:CaptchaTool.class.php

示例2: printAxis

 /**
  * Print the axis.
  */
 protected function printAxis()
 {
     $minValue = $this->axis->getLowerBoundary();
     $maxValue = $this->axis->getUpperBoundary();
     $stepValue = $this->axis->getTics();
     // Get graphical obects
     $img = $this->plot->getImg();
     $palette = $this->plot->getPalette();
     $text = $this->plot->getText();
     // Get the graph area
     $graphArea = $this->plot->getGraphArea();
     // Vertical axis
     for ($value = $minValue; $value <= $maxValue; $value += $stepValue) {
         $y = $graphArea->y2 - ($value - $minValue) * ($graphArea->y2 - $graphArea->y1) / $this->axis->displayDelta;
         imagerectangle($img, $graphArea->x1 - 3, $y, $graphArea->x1 - 2, $y + 1, $palette->axisColor[0]->getColor($img));
         imagerectangle($img, $graphArea->x1 - 1, $y, $graphArea->x1, $y + 1, $palette->axisColor[1]->getColor($img));
         $text->printText($img, $graphArea->x1 - 5, $y, $this->plot->getTextColor(), $value, $text->fontCondensed, $text->HORIZONTAL_RIGHT_ALIGN | $text->VERTICAL_CENTER_ALIGN);
     }
     // Get first serie of a list
     $pointList = $this->getFirstSerieOfList();
     // Horizontal Axis
     $pointCount = count($pointList);
     reset($pointList);
     $columnWidth = ($graphArea->x2 - $graphArea->x1) / ($pointCount - 1);
     for ($i = 0; $i < $pointCount; $i++) {
         $x = $graphArea->x1 + $i * $columnWidth;
         imagerectangle($img, $x - 1, $graphArea->y2 + 2, $x, $graphArea->y2 + 3, $palette->axisColor[0]->getColor($img));
         imagerectangle($img, $x - 1, $graphArea->y2, $x, $graphArea->y2 + 1, $palette->axisColor[1]->getColor($img));
         $point = current($pointList);
         next($pointList);
         $label = $point->getX();
         $text->printDiagonal($img, $x - 5, $graphArea->y2 + 10, $this->plot->getTextColor(), $label);
     }
 }
开发者ID:msd1310,项目名称:ci_bootstrap,代码行数:37,代码来源:LineChart.php

示例3: getCode

function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
开发者ID:hanpc,项目名称:chushen,代码行数:35,代码来源:code_char.php

示例4: drawGraphArea

 function drawGraphArea($R, $G, $B)
 {
     $color = imagecolorallocate($this->img, $R, $G, $B);
     $x1 = $this->init['x1'];
     $y1 = $this->init['y1'];
     $x2 = $this->init['x2'];
     $y2 = $this->init['y2'];
     imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $color);
     $color2 = imagecolorallocate($this->img, $R - 40, $G - 40, $B - 40);
     imagerectangle($this->img, $x1, $y1, $x2, $y2, $color2);
     if (!$this->init['bgStripe']) {
         return;
     }
     $color3 = imagecolorallocate($this->img, $R - 15, $G - 15, $B - 14);
     $imgH = $y2 - $y1 - 1;
     for ($i = $x1 - $imgH; $i <= $x2; $i = $i + 4) {
         $a1 = $i;
         $b1 = $y2;
         $a2 = $i + $imgH;
         $b2 = $y1;
         if ($a1 < $x1) {
             $a1 = $x1;
             $b1 = $y1 + $a2 - $x1 + 1;
         }
         if ($a2 >= $x2) {
             $b2 = $y1 + $a2 - $x2 + 1;
             $a2 = $x2 - 1;
         }
         imageline($this->img, $a1, $b1, $a2, $b2 + 1, $color3);
     }
 }
开发者ID:abdeljawwad,项目名称:sedr,代码行数:31,代码来源:bChart.php

示例5: imgcode

function imgcode($nums, $width, $high)
{
    //去除了數字0和1 字母小寫O和L,為了避免辨識不清楚
    //$str = "23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMOPQRSTUBWXYZ";
    $str = "0123456789";
    $code = '';
    for ($i = 0; $i < $nums; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    $_SESSION['captcha'] = $code;
    //建立圖示,設置寬度及高度與顏色等等條件
    $image = imagecreate($width, $high);
    $black = imagecolorallocate($image, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
    $border_color = imagecolorallocate($image, 21, 106, 235);
    $background_color = imagecolorallocate($image, 235, 236, 237);
    //建立圖示背景
    imagefilledrectangle($image, 0, 0, $width, $high, $background_color);
    //建立圖示邊框
    imagerectangle($image, 0, 0, $width - 1, $high - 1, $border_color);
    //在圖示布上隨機產生大量躁點
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($image, rand(0, $width), rand(0, $high), $black);
    }
    $strx = rand(3, 8);
    for ($i = 0; $i < $nums; $i++) {
        $strpos = rand(1, 6);
        imagestring($image, 5, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += rand(10, 30);
    }
    imagepng($image);
    imagedestroy($image);
}
开发者ID:FantasticThought,项目名称:tfsda,代码行数:32,代码来源:captcha.php

示例6: createAuthNumImg

function createAuthNumImg($randStr, $imgW = 100, $imgH = 40, $fontName)
{
    $image = imagecreate($imgW, $imgH);
    $color_white = imagecolorallocate($image, 255, 255, 255);
    $color_gray = imagecolorallocate($image, 228, 228, 228);
    $color_black = imagecolorallocate($image, 255, 102, 204);
    $color_radom = imagecolorallocate($image, rand(1, 200), rand(1, 200), rand(10, 250));
    for ($i = 0; $i < 2000; $i++) {
        $c = imagecolorallocate($image, rand(1, 200), rand(1, 200), rand(10, 250));
        imagesetpixel($image, mt_rand(0, $imgW), mt_rand(0, $imgH), $c);
        //Ìí¼ÓÔÓµã
    }
    imagerectangle($image, 0, 0, $imgW - 1, $imgH - 1, $color_gray);
    imagettftext($image, 50, mt_rand(-2, 2), rand(0, 20), 50, $color_radom, $fontName, $randStr);
    for ($i = 10; $i < $imgH; $i += 10) {
        imageline($image, 0, $i, $imgW, $i, $color_gray);
    }
    //»­ºáÏß
    for ($i = 10; $i < $imgW; $i += 10) {
        imageline($image, $i, 0, $i, $imgH, $color_gray);
    }
    //»­ÊúÏß
    imagepng($image);
    imagedestroy($image);
}
开发者ID:topstdio,项目名称:xnova,代码行数:25,代码来源:verify.php

示例7: create_captcha

 /**
  * +----------------------------------------------------------
  * 图片上传的处理函数
  * +----------------------------------------------------------
  */
 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;
 }
开发者ID:phphonor,项目名称:companycms,代码行数:36,代码来源:captcha.class.php

示例8: outlinedBox

 /**
  * Draw a filled gray box with thick borders and darker corners.
  *
  * @param integer top left coordinate (x)
  * @param integer top left coordinate (y)
  * @param integer bottom right coordinate (x)
  * @param integer bottom right coordinate (y)
  * @param Color edge color
  * @param Color corner color
  */
 public function outlinedBox($x1, $y1, $x2, $y2, $color0, $color1) {
     imagefilledrectangle($this->img, $x1, $y1, $x2, $y2, $color0->getColor($this->img));
     imagerectangle($this->img, $x1, $y1, $x1 + 1, $y1 + 1, $color1->getColor($this->img));
     imagerectangle($this->img, $x2 - 1, $y1, $x2, $y1 + 1, $color1->getColor($this->img));
     imagerectangle($this->img, $x1, $y2 - 1, $x1 + 1, $y2, $color1->getColor($this->img));
     imagerectangle($this->img, $x2 - 1, $y2 - 1, $x2, $y2, $color1->getColor($this->img));
 }
开发者ID:Hassanj343,项目名称:candidats,代码行数:17,代码来源:Primitive.php

示例9: checkcode

 public function checkcode($width = 60, $height = 24, $verifyName = 'checkcode')
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $code = "ABCDEFGHKLMNPRSTUVWYZ23456789";
     $length = 4;
     $randval = '';
     for ($i = 0; $i < $length; $i++) {
         $char = $code[rand(0, strlen($code) - 1)];
         $randval .= $char;
     }
     $_SESSION[$verifyName] = strtolower($randval);
     $width = $length * 10 + 10 > $width ? $length * 10 + 10 : $width;
     $im = imagecreate($width, $height);
     $backColor = imagecolorallocate($im, 255, 255, 255);
     $borderColor = imagecolorallocate($im, 255, 255, 255);
     @imagefilledrectangle($im, 0, 0, $width - 1, $height - 1, $backColor);
     @imagerectangle($im, 0, 0, $width - 1, $height - 1, $borderColor);
     $fontcolor = imagecolorallocate($im, rand(0, 200), rand(0, 120), rand(0, 120));
     for ($i = 0; $i < $length; $i++) {
         $fontsize = 5;
         $x = floor($width / $length) * $i + 5;
         $y = rand(0, $height - 15);
         imagechar($im, $fontsize, $x, $y, $randval[$i], $fontcolor);
     }
     self::output($im, 'png');
 }
开发者ID:43431655,项目名称:qizhongbao,代码行数:28,代码来源:image.class.php

示例10: gd_rectangle

/**
 * 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;
}
开发者ID:Sajaki,项目名称:addons,代码行数:51,代码来源:gd_rectangle.php

示例11: CreateImage

function CreateImage()
{
    // cria o c�digo
    $md5Hash = md5(rand(0, 999));
    $securityCode = substr($md5Hash, 0, 6);
    // define a sess�o
    $_SESSION["SecurityCode"] = $securityCode;
    // dimens�es
    $width = 134;
    $height = 40;
    // cria imagem
    $image = @imagecreate($width, $height);
    // cores
    $white = imagecolorallocate($image, 0xff, 0xff, 0xff);
    $black = imagecolorallocate($image, 0x0, 0x0, 0x0);
    $grey = imagecolorallocate($image, 0x33, 0x33, 0x33);
    $blue = imagecolorallocate($image, 0x0, 0x0, 0xff);
    $red = imagecolorallocate($image, 0xff, 0x0, 0x0);
    $yellow = imagecolorallocate($image, 0xff, 0xff, 0x0);
    $arrayColors = array($grey, $black, $red, $blue);
    imagefill($image, 0, 0, $white);
    // escreve na imagem
    $arrayFonts = array("fonts/calibri.ttf", "fonts/berlin.ttf");
    for ($i = 0, $y = strlen($securityCode); $i < $y; $i++) {
        imagettftext($image, rand(13, 20), rand(-30, 30), 10 + 20 * $i, 25, $arrayColors[array_rand($arrayColors)], $arrayFonts[array_rand($arrayFonts)], $securityCode[$i]);
    }
    // faz uma borda
    imagerectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    // fase final
    @header("Content-Type: image/jpeg");
    imagejpeg($image);
    imagedestroy($image);
}
开发者ID:neilor,项目名称:MuShopping-v3,代码行数:33,代码来源:captcha.php

示例12: process

 protected function process(ViewBag $viewbag)
 {
     $movie = $this->movie;
     $list = $this->list;
     $im = imagecreate($this->W, $this->H);
     $background_color = imagecolorallocate($im, 0xc0, 0xc0, 0xc0);
     imagefilledrectangle($im, 0, 0, $this->W - 1, $this->H - 1, $background_color);
     $black = imagecolorallocate($im, 0, 0, 0);
     imagerectangle($im, 0, 0, $this->W - 1, $this->H - 1, $black);
     $red = imagecolorallocate($im, 0xc0, 0, 0);
     $max = $movie->getMaxSeek();
     $scale = DoubleVal($this->W) / DoubleVal($max);
     foreach ($list->getCutRegions() as $v) {
         $left = $v[0];
         $right = $v[1];
         if ($right == -1) {
             $right = $max;
         }
         $x1 = IntVal($left * $scale);
         $x2 = min($this->W - 1, IntVal($right * $scale));
         imagefilledrectangle($im, $x1, 1, $x2, $this->H - 2, $red);
     }
     header("Content-Type: image/png");
     header("Cache-Control: must-revalidate");
     imagepng($im);
     exit;
 }
开发者ID:roadrunner6,项目名称:mythcut,代码行数:27,代码来源:MovieStripeHandler.php

示例13: create

 /**
  * Create verify code
  */
 public function create()
 {
     //Image width(px)
     $this->width || ($this->width = $this->length * $this->fontsize * 1.5 + $this->fontsize * 1.5);
     //Image height(px)
     $this->height || ($this->height = $this->fontsize * 2);
     // Create $this->width x $this->height image
     $this->image = imagecreate($this->width, $this->height);
     //Set the background
     imagecolorallocate($this->image, $this->bg[0], $this->bg[1], $this->bg[2]);
     //Random font color of the verify code
     $this->color = imagecolorallocate($this->image, mt_rand(156, 256), mt_rand(156, 256), mt_rand(156, 256));
     //Set the border
     imagerectangle($this->image, 0, 0, $this->width - 1, $this->height - 1, $this->color);
     //Draw noise
     $this->writeNoise();
     //Drawn curve
     $this->writeCurve();
     //Drawn verify code
     $this->writeCode();
     //Save verify code
     $this->saveCode();
     //Output image
     imagepng($this->image);
     imagedestroy($this->image);
     $this->ci->output->set_content_type('png')->set_output($this->image);
 }
开发者ID:qdsay,项目名称:cms,代码行数:30,代码来源:Captcha.php

示例14: encodeImage

 public function encodeImage(ImageCaptcha $ci)
 {
     $w = $ci->getCaptcha()->getWidth();
     $h = $ci->getCaptcha()->getHeight();
     $image = imagecreatetruecolor($w, $h);
     imagefilledrectangle($image, 0, 0, $w, $h, $this->toHex($ci->getBackgroundColor()));
     imagerectangle($image, 0, 0, $w - 1, $h - 1, $this->toHex($ci->getBorderColor()));
     // border
     $lines = $ci->getLines();
     foreach ($lines as $line) {
         $color = $this->toHex($line['color']);
         imageline($image, $line['x1'], $line['y1'], $line['x2'], $line['y2'], $color);
     }
     $fontSize = $ci->getCaptcha()->getFontSize();
     $box = imagettfbbox($fontSize, 0, $this->font, '0');
     $spacing = $ci->getCaptcha() instanceof MathCaptcha ? 0 : 5;
     $text = $ci->getText();
     $x = ($w - $fontSize * strlen(str_replace(' ', '', $text))) / 2;
     $y = $h / 2 - ($box[3] - $box[5]) / 2 + $fontSize;
     for ($i = 0; $i < strlen($text); $i++) {
         $angle = $ci->randAngle();
         $color = $this->toHex($ci->randColor());
         $box = imagettftext($image, $fontSize, $angle, $x, $y, $color, $this->font, $text[$i]);
         $x += $spacing + ($box[2] - $box[0]);
     }
     $temp = tempnam(sys_get_temp_dir(), 'captcha');
     imagepng($image, $temp);
     $data = fread(fopen($temp, 'r'), filesize($temp));
     $base64 = base64_encode($data);
     imagedestroy($image);
     unlink($temp);
     return 'data:image/png;base64,' . $base64;
 }
开发者ID:rogeriolino,项目名称:php-captcha,代码行数:33,代码来源:GdCaptchaRenderer.php

示例15: buildImageVerify

 /**
  * 
  * @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);
 }
开发者ID:fengxiangyun,项目名称:diary,代码行数:43,代码来源:Image.class.php


注:本文中的imagerectangle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。