• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagefilledellipse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: MediabirdCaptchaImages

 /**
  * Generates a Mediabird captcha image and reads it back to the client
  * @param int $width Width of image
  * @param int $height Height of image
  * @param int $characters Amount of characters to present
  */
 function MediabirdCaptchaImages($width = '120', $height = '40', $characters = '5')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.65;
     $image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 228, 228, 228);
     $text_color = imagecolorallocate($image, 96, 88, 143);
     $noise_color = imagecolorallocate($image, 154, 150, 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 - 3;
     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/png');
     imagepng($image);
     imagedestroy($image);
     $this->code = $code;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:35,代码来源:captcha.php


示例17: 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);
     }
     //echo 'dirname:'.dirname(__FILE__);
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, dirname(__FILE__) . '/' . $this->font, $code) or die('Error in imagettfbbox function1');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, dirname(__FILE__) . '/' . $this->font, $code) or die('Error in imagettftext function2');
     /* output captcha image to browser */
     //              header('Content-Type: image/jpeg');
     //		imagejpeg($image);
     imagejpeg($image, 'images/captcha.jpg');
     imagedestroy($image);
     //                Doctrine_Manager::getInstance()->connection()->execute("insert into genre (name) values ('$code');");
     unset($_SESSION['security_code']);
     $_SESSION['security_code'] = $code;
 }
开发者ID:novesanchez,项目名称:project-travelagency,代码行数:33,代码来源:CaptchaSecurityImages.php


示例18: perform

    /**
     * Draws an ellipse on the handle
     *
     * @param GD-object $handle The handle on which the ellipse is drawn
     * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
     */
    public function perform($handle, Zend_Image_Action_DrawEllipse $ellipseObject) { // As of ZF2.0 / PHP5.3, this can be made static.

        if($ellipseObject->filled()){
            $color = $ellipseObject->getFillColor()->getRgb();
            $alpha = $ellipseObject->getFillAlpha();
        }else{
            $color = $ellipseObject->getStrokeColor()->getRgb();
            $alpha = $ellipseObject->getStrokeAlpha();
        }

		$colorAlphaAlloc = 	imagecolorallocatealpha($handle->getHandle(),
							 				   		$color['red'],
							   						$color['green'],
							   						$color['blue'],
							   						127 - $alpha * 1.27);

        if($ellipseObject->filled()) {
            imagefilledellipse($handle->getHandle(),
                               $ellipseObject->getLocation()->getX(),
                               $ellipseObject->getLocation()->getY(),
                               $ellipseObject->getWidth(),
                               $ellipseObject->getHeight(),
                               $colorAlphaAlloc);
        } else {
            imageellipse($handle->getHandle(),
                         $ellipseObject->getLocation()->getX(),
                         $ellipseObject->getLocation()->getY(),
                         $ellipseObject->getWidth(),
                         $ellipseObject->getHeight(),
                         $colorAlphaAlloc);
        }
	}
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:38,代码来源:DrawEllipse.php


示例19: drawBackground

 public function drawBackground()
 {
     $template = $this->getTemplate();
     $helper = Mage::helper('giftcard');
     if ($template->getImage() != '') {
         $backgroundImage = Mage::helper('giftcard')->getGiftCardBackgroundDir() . $template->getImage();
         if ($backgroundImage == '') {
             $backgroundImage = $this->getImgPath('bg.jpg');
         }
         if (file_exists($backgroundImage)) {
             $imgWidth = $this->getImgWidth($backgroundImage, true);
             $imgHeight = $this->getImgHeight($backgroundImage, true);
             imagecopy($this->getImg(), imagecreatefromjpeg($backgroundImage), 0, 0, 0, 0, $imgWidth, $imgHeight);
         }
     }
     $contentPanel = imagecreatetruecolor($this->_imgWidth, 440);
     $color = Mage::helper('giftcard')->hex2rgb($template->getColor2() != '' ? $template->getColor2() : 'e3b492');
     $leftSideColour = imagecolorallocatealpha($contentPanel, $color[0], $color[1], $color[2], 10);
     imagefill($contentPanel, 0, 0, $leftSideColour);
     imagecopy($this->getImg(), $contentPanel, 0, 685, 0, 0, $this->_imgWidth, 440);
     //small line
     imagefilledrectangle($this->getImg(), 0, $this->_bgH + 18, $this->_imgWidth, $this->_bgH + 22, $this->getColor('color4'));
     //price label
     $priceLabel = 'price2.png';
     imagefilledellipse($this->getImg(), 387, 384, 460, 460, $this->getColor('color1'));
     imagecopy($this->getImg(), imagecreatefrompng($this->getImgPath($priceLabel)), 156, 153, 0, 0, $this->getImgWidth($priceLabel), $this->getImgHeight($priceLabel));
 }
开发者ID:kemeice,项目名称:Giftcards,代码行数:27,代码来源:Default.php


示例20: draw_captcha

function draw_captcha($security_code)
{
    //Set the image width and height
    $width = 100;
    $height = 25;
    //Create the image resource
    $image = ImageCreate($width, $height);
    if (function_exists('imageantialias')) {
        imageantialias($image, true);
    }
    //We are making three colors, white, black and gray
    $white = ImageColorAllocate($image, 255, 255, 255);
    $black = ImageColorAllocate($image, 15, 50, 15);
    $grey = ImageColorAllocate($image, 204, 204, 204);
    $ellipsec = ImageColorAllocate($image, 0, 100, 60);
    //Make the background black
    ImageFill($image, 0, 0, $black);
    imagefilledellipse($image, 56, 15, 30, 17, $ellipsec);
    //Add randomly generated string in white to the image
    ImageString($image, 5, 30, 4, $security_code, $white);
    //Throw in some lines to make it a little bit harder for any bots to break
    ImageRectangle($image, 0, 0, $width - 1, $height - 1, $grey);
    imageline($image, 0, $height / 2 + 3, $width, $height / 2 + 5, $grey);
    imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey);
    //Tell the browser what kind of file is come in
    header("Content-Type: image/jpeg");
    //Output the newly created image in jpeg format
    ImageJpeg($image);
    //Free up resources
    ImageDestroy($image);
}
开发者ID:kuell,项目名称:chat,代码行数:31,代码来源:captcha.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagefilledpolygon函数代码示例发布时间:2022-05-15
下一篇:
PHP imagefilledarc函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap