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

PHP imageellipse函数代码示例

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

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



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

示例1: circle

 protected static function circle($params)
 {
     $borderColor = isset($params['borderColor']) ? $params['borderColor'] : null;
     $bgColor = isset($params['bgColor']) ? $params['bgColor'] : null;
     $bgColorFigure = isset($params['bgColorFigure']) ? $params['bgColorFigure'] : null;
     $indent = $params['diametr'] / 2 + 1;
     // Размер картинки с отступами
     $im = imagecreatetruecolor($params['diametr'], $params['diametr']);
     // Устанавливаем цвет границ
     if ($borderColor) {
         $border = imagecolorallocate($im, $borderColor[0], $borderColor[1], $borderColor[2]);
     }
     // Устанавливаем заливку поля
     if (empty($params['transparent'])) {
         $bg = imagecolorallocate($im, $bgColor[0], $bgColor[1], $bgColor[2]);
     } else {
         $bg = imagecolorallocatealpha($im, 0, 0, 0, 127);
     }
     // Устанавливаем заливку круга
     $bgCircle = imagecolorallocate($im, $bgColorFigure[0], $bgColorFigure[1], $bgColorFigure[2]);
     imagefill($im, 1, 1, $bg);
     imagesavealpha($im, TRUE);
     // Рисуем круг
     imagefilledellipse($im, $indent - 1, $indent - 1, $params['diametr'] - 1, $params['diametr'] - 1, $bgCircle);
     if ($borderColor) {
         imageellipse($im, $indent - 1, $indent - 1, $params['diametr'] - 1, $params['diametr'] - 1, $border);
     }
     // Выводим изображение
     imagepng($im);
 }
开发者ID:CozaNostra,项目名称:app,代码行数:30,代码来源:GraphicsEditor.php


示例2: smart_spam

function smart_spam($code)
{
    @putenv('GDFONTPATH=' . realpath('.'));
    $font = 'FONT.TTF';
    // antispam image height
    $height = 40;
    // antispam image width
    $width = 110;
    $font_size = $height * 0.6;
    $image = @imagecreate($width, $height);
    $background_color = @imagecolorallocate($image, 255, 255, 255);
    $noise_color = @imagecolorallocate($image, 20, 40, 100);
    /* add image noise */
    for ($i = 0; $i < $width * $height / 4; $i++) {
        @imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    /* render text */
    $text_color = @imagecolorallocate($image, 20, 40, 100);
    @imagettftext($image, $font_size, 0, 7, 29, $text_color, $font, $code) or die('Cannot render TTF text.');
    //output image to the browser *//*
    header('Content-Type: image/png');
    @imagepng($image) or die('imagepng error!');
    @imagedestroy($image);
    exit;
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:25,代码来源:captcha.php


示例3: ellipse

 public function ellipse(Point $center, $width, $height, $filled = FALSE, Color $color = NULL)
 {
     if (!$center->isInImage($this)) {
         throw new IllegalArgumentException();
     }
     $filled == TRUE ? imagefilledellipse($this->imageResource, $center->getX(), $center->getY(), $width, $height, $this->prepareColor($color)) : imageellipse($this->imageResource, $center->getX(), $center->getY(), $width, $height, $this->prepareColor($color));
 }
开发者ID:rendix2,项目名称:QW_MVS,代码行数:7,代码来源:Images.php


示例4: draw

 public function draw($dimension = 100)
 {
     $dimension = $this->reDim($dimension);
     $Center = $dimension / 2;
     $ScaleFactor = $dimension / max($this->Sizes);
     $image = imagecreatetruecolor($dimension, $dimension);
     imagefill($image, 0, 0, imagecolorallocate($image, 255, 255, 244));
     for ($i = 0; $i < count($this->Sizes); $i++) {
         $ArrowDiameter = ceil($dimension / 20);
     }
     foreach ($this->Sizes as $key => $value) {
         $diameter = $value * $ScaleFactor;
         //$ArrowDiameter=min($diameter,$ArrowDiameter);
         $color = imagecolorallocate($image, $this->Colors[$key][0], $this->Colors[$key][1], $this->Colors[$key][2]);
         $bordercolor = imagecolorallocate($image, $this->BorderColors[$key][0], $this->BorderColors[$key][1], $this->BorderColors[$key][2]);
         imagefilledellipse($image, $Center, $Center, $diameter, $diameter, $color);
         imageellipse($image, $Center, $Center, $diameter, $diameter, $bordercolor);
     }
     //$ArrowDiameter=max($dimension/25, $ArrowDiameter/2);
     $color = imagecolorallocate($image, 64, 255, 64);
     foreach ($this->ArrowPos as $pos) {
         if (preg_match("/^[\\-0-9]*,[\\-0-9]*\$/", $pos)) {
             list($x, $y) = explode(',', $pos);
             $x = $dimension / 2 + $x * $dimension / 2000;
             $y = $dimension / 2 + $y * $dimension / 2000;
             imagefilledellipse($image, $x, $y, $ArrowDiameter, $ArrowDiameter, $color);
             imageellipse($image, $x, $y, $ArrowDiameter, $ArrowDiameter, $bordercolor);
         }
     }
     header("Content-type: image/png");
     imagepng($image);
     imagedestroy($image);
 }
开发者ID:brian-nelson,项目名称:ianseo,代码行数:33,代码来源:Obj_Target.php


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


示例6: printImage

 function printImage()
 {
     // Définition du content-type
     header("Content-type: image/png");
     $grey = imagecolorallocate($this->image, 200, 196, 196);
     $white = imagecolorallocate($this->image, 255, 255, 255);
     $black = imagecolorallocate($this->image, 0, 0, 0);
     imagefilledrectangle($this->image, 0, 0, $this->size, 50, $white);
     $font = 'agenda__.ttf';
     // dessinons quelques eclipses ;)
     for ($t = 0; $t <= 20; $t++) {
         imageellipse($this->image, rand(0, $this->size), rand(0, 50), rand(0, 200), rand(0, 200), $grey);
     }
     // centrage du texte
     $maxWord = ($this->size - 30) / 27;
     $cur_left = strlen($this->text) == $maxWord ? 15 : 15 + ($maxWord - strlen($this->text)) * 27 / 2;
     for ($t = 0; isset($this->text[$t]); $t++) {
         $cur_incli = rand(-20, 20);
         // ombre
         imagettftext($this->image, 32, $cur_incli, $cur_left, 40, $black, $font, $this->text[$t]);
         // texte
         imagettftext($this->image, 32, $cur_incli, $cur_left - 1, 39, $this->colours[array_rand($this->colours)], $font, $this->text[$t]);
         $cur_left += 27;
     }
     imagepng($this->image);
     imagedestroy($this->image);
 }
开发者ID:BackupTheBerlios,项目名称:wikiplug,代码行数:27,代码来源:captcha.php


示例7: 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, 0, 0, 0);
     $noise_color = imagecolorallocate($image, 226, 82, 207);
     $noise_color1 = imagecolorallocate($image, 64, 179, 255);
     $noise_color2 = imagecolorallocate($image, 255, 204, 190);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 250; $i++) {
         imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color2);
     }
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imagedashedline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color1);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imagedashedline($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 */
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION['security_code'] = $code;
 }
开发者ID:Coding110,项目名称:cbvideo,代码行数:34,代码来源:captcha_simple.img.php


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


示例9: drawdot

function drawdot($coords, $tipo, $valor)
{
    global $im, $mapHTML, $inner_text, $linecolor;
    imageline($im, $coords[0], $coords[1], $coords[2], $coords[3], $linecolor[$tipo]);
    imageellipse($im, $coords[0], $coords[1], 3, 3, $linecolor);
    imagestring($im, 1, $coords[0] + 2, $coords[1] + 3, $valor, $inner_text);
}
开发者ID:secteofilandia,项目名称:ieducar,代码行数:7,代码来源:grafico_linhas.php


示例10: gerImage

 function gerImage()
 {
     # Calcular tamanho para caber texto
     $this->w = $this->numChars * $this->charx + 40;
     #5px de cada lado, 4px por char
     # Criar img
     $this->im = imagecreatetruecolor($this->w, $this->h);
     #desenhar borda e fundo
     imagefill($this->im, 0, 0, $this->getColor($this->colBorder));
     imagefilledrectangle($this->im, 1, 1, $this->w - 2, $this->h - 2, $this->getColor($this->colBG));
     #desenhar circulos
     for ($i = 1; $i <= $this->numCirculos; $i++) {
         $randomcolor = imagecolorallocate($this->im, rand(120, 255), rand(120, 255), rand(120, 255));
         imageellipse($this->im, rand(0, $this->w - 10), rand(0, $this->h - 3), rand(20, 60), rand(20, 60), $randomcolor);
     }
     #escrever texto
     $ident = 20;
     for ($i = 0; $i < $this->numChars; $i++) {
         $char = substr($this->texto, $i, 1);
         $font = rand(5, 5);
         $y = round(($this->h - 15) / 4);
         $col = $this->getColor($this->colTxt);
         if ($i % 4 == 0) {
             imagechar($this->im, $font, $ident, $y, $char, $col);
         } else {
             imagechar($this->im, $font, $ident, $y + rand(3, 18), $char, $col);
         }
         $ident = $ident + $this->charx;
     }
 }
开发者ID:sknlim,项目名称:classified-2,代码行数:30,代码来源:ImgVerification.php


示例11: generateImage

 /**
  * Private function for creating a random image.
  *
  * This function only works with the GD toolkit. ImageMagick is not supported.
  */
 protected function generateImage($extension = 'png', $min_resolution, $max_resolution)
 {
     if ($tmp_file = drupal_tempnam('temporary://', 'imagefield_')) {
         $destination = $tmp_file . '.' . $extension;
         file_unmanaged_move($tmp_file, $destination, FILE_CREATE_DIRECTORY);
         $min = explode('x', $min_resolution);
         $max = explode('x', $max_resolution);
         $width = rand((int) $min[0], (int) $max[0]);
         $height = rand((int) $min[1], (int) $max[1]);
         // Make an image split into 4 sections with random colors.
         $im = imagecreate($width, $height);
         for ($n = 0; $n < 4; $n++) {
             $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
             $x = $width / 2 * ($n % 2);
             $y = $height / 2 * (int) ($n >= 2);
             imagefilledrectangle($im, $x, $y, $x + $width / 2, $y + $height / 2, $color);
         }
         // Make a perfect circle in the image middle.
         $color = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         $smaller_dimension = min($width, $height);
         $smaller_dimension = $smaller_dimension % 2 ? $smaller_dimension : $smaller_dimension;
         imageellipse($im, $width / 2, $height / 2, $smaller_dimension, $smaller_dimension, $color);
         $save_function = 'image' . ($extension == 'jpg' ? 'jpeg' : $extension);
         $save_function($im, drupal_realpath($destination));
         return $destination;
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:32,代码来源:DevelGenerateFieldImage.php


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


示例13: store_map

function store_map($im, $data, $shape, $row, $col, $x, $y)
{
    static $color = NULL;
    if (!isset($color)) {
        $color = imagecolorallocate($im, 255, 0, 0);
    }
    imageellipse($im, $x, $y, 12, 12, $color);
}
开发者ID:myfarms,项目名称:PHPlot,代码行数:8,代码来源:imagemap_trace-pt.php


示例14: store_map

function store_map($im, $passthru, $shape, $row, $col, $xc, $yc, $diam)
{
    static $color = NULL;
    if (!isset($color)) {
        $color = imagecolorallocate($im, 255, 0, 0);
    }
    imageellipse($im, $xc, $yc, $diam, $diam, $color);
}
开发者ID:myfarms,项目名称:PHPlot,代码行数:8,代码来源:imagemap_trace-bu.php


示例15: applyToImage

 /**
  * Draw ellipse instance on given image
  *
  * @param  Image   $image
  * @param  integer $x
  * @param  integer $y
  * @return boolean
  */
 public function applyToImage(Image $image, $x = 0, $y = 0)
 {
     $background = new Color($this->background);
     imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imageellipse($image->getCore(), $x, $y, $this->width, $this->height, $border_color->getInt());
     }
     return true;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:19,代码来源:EllipseShape.php


示例16: drawdot

function drawdot($coords, $tipo, $valor, $im, $linecolor)
{
    $inner_text = $linecolor[$tipo];
    // imagecolorallocate ( $im, 255, 255, 255 );
    imageline($im, $coords[0], $coords[1], $coords[2], $coords[3], $linecolor[$tipo]);
    imageellipse($im, $coords[0], $coords[1], 3, 3, $linecolor);
    if ($valor == 0) {
        $valor = "";
    }
    imagestring($im, 3, $coords[0] + 8, $coords[1] - 10, $valor, $inner_text);
}
开发者ID:secteofilandia,项目名称:ieducar,代码行数:11,代码来源:grafico.php


示例17: drawDots

 public function drawDots($vImage, $vColor, $iPosX = 0, $iPosY = false, $iDotSize = 1)
 {
     if ($iPosY === false) {
         $iPosY = imagesy($vImage);
     }
     $vBorderColor = imagecolorallocate($vImage, 0, 0, 0);
     foreach ($this->aCoords as $x => $y) {
         imagefilledellipse($vImage, $iPosX + round($x), $iPosY - round($y), $iDotSize, $iDotSize, $vColor);
         imageellipse($vImage, $iPosX + round($x), $iPosY - round($y), $iDotSize, $iDotSize, $vBorderColor);
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:11,代码来源:Plot.php


示例18: generateImage

 public function generateImage()
 {
     $this->securityCode = $this->simpleRandString($this->codeLength);
     $img_path = dirname(__FILE__) . "/../../web/uploads/";
     if (!is_writable($img_path) && !is_dir($img_path)) {
         $error = "The image path {$img_path} does not appear to be writable or the folder does not exist. Please verify your settings";
         throw new Exception($error);
     }
     $this->img = imagecreatefromjpeg($img_path . $this->imageFile);
     $img_size = getimagesize($img_path . $this->imageFile);
     foreach ($this->fontColor as $fcolor) {
         $color[] = imagecolorallocate($this->img, hexdec(substr($fcolor, 1, 2)), hexdec(substr($fcolor, 3, 2)), hexdec(substr($fcolor, 5, 2)));
     }
     $line = imagecolorallocate($this->img, 255, 255, 255);
     $line2 = imagecolorallocate($this->img, 200, 200, 200);
     $fw = imagefontwidth($this->fontSize) + 3;
     $fh = imagefontheight($this->fontSize);
     // create a new string with a blank space between each letter so it looks better
     $newstr = "";
     for ($i = 0; $i < strlen($this->securityCode); $i++) {
         $newstr .= $this->securityCode[$i] . " ";
     }
     // remove the trailing blank
     $newstr = trim($newstr);
     // center the string
     $x = ($img_size[0] - strlen($newstr) * $fw) / 2;
     $font[0] = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
     $font[1] = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
     $font[2] = '/usr/share/fonts/truetype/msttcorefonts/arial.ttf';
     // create random lines over text
     for ($i = 0; $i < 3; $i++) {
         $s_x = rand(40, 180);
         $s_y = rand(5, 35);
         $e_x = rand($s_x - 50, $s_x + 50);
         $e_y = rand(5, 35);
         $c = rand(0, count($color) - 1);
         imageline($this->img, $s_x, $s_y, $e_x, $e_y, $color[$c]);
     }
     // random bg ellipses
     imageellipse($this->img, $s_x, $s_y, $e_x, $e_y, $line);
     imageellipse($this->img, $e_x, $e_y, $s_x, $s_y, $line2);
     // output each character at a random height and standard horizontal spacing
     for ($i = 0; $i < strlen($newstr); $i++) {
         $hz = mt_rand(10, $img_size[1] - $fh - 5);
         // randomize rotation
         $rotate = rand(-35, 35);
         // randomize font size
         $this->fontSize = rand(14, 18);
         // radomize color
         $c = rand(0, count($color) - 1);
         // imagechar( $this->img, $this->fontSize, $x + ($fw*$i), $hz, $newstr[$i], $color);
         imagettftext($this->img, $this->fontSize, $rotate, $x + $fw * $i, $hz + 12, $color[0], $font[$c], $newstr[$i]);
     }
 }
开发者ID:broschb,项目名称:cyclebrain,代码行数:54,代码来源:sfCaptcha.php


示例19: view_image

 function view_image($id = null)
 {
     if (is_numeric($id)) {
         $question = $this->Question->findById($id);
         $line_count = 0;
         // array of lines
         $question_text = array();
         // Other kinds of newlines causing problems.
         $question['Question']['question'] = str_replace(array("\r", "\r\n", "\n"), '\\n', $question['Question']['question']);
         $question_wrapped = wordwrap(strip_tags(QH_urldecode($question['Question']['question'])), $this->number_of_characters, '\\n', true);
         $question_text = array_merge($question_text, explode('\\n', $question_wrapped));
         $line_count += count($question_text);
         $answers = Set::combine($question['Answer'], '{n}.order', '{n}.answer');
         $answer_text = array();
         foreach ($answers as $answer) {
             $answer_wrapped = wordwrap(strip_tags($answer), $this->number_of_characters - 4, '\\n', true);
             $line_array = explode('\\n', $answer_wrapped);
             $answer_text[] = $line_array;
             $line_count += count($line_array);
         }
         $box_height = $this->padding * 2 + $this->line_height * $line_count;
         $box_width = $this->padding * 2 + $this->number_of_characters * $this->character_width;
         $image = imagecreatetruecolor($box_width, $box_height);
         $background = imagecolorallocate($image, 255, 255, 255);
         imagefill($image, 0, 0, $background);
         $black = imagecolorallocate($image, 0, 0, 0);
         imagerectangle($image, 0, 0, $box_width - 1, $box_height - 1, $black);
         $y = $this->padding + $this->character_height;
         foreach ($question_text as $line) {
             imagettftext($image, $this->font_size, 0, $this->padding, $y, $black, APP . 'Lib/unifont_5.1.20080907.ttf', html_entity_decode($line));
             // h_e_d for preventing &nbsp; in the image... sometimes. Not clear on that, but
             //   this fixed #206.
             $y += $this->line_height;
         }
         foreach ($answer_text as $order => $answer) {
             if ($order == $question['Question']['correct_answer']) {
                 imagefilledellipse($image, $this->character_width * 3, $y - $this->character_height / 2, 8, 8, $black);
             } else {
                 imageellipse($image, $this->character_width * 3, $y - $this->character_height / 2, 8, 8, $black);
             }
             foreach ($answer as $answer_line) {
                 $answer_line = '    ' . $answer_line;
                 imagettftext($image, $this->font_size, 0, $this->padding, $y, $black, APP . 'Lib/unifont_5.1.20080907.ttf', $answer_line);
                 $y += $this->line_height;
             }
         }
         $this->layout = 'image';
         header("Content-type: image/png");
         imagepng($image);
         imagedestroy($image);
         $this->autoRender = false;
     }
 }
开发者ID:nkuitse,项目名称:Guide-on-the-Side,代码行数:53,代码来源:QuestionsController.php


示例20: write_number

function write_number($x, $y, $n)
{
    global $im, $fg_color, $font_size, $font;
    if (!($box = imagettftext($im, $font_size, 0, $x, $y, $fg_color, $font, $n))) {
        die("Error drawing text");
    }
    $el_w = $box[2] - $box[0] + $font_size;
    $el_h = $box[1] - $box[7] + $font_size / 2;
    $el_x = ($box[0] + $box[2]) / 2;
    $el_y = ($box[1] + $box[7]) / 2;
    imageellipse($im, $el_x, $el_y, $el_w, $el_h, $fg_color);
    return array($el_x, $el_y, $el_w, $el_h);
}
开发者ID:spachev,项目名称:number-chart,代码行数:13,代码来源:number-chart.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP imagefill函数代码示例发布时间:2022-05-15
下一篇:
PHP imagedestroy函数代码示例发布时间: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