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


PHP imageline函数代码示例

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


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

示例1: 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

示例2: embroidery2image

function embroidery2image($embroidery, $scale_post = 1, $scale_pre = false)
{
    // Create image
    $im = imagecreatetruecolor(ceil($embroidery->imageWidth * $scale_post), ceil($embroidery->imageHeight * $scale_post));
    imagesavealpha($im, true);
    imagealphablending($im, false);
    $color = imagecolorallocatealpha($im, 255, 255, 255, 127);
    imagefill($im, 0, 0, $color);
    // Draw stitches
    foreach ($embroidery->blocks as $block) {
        $color = imagecolorallocate($im, $block->color->r, $block->color->g, $block->color->b);
        $x = false;
        foreach ($block->stitches as $stitch) {
            if ($x !== false) {
                imageline($im, ($x - $embroidery->min->x) * $scale_post, ($y - $embroidery->min->y) * $scale_post, ($stitch->x - $embroidery->min->x) * $scale_post, ($stitch->y - $embroidery->min->y) * $scale_post, $color);
            }
            $x = $stitch->x;
            $y = $stitch->y;
        }
    }
    // Scale finished image
    if ($scale_pre) {
        $im2 = imagecreatetruecolor($embroidery->imageWidth * $scale_post * $scale_pre, $embroidery->imageHeight * $scale_post * $scale_pre);
        imagesavealpha($im2, true);
        imagealphablending($im2, false);
        imagecopyresized($im2, $im, 0, 0, 0, 0, $embroidery->imageWidth * $scale_post * $scale_pre, $embroidery->imageHeight * $scale_post * $scale_pre, $embroidery->imageWidth * $scale_post, $embroidery->imageHeight * $scale_post);
        imagedestroy($im);
        $im = $im2;
    }
    return $im;
}
开发者ID:bobosch,项目名称:embroidery,代码行数:31,代码来源:embroidery2image.php

示例3: guvenlik_resmi

 function guvenlik_resmi()
 {
     $sifre = substr(md5(rand(0, 999999999999)), -5);
     if ($sifre) {
         $this->session->set_userdata('koruma', $sifre);
         $yukseklik = 62;
         $genislik = 200;
         $resim = ImageCreate($genislik, $yukseklik);
         $siyah = ImageColorAllocate($resim, 0, 0, 0);
         $kirmizi = ImageColorAllocate($resim, 182, 16, 99);
         $beyaz = ImageColorAllocate($resim, 255, 255, 255);
         ImageFill($resim, 0, 0, $beyaz);
         $font = 'css/comic.ttf';
         $font_boyut = 24;
         $sM = 30;
         $uM = 45;
         //kullanımı
         //resim adı, font boyutu, yazının açısı, yazının soldan margini, üstten margin, renk, font adı, şifrenin hangi digitinin yazılacağı bellirtiliyor
         imagettftext($resim, $font_boyut, rand(-45, 45), $sMa = $sM, $uM, rand(0, 255), $font, $sifre[0]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[1]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[2]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[3]);
         imagettftext($resim, $font_boyut, rand(-45, 45), $sM = $sMa + $sM, $uM, rand(0, 255), $font, $sifre[4]);
         //ImageRectangle($resim, 0, 0, $genislik-1, $yukseklik-1, $kirmizi);
         imageline($resim, 0, $yukseklik / 2, $genislik, $yukseklik / 2, $kirmizi);
         imageline($resim, $genislik / 2, 0, $genislik / 2, $yukseklik, $kirmizi);
         header("Content-Type: image/png");
         ImagePng($resim);
         ImageDestroy($resim);
     }
     exit;
 }
开发者ID:alyayazilim,项目名称:Servis-Takip,代码行数:32,代码来源:Sistem_yonetimi.php

示例4: index

 public function index()
 {
     ob_clean();
     $image_handle = imagecreatetruecolor(150, 60);
     $white = imagecolorallocate($image_handle, 255, 255, 255);
     $rndm = imagecolorallocate($image_handle, rand(64, 192), rand(64, 192), rand(64, 192));
     imagefill($image_handle, 0, 0, $white);
     $fontName = PUBLICPATH . "/fonts/elephant.ttf";
     $myX = 15;
     $myY = 30;
     $angle = 0;
     for ($x = 0; $x <= 100; $x++) {
         $myX = rand(1, 148);
         $myY = rand(1, 58);
         imageline($image_handle, $myX, $myY, $myX + rand(-5, 5), $myY + rand(-5, 5), $rndm);
     }
     $myCryptBase = tep_create_random_value(50, 'digits');
     $secure_image_hash_string = "";
     for ($x = 0; $x <= 4; $x++) {
         $dark = imagecolorallocate($image_handle, rand(5, 128), rand(5, 128), rand(5, 128));
         $capChar = substr($myCryptBase, rand(1, 35), 1);
         $secure_image_hash_string .= $capChar;
         $fs = rand(20, 26);
         $myX = 15 + ($x * 28 + rand(-5, 5));
         $myY = rand($fs + 2, 55);
         $angle = rand(-30, 30);
         ImageTTFText($image_handle, $fs, $angle, $myX, $myY, $dark, $fontName, $capChar);
     }
     $this->session->set_userdata('secure_image_hash_string', $secure_image_hash_string);
     header("Content-type: image/jpeg");
     imagejpeg($image_handle, "", 95);
     imagedestroy($image_handle);
     die;
 }
开发者ID:rongandat,项目名称:ookcart-project,代码行数:34,代码来源:secure_image.php

示例5: create

 function create($width = '120', $height = '40', $characters = '6')
 {
     ob_clean();
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.7;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 220, 220, 220);
     $text_color = imagecolorallocate($image, 10, 30, 80);
     $noise_color = imagecolorallocate($image, 150, 180, 220);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     $y -= 5;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $this->Controller->Session->write('security_code', $code);
 }
开发者ID:hqubaisi,项目名称:Fivedollarwork,代码行数:31,代码来源:captcha.php

示例6: index

 public function index()
 {
     header("content-type:image/gif");
     $this->load->library('session');
     $width = 60;
     $height = 30;
     $img = imagecreatetruecolor($width, $height);
     $white = imagecolorallocate($img, 255, 255, 255);
     $color = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
     $str = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
     $code = "";
     for ($i = 0; $i < 5; $i++) {
         $code .= $str[rand(0, strlen($str) - 1)];
     }
     $this->session->set_userdata(array('myCode' => strtolower($code)));
     imagefilledrectangle($img, 0, 0, 60, 30, $color);
     for ($i = 0; $i < 100; $i++) {
         imagesetpixel($img, rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
     }
     for ($i = 0; $i < 10; $i++) {
         imageline($img, rand(0, 60), rand(0, 30), rand(0, 60), rand(0, 30), imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255)));
     }
     imagestring($img, 5, 10, 5, $code, $white);
     return imagegif($img);
     //imagedestroy($img);
 }
开发者ID:804485808,项目名称:local_motors,代码行数:26,代码来源:imgcode.php

示例7: captcha

function captcha($width, $height, $code)
{
    $font = "./font/ChalkboardBold.ttf";
    $font_size = 17;
    $image = imagecreate($width, $height);
    $background_color = imagecolorallocate($image, 255, 255, 255);
    $text_color = imagecolorallocate($image, 20, 40, 100);
    $noise_color = imagecolorallocate($image, 100, 120, 180);
    for ($i = 0; $i < $width * $height / 3; $i++) {
        imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    for ($i = 0; $i < $width * $height / 150; $i++) {
        imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
    }
    $x = 3;
    $y = 20;
    imagettftext($image, $font_size, rand(-45, 45), $x, $y + rand() % 16, $text_color, $font, $code[0]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 23, $y + rand() % 16, $text_color, $font, $code[1]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 46, $y + rand() % 16, $text_color, $font, $code[2]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 69, $y + rand() % 16, $text_color, $font, $code[3]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 92, $y + rand() % 16, $text_color, $font, $code[4]);
    imagettftext($image, $font_size, rand(-45, 45), $x + 115, $y + rand() % 16, $text_color, $font, $code[5]);
    header('Content-Type: image/jpeg');
    imagejpeg($image);
    imagedestroy($image);
}
开发者ID:brenoinojosa,项目名称:ragnarok-public,代码行数:26,代码来源:img.php

示例8: generate

 public function generate()
 {
     foreach ($this->__shapes as $shape) {
         $type = array_shift($shape);
         $color = array_shift($shape);
         $color = $this->_owner->imagecolorallocate(!isset($color) || is_null($color) ? $this->__base_color : $color, $this->__base_alpha);
         switch ($type) {
             case self::LINE:
                 imageline($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::RECTANGLE:
                 imagerectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::FILLED_RECTANGLE:
                 imagefilledrectangle($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::ELLIPSE:
                 imageellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::FILLED_ELLIPSE:
                 imagefilledellipse($this->_owner->image, $shape[0], $shape[1], $shape[2], $shape[3], $color);
                 break;
             case self::SPIRAL:
                 $angle = $r = 0;
                 while ($r <= $shape[2]) {
                     imagearc($this->_owner->image, $shape[0], $shape[1], $r, $r, $angle - $shape[3], $angle, $color);
                     $angle += $shape[3];
                     $r++;
                 }
                 break;
         }
     }
     return true;
 }
开发者ID:npetrovski,项目名称:php5-image,代码行数:34,代码来源:Primitive.php

示例9: generate

 public static function generate($id, $width = 100, $height = 40)
 {
     $code = session::get("capcha_{$id}");
     // If not set then font size will be 75% size of height or width
     if (!self::$_font_size) {
         if ($width > $height) {
             self::$_font_size = $height * 0.75;
         } else {
             self::$_font_size = $width * 0.75;
         }
     }
     // Create image
     $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     // set the colors
     $background_color = imagecolorallocate($image, self::$_background_color[0], self::$_background_color[1], self::$_background_color[2]);
     $text_color = imagecolorallocate($image, self::$_font_color[0], self::$_font_color[1], self::$_font_color[2]);
     $noise_color = imagecolorallocate($image, self::$_noise_color[0], self::$_noise_color[1], self::$_noise_color[2]);
     // Generate random dots in background
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     // Generate random lines in background
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     // create textbox and add text
     $textbox = imagettfbbox(self::$_font_size, 0, self::$_font_file, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, self::$_font_size, 0, $x, $y, $text_color, self::$_font_file, $code) or die('Error in imagettftext function');
     // Output captcha image to browser
     header('Content-Type:image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:reang,项目名称:Dingo-Framework,代码行数:35,代码来源:capcha.php

示例10: makeGraphicalCaptcha

 /**
  * Makes a graphical captcha from the provided text string
  *
  * @param string $captcha_text string to make image captcha from
  * @return string $data_url a data url containing the obfuscated image
  */
 function makeGraphicalCaptcha($captcha_text)
 {
     $image = @imagecreatetruecolor(195, 35);
     // defines background color, random lines color and text color
     $bg_color = imagecolorallocate($image, mt_rand(0, 255), 255, 0);
     imagefill($image, 0, 0, $bg_color);
     $lines_color = imagecolorallocate($image, 0x99, 0xcc, 0x99);
     $text_color = imagecolorallocate($image, mt_rand(0, 255), 0, 255);
     // draws random lines
     for ($i = 0; $i < 4; $i++) {
         imageline($image, 0, rand(0, 35), 195, rand(0, 35), $lines_color);
     }
     $captcha_letter_array = str_split($captcha_text);
     foreach ($captcha_letter_array as $i => $captcha_letter) {
         imagesetthickness($image, 1);
         imagestring($image, 5, 5 + $i * 35, rand(2, 14), $captcha_letter, $text_color);
     }
     // creates image
     ob_start();
     imagejpeg($image);
     $image_data = ob_get_contents();
     ob_end_clean();
     $data_url = "data:image/jpeg;base64," . base64_encode($image_data);
     imagedestroy($image);
     return $data_url;
 }
开发者ID:yakar,项目名称:yioop,代码行数:32,代码来源:captcha_model.php

示例11: getVerify

 public function getVerify()
 {
     //创建画布
     $img = imagecreatetruecolor($this->config['width'], $this->config['height']);
     //设置背景颜色
     $bgColor = imagecolorallocate($img, 255, 255, 255);
     imagefill($img, 0, 0, $bgColor);
     $_x = ceil(($this->config['width'] - 20) / $this->config['lenght']);
     $code = '';
     //写入验证码
     for ($i = 0; $i < $this->config['lenght']; $i++) {
         $str = random();
         $code .= $str;
         $x = 10 + $i * $_x;
         $fontSize = mt_rand($this->config['fontsize'] - 10, $this->config['fontsize']);
         $fontH = imagefontheight($this->config['fontsize']);
         $y = mt_rand($fontH + 10, $this->config['height'] - 5);
         $fontColor = imagecolorallocate($img, mt_rand(0, 200), mt_rand(0, 200), mt_rand(0, 200));
         imagettftext($img, $fontSize, 0, $x, $y, $fontColor, $this->config['fontfile'], $str);
     }
     //增加干扰点
     for ($i = 0; $i < $this->config['point']; $i++) {
         $pointColor = imagecolorallocate($img, rand(150, 200), rand(150, 200), rand(100, 200));
         imagesetpixel($img, mt_rand(1, $this->config['width']), mt_rand(1, $this->config['height']), $pointColor);
     }
     //增加线干扰
     for ($i = 0; $i < $this->config['line']; $i++) {
         $linColor = imagecolorallocate($img, rand(0, 200), rand(0, 200), rand(0, 200));
         imageline($img, rand(0, $this->config['width']), rand(0, $this->config['height']), rand(0, $this->config['width']), rand(0, $this->config['height']), $linColor);
     }
     $_SESSION['Verify'] = md5(strtoupper($code));
     header('Content-type: image/png');
     imagepng($img);
     imagedestroy($img);
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:35,代码来源:Verify.class.php

示例12: setRandLine

 public function setRandLine()
 {
     for ($i = 0; $i < $this->LineNumber; $i++) {
         $LineColor = imagecolorallocate($this->ImgObj, rand(0, 255), rand(0, 255), rand(0, 255));
         imageline($this->ImgObj, rand(0, $this->Width), rand(0, $this->Height), rand(0, $this->Width), rand(0, $this->Height), $LineColor);
     }
 }
开发者ID:noikiy,项目名称:maiwoke,代码行数:7,代码来源:Captcha.php

示例13: __construct

 /**
  * Generate captcha
  *
  * @param  integer  $characters        Amount of characters to draw
  * @param  integer  $width
  * @param  integer  $height
  */
 public function __construct($characters = 10, $width = 140, $height = 24)
 {
     if (!file_exists($this->font)) {
         throw new RuntimeException("Font " . $this->font . " is missing. Can't proceed.");
     }
     $this->code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.7;
     $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $noise_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 44, 44, 44);
     $text_color2 = imagecolorallocate($image, 244, 1, 1);
     $line_color = imagecolorallocate($image, 244, 0, 0);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background of text */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $this->code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $this->code) or die('Error in imagettftext function');
     imagettftext($image, $font_size, 0, $x + 1, $y + 1, $text_color2, $this->font, substr($this->code, 0, 4));
     imagettftext($image, $font_size + 2, 0, $width - 50, 20, $line_color, $this->font, substr($this->code, -3));
     $this->image = $image;
 }
开发者ID:rszabo,项目名称:egalite,代码行数:38,代码来源:Text.php

示例14: generateCaptcha

 public function generateCaptcha()
 {
     //make image
     $im = imagecreatetruecolor($this->width, $this->height);
     //set background
     $bg_color = imagecolorallocate($im, mt_rand($this->bg_color_min, $this->bg_color_max), mt_rand($this->bg_color_min, $this->bg_color_max), mt_rand($this->bg_color_min, $this->bg_color_max));
     //padding
     imagefill($im, 0, 0, $bg_color);
     //add lines
     for ($i = 0; $i < $this->lines; $i++) {
         //set color
         $line_color = imagecolorallocate($im, mt_rand($this->line_color_min, $this->line_color_max), mt_rand($this->line_color_min, $this->line_color_max), mt_rand($this->line_color_min, $this->line_color_max));
         //draw line
         imageline($im, mt_rand(0, $this->width), mt_rand(0, $this->height), mt_rand(0, $this->width), mt_rand(0, $this->height), $line_color);
     }
     //add pixels
     for ($i = 0; $i < $this->pixels; $i++) {
         //set color
         $pixels_color = imagecolorallocate($im, mt_rand($this->pixels_color_min, $this->pixels_color_max), mt_rand($this->pixels_color_min, $this->pixels_color_max), mt_rand($this->pixels_color_min, $this->pixels_color_max));
         //draw pixels
         imagesetpixel($im, mt_rand(0, $this->width), mt_rand(0, $this->height), $pixels_color);
     }
     //get captcha string
     $captcha = $this->generateString();
     //set color of font
     $str_color = imagecolorallocate($im, mt_rand($this->font_color_min, $this->font_color_max), mt_rand($this->font_color_min, $this->font_color_max), mt_rand($this->font_color_min, $this->font_color_max));
     //put string to picture
     imagestring($im, $this->font, ceil($this->width / 2) - 20, ceil($this->height / 2) - 10, $captcha, $str_color);
     //save or output
     imagepng($im);
     //destroy res
     imagedestroy($im);
 }
开发者ID:billywl,项目名称:shop,代码行数:33,代码来源:Captcha.class.php

示例15: verifyImage

function verifyImage($type = 1, $length = 4, $pixel = 0, $line = 10, $sses_name = "verify")
{
    // 创建画布
    $width = 80;
    $height = 28;
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $balck = imagecolorallocate($image, 0, 0, 0);
    // 用填充矩形填充画布
    imagefilledrectangle($image, 1, 1, $width - 2, $height - 2, $white);
    $chars = buildRandomString($type, $length);
    $_SESSION[$sses_name] = $chars;
    for ($i = 0; $i < $length; $i++) {
        $size = mt_rand(14, 18);
        $angle = mt_rand(-15, 15);
        $x = 3 + $i * $size;
        $y = mt_rand(18, 22);
        $fontfile = "../fonts/" . "STFANGSO.TTF";
        $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
        $text = substr($chars, $i, 1);
        imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text);
    }
    // 加点
    for ($i = 0; $i < $pixel; $i++) {
        imagesetpixel($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), $balck);
    }
    // 加直线
    for ($i = 0; $i < $line; $i++) {
        $color = imagecolorallocate($image, mt_rand(50, 90), mt_rand(80, 200), mt_rand(90, 180));
        imageline($image, mt_rand(0, $width - 1), mt_rand(0, $height - 1), mt_rand(0, $width - 1), mt_rand(0, $height - 1), $color);
    }
    header("content-type:image/jpg");
    imagegif($image);
    imagedestroy($image);
}
开发者ID:hiden2,项目名称:shopImooc-1,代码行数:35,代码来源:image.func.php


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