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


PHP imagefilledellipse函数代码示例

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


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

示例1: _drawLine

 private function _drawLine($image, $x1, $y1, $x2, $y2)
 {
     $thick = $this->_thickness->getThickness();
     $color = $this->_getDrawColor($image);
     if ($thick == 1) {
         return imageline($image, $x1, $y1, $x2, $y2, $color);
     }
     if ($this->hasTransparency() && $this->_transparency->getTransparency() != ParamTransparency::$minAlpha) {
         $t = $thick / 2 - 0.5;
         if ($x1 == $x2 || $y1 == $y2) {
             return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color);
         }
         $k = ($y2 - $y1) / ($x2 - $x1);
         //y = kx + q
         $a = $t / sqrt(1 + pow($k, 2));
         $points = array(round($x1 - (1 + $k) * $a), round($y1 + (1 - $k) * $a), round($x1 - (1 - $k) * $a), round($y1 - (1 + $k) * $a), round($x2 + (1 + $k) * $a), round($y2 - (1 - $k) * $a), round($x2 + (1 - $k) * $a), round($y2 + (1 + $k) * $a));
         imagefilledpolygon($image, $points, 4, $color);
         imagepolygon($image, $points, 4, $color);
     } else {
         imagesetthickness($image, $thick);
         imageline($image, $x1, $y1, $x2, $y2, $color);
         imagesetthickness($image, 1);
         imagefilledellipse($image, $x1, $y1, $thick, $thick, $color);
         imagefilledellipse($image, $x2, $y2, $thick, $thick, $color);
         imageellipse($image, $x1, $y1, $thick, $thick, $color);
         imageellipse($image, $x2, $y2, $thick, $thick, $color);
     }
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:28,代码来源:Line.php

示例2: __construct

 public function __construct($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* 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;
     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);
     /* @var $CI My_Controller */
     $CI = get_instance();
     $CI->session->set_userdata('security_code', $code);
 }
开发者ID:elshafey,项目名称:ir,代码行数:31,代码来源:capatcha.php

示例3: index

 public function index()
 {
     $code = substr(sha1(mt_rand()), 17, 6);
     $this->session->set_userdata('captcha_code', $code);
     $width = '120';
     $height = '40';
     $font = APPPATH . 'modules/contact/assets/fonts/monofont.ttf';
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* 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, $font, $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, $font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:binaek89,项目名称:cms-canvas,代码行数:31,代码来源:captcha.php

示例4: showImage

 function showImage()
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $width = imagesx($image);
     $height = imagesy($image);
     $black = imagecolorallocate($image, 0, 0, 0);
     $white = imagecolorallocate($image, 255, 255, 255);
     $red = imagecolorallocatealpha($image, 255, 0, 0, 75);
     $green = imagecolorallocatealpha($image, 0, 255, 0, 75);
     $blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
     imagefilledrectangle($image, 0, 0, $width, $height, $white);
     $tam = ceil(rand(10, 30));
     imagefilledellipse($image, ceil(rand(5, 100)), ceil(rand(0, 30)), $tam, $tam, $red);
     $tam = ceil(rand(10, 30));
     imagefilledellipse($image, ceil(rand(5, 100)), ceil(rand(0, 30)), $tam, $tam, $green);
     $tam = ceil(rand(10, 30));
     imagefilledellipse($image, ceil(rand(5, 100)), ceil(rand(0, 30)), $tam, $tam, $blue);
     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);
     imagestring($image, 15, intval(($width - strlen($this->code) * 9) / 2), intval(($height - 15) / 2), $this->code, $black);
     header('Content-type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:luanmpereira,项目名称:default-store,代码行数:26,代码来源:captcha.php

示例5: __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

示例6: showimage

 /**
  *
  */
 public function showimage()
 {
     $image = imagecreateTruecolor($this->width, $this->height);
     $width = imagesx($image);
     $height = imagesy($image);
     $black = imagecolorallocate($image, 0, 0, 0);
     $white = imagecolorallocate($image, 255, 255, 255);
     $red = imagecolorallocatealpha($image, 255, 0, 0, 75);
     $green = imagecolorallocatealpha($image, 0, 255, 0, 75);
     $blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
     imagefilledrectangle($image, 0, 0, $width, $height, $white);
     for ($i = 0; $i < 50; $i++) {
         imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
         imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
         imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
     }
     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);
     imagettftext($image, 15, 0, intval(($width - strlen($this->code) * 10) / 2), intval($height / 2 + 7), $black, $this->font, $this->code);
     header('Content-type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:metekorkmaz,项目名称:ccfw,代码行数:28,代码来源:TP_captcha.php

示例7: __construct

 public function __construct($width = '120', $height = '40', $characters = '6')
 {
     $fontPath = getcwd() . '/' . $this->font;
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* 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, $fontPath, $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, $fontPath, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     $context = Context::getContext();
     //        $context->cookie->ssmartblogcaptcha = $code;
     $context->cookie->__set('ssmartblogcaptcha', $code);
     $context->cookie->write();
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     //$_SESSION['ssmartblogcaptcha'] = $code;
 }
开发者ID:johnulist,项目名称:smartblog,代码行数:34,代码来源:CaptchaSecurityImages.php

示例8: showImage

 function showImage()
 {
     $image = imagecreatetruecolor($this->height, $this->width);
     $width = imagesx($image);
     $height = imagesy($image);
     $black = imagecolorallocate($image, 0, 0, 0);
     $white = imagecolorallocate($image, 255, 255, 255);
     $red = imagecolorallocatealpha($image, 255, 0, 0, 75);
     $green = imagecolorallocatealpha($image, 0, 255, 0, 75);
     $blue = imagecolorallocatealpha($image, 0, 0, 255, 75);
     imagefilledrectangle($image, 0, 0, $width, $height, $white);
     imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
     imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $green);
     imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $blue);
     imageline($image, 108, 23, 40, 23, $black);
     $pixel_color = imagecolorallocate($image, 100, 100, 100);
     for ($i = 0; $i < 1000; $i++) {
         imagesetpixel($image, rand() % 200, rand() % 50, $pixel_color);
     }
     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);
     imagestring($image, 10, intval(($width - strlen($this->code) * 9) / 2), intval(($height - 15) / 2), $this->code, $black);
     header('Content-type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     exit;
 }
开发者ID:afshinnj,项目名称:abantecart-src,代码行数:29,代码来源:captcha.php

示例9: CaptchaSecurityImages

 /**
  * @param int $width
  * @param int $height
  * @param int $characters
  */
 public function CaptchaSecurityImages($width = 120, $height = 40, $characters = 6)
 {
     $code = $this->generateCode($characters);
     // Font size will be 75% of the image height
     $fontSize = $height * 0.45;
     $image = imagecreate($width, $height);
     // Set the colours
     $backgroundColor = imagecolorallocate($image, 255, 255, 255);
     $textColor = imagecolorallocate($image, 46, 118, 126);
     $noiseColor = imagecolorallocate($image, 118, 173, 201);
     // Generate random dots in background
     for ($i = 0; $i < $width * $height / 10; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noiseColor);
     }
     // Generate random lines in background
     for ($i = 0; $i < $width * $height / 310; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noiseColor);
     }
     // Create textbox and add text
     $textbox = imagettfbbox($fontSize, 0, $this->config['font'], $code);
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $fontSize, 0, $x, $y, $textColor, $this->config['font'], $code);
     // Output captcha image to browser
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION['security_code'] = $code;
 }
开发者ID:mixset,项目名称:captcha.class.php,代码行数:34,代码来源:Captcha.class.php

示例10: genterate_flag

function genterate_flag($hex)
{
    $r = hexdec(substr($hex, 0, 2));
    $g = hexdec(substr($hex, 2, 2));
    $b = hexdec(substr($hex, 4, 2));
    // create a true colour, transparent image
    // turn blending OFF and draw a background rectangle in our transparent colour
    $default_size = 30;
    $size = $_REQUEST["size"];
    if ($size == '') {
        $size = $default_size;
    }
    $iwidth = $size;
    $iheight = $size;
    $image = imagecreatetruecolor($iwidth, $iheight);
    //
    imagealphablending($image, false);
    $col = imagecolorallocatealpha($image, 255, 255, 255, 127);
    $newc = imagecolorallocate($image, $r, $g, $b);
    $black = imagecolorallocatealpha($image, 0, 0, 0, 50);
    imagefilledrectangle($image, 0, 0, $iwidth, $iheight, $col);
    //imagefilledrectangle($image,10,10,($iwidth -10) ,($iheight-10),$newc);
    $values = array(0, $size / 10, 0, $size / 2, $size / 2, $size, $size, $size / 2, $size / 2, 0, $size / 10, 0);
    imagefilledpolygon($image, $values, 6, $newc);
    //imagefilledellipse($image, $size / 5, $size / 5 , $size / 8 , $size / 8, $black);
    imagefilledellipse($image, $size / 5, $size / 5, $size / 6, $size / 6, $col);
    //imagefilledpolygon($image , $values , 4 , $col );
    // imagealphablending($image,true);
    // ^^ Alpha blanding is back on.
    // insert image manipulation stuff in here
    // output the results...
    imagealphablending($image, true);
    // imagesavealpha($image,true);
    return $image;
}
开发者ID:name256,项目名称:crm42,代码行数:35,代码来源:image.flag.php

示例11: CaptchaSecurityImages

 function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.75;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* 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;
     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');
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Fri, 19 Jan 1994 05:00:00 GMT');
     header('Pragma: no-cache');
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION["gblSecurityCode"] = $code;
 }
开发者ID:rusoftware,项目名称:GrupoNorte,代码行数:32,代码来源:CaptchaSecurityImages.php

示例12: create_image

 function create_image()
 {
     // Seed string
     $this->generate_string();
     $this->im = imagecreatetruecolor($this->height, $this->width);
     // Create image
     // Get width and height
     $img_width = imagesx($this->im);
     $img_height = imagesy($this->im);
     // Define some common colors
     $black = imagecolorallocate($this->im, 0, 0, 0);
     $white = imagecolorallocate($this->im, 255, 255, 255);
     $red = imagecolorallocatealpha($this->im, 255, 0, 0, 75);
     $green = imagecolorallocatealpha($this->im, 0, 255, 0, 75);
     $blue = imagecolorallocatealpha($this->im, 0, 0, 255, 75);
     $yellow = imagecolorallocatealpha($this->im, 255, 255, 0, 75);
     $pink = imagecolorallocatealpha($this->im, 102, 102, 153, 75);
     // Background
     imagefilledrectangle($this->im, 0, 0, $img_width, $img_height, $white);
     // Ellipses (helps prevent optical character recognition)
     imagefilledellipse($this->im, ceil(rand(5, $img_width - 5)), ceil(rand(0, $img_height)), 40, 40, $red);
     imagefilledellipse($this->im, ceil(rand(5, $img_width - 5)), ceil(rand(0, $img_height)), 40, 40, $green);
     imagefilledellipse($this->im, ceil(rand(5, $img_width - 5)), ceil(rand(0, $img_height)), 40, 40, $blue);
     imagefilledellipse($this->im, ceil(rand(5, $img_width - 5)), ceil(rand(0, $img_height)), 40, 40, $yellow);
     imagefilledellipse($this->im, ceil(rand(5, $img_width - 5)), ceil(rand(0, $img_height)), 40, 40, $pink);
     // Borders
     //imagefilledrectangle($this->im, 0, 0, $img_width, 0, $black);
     //imagefilledrectangle($this->im, $img_width - 1, 0, $img_width - 1, $img_height - 1, $black);
     //imagefilledrectangle($this->im, 0, 0, 0, $img_height - 1, $black);
     //imagefilledrectangle($this->im, 0, $img_height - 1, $img_width, $img_height - 1, $black);
     imagestring($this->im, 6, intval(($img_width - strlen($this->string) * 9) / 2), intval(($img_height - 15) / 2), $this->string, $black);
     // Write string to photo
 }
开发者ID:skymak2050,项目名称:Schol2,代码行数:33,代码来源:random_image.php

示例13: applyFilter

 /**
  * (non-PHPdoc)
  * @see \imagemanipulation\filter\IImageFilter::applyFilter()
  */
 public function applyFilter(ImageResource $resource)
 {
     if ($this->radius === 0) {
         return;
     }
     $source_image = $resource->getResource();
     $source_width = $resource->getX();
     $source_height = $resource->getY();
     $corner_image = imagecreatetruecolor($this->radius, $this->radius);
     $clear_colour = imagecolorallocate($corner_image, 0, 0, 0);
     imagecolortransparent($corner_image, $clear_colour);
     $solid_colour = imagecolorallocate($corner_image, $this->color->getRed(), $this->color->getGreen(), $this->color->getBlue());
     imagefill($corner_image, 0, 0, $solid_colour);
     imagefilledellipse($corner_image, $this->radius, $this->radius, $this->radius * 2, $this->radius * 2, $clear_colour);
     /*
      * render the top-left, bottom-left, bottom-right, top-right corners by rotating and copying the mask
      */
     imagecopymerge($source_image, $corner_image, 0, 0, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, 0, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, $source_width - $this->radius, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, $source_width - $this->radius, 0, 0, 0, $this->radius, $this->radius, 100);
 }
开发者ID:dreamsxin,项目名称:imagemanipulation,代码行数:29,代码来源:ImageFilterRoundedCorners.php

示例14: create

 function create($width = '120', $height = '40', $characters = '6')
 {
     if ($this->font == null) {
         $this->font = App::pluginPath($this->Controller->plugin) . DS . 'webroot' . DS . 'monofont.ttf';
     }
     $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;
     $slope = rand(3, 8);
     $slope = rand(0, 1) == 1 ? $slope : -$slope;
     imagettftext($image, $font_size, $slope, $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:rchavik,项目名称:simple_captcha,代码行数:35,代码来源:captcha.php

示例15: creatImage

 public function creatImage()
 {
     $md5_hash = md5(uniqid());
     $security_code = substr($md5_hash, 15, 5);
     $this->CI->session->set_flashdata('security_code', $security_code);
     $width = 80;
     $height = 22;
     $font_size = $height * 0.75;
     $font = "monofont.ttf";
     $image = imagecreate($width, $height);
     $white = imagecolorallocate($image, 50, 0, 60);
     $black = imagecolorallocate($image, 140, 140, 140);
     $grey = imagecolorallocate($image, 200, 150, 150);
     imagefill($image, 0, 0, $black);
     $i = 0;
     for (; $i < $width * $height / 3; ++$i) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $grey);
     }
     $i = 0;
     for (; $i < $width * $height / 150; ++$i) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $grey);
     }
     if (!imagestring($image, $font_size, 15, 2, $security_code, 10)) {
         exit("Error in imagestring function");
     }
     header("Content-Type: image/jpeg");
     imagejpeg($image);
     imagedestroy($image);
 }
开发者ID:4johndoe,项目名称:ShopPC-CodeI,代码行数:29,代码来源:captcha_.php


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