コード例 #1
0
ファイル: libgraph.php プロジェクト: pl0o0f/nedi-puppet
 function drawGrid()
 {
     $this->x0 = -$x1;
     $this->y0 = -$y1;
     $this->x1 = $x1;
     $this->y1 = $y1;
     $this->posX0 = $width / 2;
     $this->posY0 = $height / 2;
     $this->scale = (double) ($width - 20) / ($this->x1 - $this->x0);
     imageLine($this->img, $this->posX0 + $this->x0 * $this->scale - 2, $this->posY0, $this->posX0 + $this->x1 * $this->scale + 2, $this->posY0, $this->blk);
     imageLine($this->img, $this->posX0, $this->posY0 - $this->y0 * $this->scale + 2, $this->posX0, $this->posY0 - $this->y1 * $this->scale - 2, $this->blk);
     imagesetstyle($this->img, array($this->gry, $this->wte, $this->wte, $this->wte, $this->wte));
     for ($x = 1; $x <= $this->x1; $x += 1) {
         imageline($this->img, $this->posX0 + $x * $this->scale, 0, $this->posX0 + $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
         imageline($this->img, $this->posX0 - $x * $this->scale, 0, $this->posX0 - $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
         imageLine($this->img, $this->posX0 + $x * $this->scale, $this->posY0 - 3, $this->posX0 + $x * $this->scale, $this->posY0 + 3, $this->blk);
         imageLine($this->img, $this->posX0 - $x * $this->scale, $this->posY0 - 3, $this->posX0 - $x * $this->scale, $this->posY0 + 3, $this->blk);
         imagestring($this->img, 2, $this->posX0 + $x * $this->scale, $this->posY0 + 4, $x, $this->blu);
         imagestring($this->img, 2, $this->posX0 - $x * $this->scale, $this->posY0 + 4, "-{$x}", $this->blu);
     }
     for ($y = 1; $y <= $this->y1; $y += 1) {
         imageline($this->img, 0, $this->posY0 + $y * $this->scale, $this->posX0 * 2, $this->posY0 + $y * $this->scale, IMG_COLOR_STYLED);
         imageline($this->img, 0, $this->posY0 - $y * $this->scale, $this->posX0 * 2, $this->posY0 - $y * $this->scale, IMG_COLOR_STYLED);
         imageLine($this->img, $this->posX0 - 3, $this->posY0 - $y * $this->scale, $this->posX0 + 3, $this->posY0 - $y * $this->scale, $this->blk);
         imageLine($this->img, $this->posX0 - 3, $this->posY0 + $y * $this->scale, $this->posX0 + 3, $this->posY0 + $y * $this->scale, $this->blk);
         imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 - $y * $this->scale, $y, $this->blu);
         imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 + $y * $this->scale, "-{$y}", $this->blu);
     }
 }
コード例 #2
0
ファイル: Render.class.php プロジェクト: eXcomm/3D-PHP-Class
 private function _render_edge($mesh)
 {
     $style = array();
     foreach ($mesh as $value) {
         $style = range($value->getA()->getColor()->toPngColor($this->_img), $value->getB()->getColor()->toPngColor($this->_img), 0xf1);
         imagesetstyle($this->_img, $style);
         imageline($this->_img, -$value->getA()->getX() + $this->_width / 2, -$value->getA()->getY() + $this->_height / 2, -$value->getB()->getX() + $this->_width / 2, -$value->getB()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
         imagesetstyle($this->_img, $style);
         imageline($this->_img, -$value->getA()->getX() + $this->_width / 2, -$value->getA()->getY() + $this->_height / 2, -$value->getC()->getX() + $this->_width / 2, -$value->getC()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
         imagesetstyle($this->_img, $style);
         imageline($this->_img, -$value->getC()->getX() + $this->_width / 2, -$value->getC()->getY() + $this->_height / 2, -$value->getB()->getX() + $this->_width / 2, -$value->getB()->getY() + $this->_height / 2, IMG_COLOR_STYLED);
     }
 }
コード例 #3
0
    /**
     * Draws a polygon on the handle
     *
     * @param GD-object $handle The handle on which the polygon is drawn
     * @param Zend_Image_Action_DrawPolygon $polygonObject The object that with all info
     */
    public function perform(Zend_Image_Adapter_Gd $adapter, Zend_Image_Action_DrawPolygon $polygonObject) { // As of ZF2.0 / PHP5.3, this can be made static.
        $handle = $adapter->getHandle();
    
        $points = $this->_parsePoints($polygonObject->getPoints());
        
        if(($pattern = $polygonObject->getStrokeDashPattern())!== null) {
            $color = imagecolorallocate($handle, 0, 255, 0);
            $array = array();
            foreach($pattern as $amountOfPixels) {
                $array = array_merge($array, array_fill(0, $amountOfPixels, $color));
                $array = array_merge($array, array_fill(0, $polygonObject->getStrokeDashOffset(), IMG_COLOR_TRANSPARENT));
            }
            
            if(count($array) > 0) {
                imagesetstyle($handle, $array);
            }
        }
        
        
        
        if($polygonObject->isFilled()) {
            //@TODO: extract this to Zend_Image_Adapter_Gd_Action_ActionAbstract ?
            $color = $polygonObject->getFillColor()->getRgb();
            $colorRes = imagecolorallocatealpha($handle,
                                               $color['red'],
                                               $color['green'],
                                               $color['blue'],
                                               $polygonObject->getFillAlpha());
            
            imagefilledpolygon($handle, $points, count($points)/2, $colorRes);
        }
        
        $points = $polygonObject->getPoints();
        $start = current($points);;
        $line = new Zend_Image_Action_DrawLine();
        while(current($points)!==false) {
            $from = current($points);
            $to = next($points);
            if($to===false) {
                if(!$polygonObject->isClosed()) {
                    break;
                } else {
                    $to = $start;
                }
            }

            $line->from($from);
            $line->to($to);
            $line->perform($adapter);
        }
    }
コード例 #4
0
ファイル: CaptchaSecurityImages.php プロジェクト: qcww/yh_cms
 function CaptchaImages($code, $width = 145, $height = 35)
 {
     /* select the type of font, must be used in directoy in which script is being called into */
     $this->font = dirname(__FILE__) . '/CALIBRI.TTF';
     $font_size = $height * 0.6;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $bgR = mt_rand(0, 255);
     $bgG = mt_rand(0, 255);
     $bgB = mt_rand(0, 255);
     $background_color = imagecolorallocate($image, $bgR, $bgG, $bgB);
     $noise_color = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     $text_color = imagecolorallocate($image, abs(255 - $bgR), abs(255 - $bgG), abs(255 - $bgB));
     /* 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);
     }
     /* set random colors */
     $w = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     $r = imagecolorallocate($image, abs(100 - $bgR), abs(100 - $bgG), abs(100 - $bgB));
     /* Draw a dashed line, 5 red pixels, 5 white pixels */
     $style = array($r, $r, $r, $r, $r, $w, $w, $w, $w, $w);
     imagesetstyle($image, $style);
     imageline($image, 0, 0, $width, $height, IMG_COLOR_STYLED);
     imageline($image, $width, 0, 0, $height, IMG_COLOR_STYLED);
     /* create random polygon points */
     $values = array(mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $height), mt_rand(0, $width));
     /* create Random Colors then set it to $clr */
     $r = abs(100 - mt_rand(0, 255));
     $g = abs(100 - mt_rand(0, 255));
     $b = abs(100 - mt_rand(0, 255));
     $clr = imagecolorallocate($image, $r, $g, $b);
     /* create filled polygon with random points */
     imagefilledpolygon($image, $values, 6, $clr);
     $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');
     /* pretty it */
     imageantialias($image, 100);
     imagealphablending($image, 1);
     imagelayereffect($image, IMG_EFFECT_OVERLAY);
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
コード例 #5
0
ファイル: captcha.php プロジェクト: em-z/Docs
function getCode($num,$w,$h) { 
    $code = ""; 
	$w = 80;
	$h = 30;
	$num = 5;
    for ($i = 0; $i < $num; $i++) { 
        $code .= rand(0, 9); 
    } 
    //4位验证码也可以用rand(1000,9999)直接生成 
    //将生成的验证码写入session,备验证时用 
    $_SESSION["helloweba_num"] = $code; 
    //创建图片,定义颜色值 
    header("Content-type: image/PNG"); 
    $im = imagecreate($w, $h); 
    $nums = imagecolorallocate($im, 0, 255, 144); 
    $bg = imagecolorallocate($im, 0, 100, 200); 
    $bgcolor = imagecolorallocate($im, 255, 255, 255); 
    //填充背景 
    imagefill($im, 0, 0, $bg); 
 
    //画边框 
    imagerectangle($im, 0, 0, $w-1, $h-1, $nums); 
 
    //随机绘制两条虚线,起干扰作用 
    $style = array ($nums,$nums,$nums,$nums,$nums, 
        $bg,$bg,$bg,$bg,$bg 
    ); 
    imagesetstyle($im, $style); 
    $y1 = rand(0, $h); 
    $y2 = rand(0, $h); 
    $y3 = rand(0, $h); 
    $y4 = rand(0, $h); 
    imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED); 
    imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED); 
 
    //在画布上随机生成大量黑点,起干扰作用; 
    for ($i = 0; $i < 80; $i++) { 
        imagesetpixel($im, rand(0, $w), rand(0, $h), $nums); 
    } 
    //将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成 
    $strx = rand(0, 35); //左右
    for ($i = 0; $i < $num; $i++) { 
        $strpos = rand(1, 10); 
        imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $nums); 
        $strx += rand(8, 10); 
    } 
    imagepng($im);//输出图片 
    imagedestroy($im);//释放图片所占内存 
} 
コード例 #6
0
ファイル: MateController.php プロジェクト: FRED5DON/MemoServo
 public static function getCode($code_key = "code_key", $num = 5, $w = 80, $h = 36)
 {
     $code = "";
     for ($i = 0; $i < $num; $i++) {
         $code .= rand(0, 9);
     }
     //4位验证码也可以用rand(1000,9999)直接生成
     //将生成的验证码写入session,备验证时用
     $_SESSION[$code_key] = $code;
     //创建图片,定义颜色值
     header("Content-type:image/PNG");
     $im = imagecreate($w, $h);
     $black = imagecolorallocate($im, 0, 0, 0);
     $gray = imagecolorallocate($im, 200, 200, 200);
     $bgcolor = imagecolorallocate($im, 255, 255, 255);
     //填充背景
     imagefill($im, 0, 0, $gray);
     //画边框
     imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
     //随机绘制两条虚线,起干扰作用
     $style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
     imagesetstyle($im, $style);
     $y1 = rand(0, $h);
     $y2 = rand(0, $h);
     $y3 = rand(0, $h);
     $y4 = rand(0, $h);
     imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
     imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
     //在画布上随机生成大量黑点,起干扰作用;
     for ($i = 0; $i < 80; $i++) {
         imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
     }
     //将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
     $strx = rand(3, 8);
     for ($i = 0; $i < $num; $i++) {
         $strpos = rand(1, 6);
         imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
         $strx += rand(8, 12);
     }
     imagepng($im);
     //输出图片
     imagedestroy($im);
     //释放图片所占内存
 }
コード例 #7
0
ファイル: code.php プロジェクト: shenerguang/chatRoom_php
function getCode($num, $w, $h)
{
    $code = "";
    for ($i = 0; $i < $num; $i++) {
        $code .= rand(0, 9);
    }
    $_SESSION["code_num"] = $code;
    header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, 0, 0, 0);
    $gray = imagecolorallocate($im, 200, 200, 200);
    $bgcolor = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $gray);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
    //随机绘制两条虚线,起干扰作用
    $style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
    imagesetstyle($im, $style);
    $y1 = rand(0, $h);
    $y2 = rand(0, $h);
    $y3 = rand(0, $h);
    $y4 = rand(0, $h);
    imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
    imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
    //在画布上随机生成大量黑点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(3, 8);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += rand(8, 12);
    }
    imagepng($im);
    //输出图片
    imagedestroy($im);
    //释放图片所占内存
}
コード例 #8
0
ファイル: Yz.php プロジェクト: miguelmeca/wscat
 public function initialize()
 {
     $CI =& get_instance();
     $num = "";
     for ($i = 0; $i < 4; $i++) {
         $num .= rand(0, 9);
     }
     //4位验证码也可以用rand(1000,9999)直接生成
     //将生成的验证码写入session,备验证页面使用
     $CI->session->set_userdata('Checknum', $num);
     //创建图片,定义颜色值
     Header("Content-type: image/PNG");
     srand((double) microtime() * 1000000);
     $im = imagecreate(60, 20);
     $black = ImageColorAllocate($im, 0, 0, 0);
     $gray = ImageColorAllocate($im, 200, 200, 200);
     imagefill($im, 0, 0, $gray);
     //随机绘制两条虚线,起干扰作用
     $style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
     imagesetstyle($im, $style);
     $y1 = rand(0, 20);
     $y2 = rand(0, 20);
     $y3 = rand(0, 20);
     $y4 = rand(0, 20);
     imageline($im, 0, $y1, 60, $y3, IMG_COLOR_STYLED);
     imageline($im, 0, $y2, 60, $y4, IMG_COLOR_STYLED);
     //在画布上随机生成大量黑点,起干扰作用;
     for ($i = 0; $i < 80; $i++) {
         imagesetpixel($im, rand(0, 60), rand(0, 20), $black);
     }
     //将四个数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
     $strx = rand(3, 8);
     for ($i = 0; $i < 4; $i++) {
         $strpos = rand(1, 6);
         imagestring($im, 5, $strx, $strpos, substr($num, $i, 1), $black);
         $strx += rand(8, 12);
     }
     ImagePNG($im);
     ImageDestroy($im);
 }
コード例 #9
0
ファイル: graph.php プロジェクト: BackupTheBerlios/nedi-svn
 function drawAxes()
 {
     imagesetstyle($this->img, array($this->gry, $this->wte, $this->wte, $this->wte, $this->wte));
     imageLine($this->img, $this->posX0 + $this->x0 * $this->scale - 2, $this->posY0, $this->posX0 + $this->x1 * $this->scale + 2, $this->posY0, $this->blk);
     imageLine($this->img, $this->posX0, $this->posY0 - $this->y0 * $this->scale + 2, $this->posX0, $this->posY0 - $this->y1 * $this->scale - 2, $this->blk);
     for ($x = 1; $x <= $this->x1; $x += 1) {
         imageline($this->img, $this->posX0 + $x * $this->scale, 0, $this->posX0 + $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
         imageline($this->img, $this->posX0 - $x * $this->scale, 0, $this->posX0 - $x * $this->scale, $this->posY0 * 2, IMG_COLOR_STYLED);
         imageLine($this->img, $this->posX0 + $x * $this->scale, $this->posY0 - 3, $this->posX0 + $x * $this->scale, $this->posY0 + 3, $this->blk);
         imageLine($this->img, $this->posX0 - $x * $this->scale, $this->posY0 - 3, $this->posX0 - $x * $this->scale, $this->posY0 + 3, $this->blk);
         imagestring($this->img, 2, $this->posX0 + $x * $this->scale, $this->posY0 + 4, $x, $this->blu);
         imagestring($this->img, 2, $this->posX0 - $x * $this->scale, $this->posY0 + 4, "-{$x}", $this->blu);
     }
     for ($y = 1; $y <= $this->y1; $y += 1) {
         imageline($this->img, 0, $this->posY0 + $y * $this->scale, $this->posX0 * 2, $this->posY0 + $y * $this->scale, IMG_COLOR_STYLED);
         imageline($this->img, 0, $this->posY0 - $y * $this->scale, $this->posX0 * 2, $this->posY0 - $y * $this->scale, IMG_COLOR_STYLED);
         imageLine($this->img, $this->posX0 - 3, $this->posY0 - $y * $this->scale, $this->posX0 + 3, $this->posY0 - $y * $this->scale, $this->blk);
         imageLine($this->img, $this->posX0 - 3, $this->posY0 + $y * $this->scale, $this->posX0 + 3, $this->posY0 + $y * $this->scale, $this->blk);
         imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 - $y * $this->scale, $y, $this->blu);
         imagestring($this->img, 2, $this->posX0 + 4, $this->posY0 + $y * $this->scale, "-{$y}", $this->blu);
     }
 }
コード例 #10
0
 protected function drawElement(&$data, $from, $to, $minX, $maxX, $minY, $maxY, $drawtype, $max_color, $avg_color, $min_color, $minmax_color, $calc_fnc, $axisside)
 {
     if (!isset($data['max'][$from]) || !isset($data['max'][$to])) {
         return;
     }
     $oxy = $this->oxy[$axisside];
     $zero = $this->zero[$axisside];
     $unit2px = $this->unit2px[$axisside];
     $shift_min_from = $shift_min_to = 0;
     $shift_max_from = $shift_max_to = 0;
     $shift_avg_from = $shift_avg_to = 0;
     if (isset($data['shift_min'][$from])) {
         $shift_min_from = $data['shift_min'][$from];
     }
     if (isset($data['shift_min'][$to])) {
         $shift_min_to = $data['shift_min'][$to];
     }
     if (isset($data['shift_max'][$from])) {
         $shift_max_from = $data['shift_max'][$from];
     }
     if (isset($data['shift_max'][$to])) {
         $shift_max_to = $data['shift_max'][$to];
     }
     if (isset($data['shift_avg'][$from])) {
         $shift_avg_from = $data['shift_avg'][$from];
     }
     if (isset($data['shift_avg'][$to])) {
         $shift_avg_to = $data['shift_avg'][$to];
     }
     /**/
     $min_from = $data['min'][$from] + $shift_min_from;
     $min_to = $data['min'][$to] + $shift_min_to;
     $max_from = $data['max'][$from] + $shift_max_from;
     $max_to = $data['max'][$to] + $shift_max_to;
     $avg_from = $data['avg'][$from] + $shift_avg_from;
     $avg_to = $data['avg'][$to] + $shift_avg_to;
     $x1 = $from + $this->shiftXleft - 1;
     $x2 = $to + $this->shiftXleft;
     $y1min = $zero - ($min_from - $oxy) / $unit2px;
     $y2min = $zero - ($min_to - $oxy) / $unit2px;
     $y1max = $zero - ($max_from - $oxy) / $unit2px;
     $y2max = $zero - ($max_to - $oxy) / $unit2px;
     $y1avg = $zero - ($avg_from - $oxy) / $unit2px;
     $y2avg = $zero - ($avg_to - $oxy) / $unit2px;
     //*/
     switch ($calc_fnc) {
         case CALC_FNC_MAX:
             $y1 = $y1max;
             $y2 = $y2max;
             $shift_from = $shift_max_from;
             $shift_to = $shift_max_to;
             break;
         case CALC_FNC_MIN:
             $y1 = $y1min;
             $y2 = $y2min;
             $shift_from = $shift_min_from;
             $shift_to = $shift_min_to;
             break;
         case CALC_FNC_ALL:
             // MAX
             $y1x = $y1max > $this->sizeY + $this->shiftY || $y1max < $this->shiftY;
             $y2x = $y2max > $this->sizeY + $this->shiftY || $y2max < $this->shiftY;
             if ($y1x) {
                 $y1max = $y1max > $this->sizeY + $this->shiftY ? $this->sizeY + $this->shiftY : $this->shiftY;
             }
             if ($y2x) {
                 $y2max = $y2max > $this->sizeY + $this->shiftY ? $this->sizeY + $this->shiftY : $this->shiftY;
             }
             //--
             // MIN
             $y1n = $y1min > $this->sizeY + $this->shiftY || $y1min < $this->shiftY;
             $y2n = $y2min > $this->sizeY + $this->shiftY || $y2min < $this->shiftY;
             if ($y1n) {
                 $y1min = $y1min > $this->sizeY + $this->shiftY ? $this->sizeY + $this->shiftY : $this->shiftY;
             }
             if ($y2n) {
                 $y2min = $y2min > $this->sizeY + $this->shiftY ? $this->sizeY + $this->shiftY : $this->shiftY;
             }
             //--
             $a[0] = $x1;
             $a[1] = $y1max;
             $a[2] = $x1;
             $a[3] = $y1min;
             $a[4] = $x2;
             $a[5] = $y2min;
             $a[6] = $x2;
             $a[7] = $y2max;
             // don't use break, avg must be drawed in this statement
         // don't use break, avg must be drawed in this statement
         case CALC_FNC_AVG:
             // don't use break, avg must be drawed in this statement
         // don't use break, avg must be drawed in this statement
         default:
             $y1 = $y1avg;
             $y2 = $y2avg;
             $shift_from = $shift_avg_from;
             $shift_to = $shift_avg_to;
     }
     $shift_from -= $shift_from != 0 ? $oxy : 0;
     $shift_to -= $shift_to != 0 ? $oxy : 0;
     $y1_shift = $zero - $shift_from / $unit2px;
     $y2_shift = $zero - $shift_to / $unit2px;
     //*/
     if (!$this->limitToBounds($y1, $y2, $this->shiftY, $this->sizeY, $drawtype)) {
         return true;
     }
     if (!$this->limitToBounds($y1_shift, $y2_shift, $this->shiftY, $this->sizeY, $drawtype)) {
         return true;
     }
     // draw main line
     switch ($drawtype) {
         case GRAPH_ITEM_DRAWTYPE_BOLD_LINE:
             if ($calc_fnc == CALC_FNC_ALL) {
                 imagefilledpolygon($this->im, $a, 4, $minmax_color);
                 if (!$y1x || !$y2x) {
                     imageline($this->im, $x1 + 1, $y1max, $x2 + 1, $y2max, $max_color);
                     imageline($this->im, $x1, $y1max, $x2, $y2max, $max_color);
                 }
                 if (!$y1n || !$y2n) {
                     imageline($this->im, $x1 - 1, $y1min, $x2 - 1, $y2min, $min_color);
                     imageline($this->im, $x1, $y1min, $x2, $y2min, $min_color);
                 }
             }
             imageline($this->im, $x1, $y1 + 1, $x2, $y2 + 1, $avg_color);
             imageline($this->im, $x1, $y1, $x2, $y2, $avg_color);
             break;
         case GRAPH_ITEM_DRAWTYPE_LINE:
             if ($calc_fnc == CALC_FNC_ALL) {
                 imagefilledpolygon($this->im, $a, 4, $minmax_color);
                 if (!$y1x || !$y2x) {
                     imageline($this->im, $x1, $y1max, $x2, $y2max, $max_color);
                 }
                 if (!$y1n || !$y2n) {
                     imageline($this->im, $x1, $y1min, $x2, $y2min, $min_color);
                 }
             }
             imageline($this->im, $x1, $y1, $x2, $y2, $avg_color);
             break;
         case GRAPH_ITEM_DRAWTYPE_FILLED_REGION:
             //--
             $a[0] = $x1;
             $a[1] = $y1;
             $a[2] = $x1;
             $a[3] = $y1_shift;
             $a[4] = $x2;
             $a[5] = $y2_shift;
             $a[6] = $x2;
             $a[7] = $y2;
             imagefilledpolygon($this->im, $a, 4, $avg_color);
             break;
         case GRAPH_ITEM_DRAWTYPE_DOT:
             imagefilledrectangle($this->im, $x1 - 1, $y1 - 1, $x1, $y1, $avg_color);
             break;
         case GRAPH_ITEM_DRAWTYPE_BOLD_DOT:
             imagefilledrectangle($this->im, $x2 - 1, $y2 - 1, $x2 + 1, $y2 + 1, $avg_color);
             break;
         case GRAPH_ITEM_DRAWTYPE_DASHED_LINE:
             if (function_exists('imagesetstyle')) {
                 // Use imagesetstyle+imageline instead of bugged imagedashedline
                 $style = array($avg_color, $avg_color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
                 imagesetstyle($this->im, $style);
                 imageline($this->im, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
             } else {
                 imagedashedline($this->im, $x1, $y1, $x2, $y2, $avg_color);
             }
             break;
         case GRAPH_ITEM_DRAWTYPE_GRADIENT_LINE:
             ImageLine($this->im, $x1, $y1, $x2, $y2, $avg_color);
             //draw the initial line
             ImageLine($this->im, $x1, $y1 - 1, $x2, $y2 - 1, $avg_color);
             $bitmask = 255;
             $blue = $avg_color & $bitmask;
             // $blue_diff = 255 - $blue;
             $bitmask = $bitmask << 8;
             $green = ($avg_color & $bitmask) >> 8;
             // $green_diff = 255 - $green;
             $bitmask = $bitmask << 8;
             $red = ($avg_color & $bitmask) >> 16;
             // $red_diff = 255 - $red;
             $maxAlpha = 110;
             $startAlpha = 50;
             $alphaRatio = $maxAlpha / ($this->sizeY - $startAlpha);
             $diffX = $x1 - $x2;
             for ($i = 0; $i <= $diffX; $i++) {
                 $Yincr = $diffX > 0 ? abs($y2 - $y1) / $diffX : 0;
                 $gy = $y1 > $y2 ? $y2 + $Yincr * $i : $y2 - $Yincr * $i;
                 $steps = $this->sizeY + $this->shiftY - $gy + 1;
                 for ($j = 0; $j < $steps; $j++) {
                     if ($gy + $j < $this->shiftY + $startAlpha) {
                         $alpha = 0;
                     } else {
                         $alpha = 127 - abs(127 - $alphaRatio * ($gy + $j - $this->shiftY - $startAlpha));
                     }
                     $color = imagecolorexactalpha($this->im, $red, $green, $blue, $alpha);
                     imagesetpixel($this->im, $x2 + $i, $gy + $j, $color);
                 }
             }
             break;
     }
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function apply(CanvasInterface $canvas, AbstractStyledDrawable $drawable)
 {
     $fv = $drawable->getColor()->getValue();
     $sv = $this->getSecondColor()->getValue();
     $style = array_merge(array_fill(0, $this->getFirstColorShowTime(), $fv), array_fill(0, $this->getSecondColorShowTime(), $sv));
     if (false == @imagesetstyle($canvas->getHandler(), $style)) {
         throw new DrawableException('Could Not Apply The DashedLine Style');
     }
     return new StyledColor();
 }
コード例 #12
0
ファイル: asciisvgimg.php プロジェクト: rolwi/koala
 function ASsetdash()
 {
     if (func_num_args() > 0) {
         $dash = func_get_arg(0);
         $this->curdash = $dash;
     } else {
         $dash = $this->curdash;
     }
     if ($dash == 'none' || !preg_match('/\\d/', $dash)) {
         $this->isdashed = false;
     } else {
         $dash = preg_replace('/\\s+/', ',', $dash);
         $darr = explode(',', $dash);
         $style = array();
         $alt = 0;
         $doagain = count($darr) % 2;
         //do twice if odd number
         while ($doagain > -1) {
             for ($i = 0; $i < count($darr); $i++) {
                 if ($alt == 0) {
                     $color = $this->stroke;
                 } else {
                     $color = 'white';
                 }
                 $style = array_pad($style, count($style) + $darr[$i], $this->{$color});
                 $alt = 1 - $alt;
             }
             $doagain--;
         }
         imagesetstyle($this->img, $style);
         $this->isdashed = true;
     }
 }
コード例 #13
0
ファイル: gd_image.inc.php プロジェクト: hcvcastro/pxp
 function DashedLineForGrid($x1, $y1, $x2, $y2, $dash_length = 1, $dash_space = 4)
 {
     if ($this->line_weight <= 0) {
         return;
     }
     // Add error check to make sure anti-alias is not enabled.
     // Dashed line does not work with anti-alias enabled. This
     // is a limitation in GD.
     if ($this->use_anti_aliasing) {
         //            JpGraphError::RaiseL(25129); // Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.
     }
     $x1 = round($x1);
     $x2 = round($x2);
     $y1 = round($y1);
     $y2 = round($y2);
     /*
     $dash_length *= $this->scale;
     $dash_space  *= $this->scale;
     */
     $dash_length = 2;
     $dash_length = 4;
     imagesetthickness($this->img, 1);
     $style = array_fill(0, $dash_length, $this->current_color);
     //hexdec('CCCCCC'));
     $style = array_pad($style, $dash_space, IMG_COLOR_TRANSPARENT);
     imagesetstyle($this->img, $style);
     imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
     $this->lastx = $x2;
     $this->lasty = $y2;
 }
コード例 #14
0
ファイル: gd_adapter.cls.php プロジェクト: sgrove/cothinker
 /**
  * Draws a circle at $x,$y with radius $r
  *
  * See {@link Style::munge_color()} for the format of the color array.
  * See {@link Cpdf::setLineStyle()} for a description of the $style
  * parameter (aka dash)
  *
  * @param float $x
  * @param float $y
  * @param float $r
  * @param array $color
  * @param float $width
  * @param array $style
  * @param bool $fill Fills the circle if true   
  */
 function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false)
 {
     // Scale by the AA factor
     $x *= $this->_aa_factor;
     $y *= $this->_aa_factor;
     $r *= $this->_aa_factor;
     $c = $this->_allocate_color($color);
     // Convert the style array if required
     if (!is_null($style) && !$fill) {
         $gd_style = array();
         foreach ($style as $length) {
             for ($i = 0; $i < $length; $i++) {
                 $gd_style[] = $c;
             }
         }
         imagesetstyle($this->_img, $gd_style);
         $c = IMG_COLOR_STYLED;
     }
     imagesetthickness($this->_img, $width);
     if ($fill) {
         imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
     } else {
         imageellipse($this->_img, $x, $y, $r, $r, $c);
     }
 }
コード例 #15
0
ファイル: captcha_gd.php プロジェクト: pombredanne/ArcherSys
	/**
	* Noise line
	*/
	function noise_line($img, $min_x, $min_y, $max_x, $max_y, $bg, $font, $non_font)
	{
		imagesetthickness($img, 2);

		$x1 = $min_x;
		$x2 = $max_x;
		$y1 = $min_y;
		$y2 = $min_y;

		do
		{
			$line = array_merge(
				array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
				array_fill(0, mt_rand(30, 60), $bg)
			);

			imagesetstyle($img, $line);
			imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);

			$y1 += mt_rand(12, 35);
			$y2 += mt_rand(12, 35);
		}
		while ($y1 < $max_y && $y2 < $max_y);

		$x1 = $min_x;
		$x2 = $min_x;
		$y1 = $min_y;
		$y2 = $max_y;

		do
		{
			$line = array_merge(
				array_fill(0, mt_rand(30, 60), $non_font[array_rand($non_font)]),
				array_fill(0, mt_rand(30, 60), $bg)
			);

			imagesetstyle($img, $line);
			imageline($img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);

			$x1 += mt_rand(20, 35);
			$x2 += mt_rand(20, 35);
		}
		while ($x1 < $max_x && $x2 < $max_x);
		imagesetthickness($img, 1);
	}
コード例 #16
0
ファイル: Image.class.php プロジェクト: xingskycn/simple-php
 function ImageCreateFrombmp($filename)
 {
     $buf = @file_get_contents($filename);
     if (strlen($buf) < 54) {
         return false;
     }
     $file_header = unpack("sbfType/LbfSize/sbfReserved1/sbfReserved2/LbfOffBits", substr($buf, 0, 14));
     if ($file_header["bfType"] != 19778) {
         return false;
     }
     $info_header = unpack("LbiSize/lbiWidth/lbiHeight/sbiPlanes/sbiBitCountLbiCompression/LbiSizeImage/lbiXPelsPerMeter/lbiYPelsPerMeter/LbiClrUsed/LbiClrImportant", substr($buf, 14, 40));
     if ($info_header["biBitCountLbiCompression"] == 2) {
         return false;
     }
     $line_len = round($info_header["biWidth"] * $info_header["biBitCountLbiCompression"] / 8);
     $x = $line_len % 4;
     if ($x > 0) {
         $line_len += 4 - $x;
     }
     $img = imagecreatetruecolor($info_header["biWidth"], $info_header["biHeight"]);
     switch ($info_header["biBitCountLbiCompression"]) {
         case 4:
             $colorset = unpack("L*", substr($buf, 54, 64));
             for ($y = 0; $y < $info_header["biHeight"]; $y++) {
                 $colors = array();
                 $y_pos = $y * $line_len + $file_header["bfOffBits"];
                 for ($x = 0; $x < $info_header["biWidth"]; $x++) {
                     if ($x % 2) {
                         $colors[] = $colorset[(ord($buf[$y_pos + ($x + 1) / 2]) & 0xf) + 1];
                     } else {
                         $colors[] = $colorset[(ord($buf[$y_pos + $x / 2 + 1]) >> 4 & 0xf) + 1];
                     }
                 }
                 imagesetstyle($img, $colors);
                 imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
             }
             break;
         case 8:
             $colorset = unpack("L*", substr($buf, 54, 1024));
             for ($y = 0; $y < $info_header["biHeight"]; $y++) {
                 $colors = array();
                 $y_pos = $y * $line_len + $file_header["bfOffBits"];
                 for ($x = 0; $x < $info_header["biWidth"]; $x++) {
                     $colors[] = $colorset[ord($buf[$y_pos + $x]) + 1];
                 }
                 imagesetstyle($img, $colors);
                 imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
             }
             break;
         case 16:
             for ($y = 0; $y < $info_header["biHeight"]; $y++) {
                 $colors = array();
                 $y_pos = $y * $line_len + $file_header["bfOffBits"];
                 for ($x = 0; $x < $info_header["biWidth"]; $x++) {
                     $i = $x * 2;
                     $color = ord($buf[$y_pos + $i]) | ord($buf[$y_pos + $i + 1]) << 8;
                     $colors[] = imagecolorallocate($img, ($color >> 10 & 0x1f) * 0xff / 0x1f, ($color >> 5 & 0x1f) * 0xff / 0x1f, ($color & 0x1f) * 0xff / 0x1f);
                 }
                 imagesetstyle($img, $colors);
                 imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
             }
             break;
         case 24:
             for ($y = 0; $y < $info_header["biHeight"]; $y++) {
                 $colors = array();
                 $y_pos = $y * $line_len + $file_header["bfOffBits"];
                 for ($x = 0; $x < $info_header["biWidth"]; $x++) {
                     $i = $x * 3;
                     $colors[] = imagecolorallocate($img, ord($buf[$y_pos + $i + 2]), ord($buf[$y_pos + $i + 1]), ord($buf[$y_pos + $i]));
                 }
                 imagesetstyle($img, $colors);
                 imageline($img, 0, $info_header["biHeight"] - $y - 1, $info_header["biWidth"], $info_header["biHeight"] - $y - 1, IMG_COLOR_STYLED);
             }
             break;
         default:
             return false;
             break;
     }
     return $img;
 }
コード例 #17
0
 /**
  * Draw a line on image
  *
  * Currently used only for drawig borders/
  * $begin and $end holds coordinates of begin and end points of line.
  * $color can be:
  * - integer - if line have to be solid
  * - array - if line have to be an pattern ({@link http://php.net/imagesestyle})
  *
  * @param array   $begin
  * @param array   $end
  * @param mixed   $color
  * @param integer $thickness
  *
  * @return boolean
  *
  * @access public
  */
 protected function drawLine(array $begin, array $end, $color, $thickness)
 {
     imagesetthickness($this->body, $thickness);
     if (!is_array($color)) {
         //solid
         if (is_string($color)) {
             $color = $this->color($color);
         }
         imageline($this->body, $begin[0], $begin[1], $end[0], $end[1], $color);
     } else {
         //pattern
         imagesetstyle($this->body, $color);
         imageline($this->body, $begin[0], $begin[1], $end[0], $end[1], IMG_COLOR_STYLED);
     }
     return true;
 }
コード例 #18
0
function dashedLine($image, $x1, $y1, $x2, $y2, $color)
{
    // style for dashed lines
    if (!is_array($color)) {
        $style = array($color, $color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
    } else {
        $style = $color;
    }
    imagesetstyle($image, $style);
    imageline($image, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
}
コード例 #19
0
ファイル: class.phplot.php プロジェクト: danorama/orsee
 protected function SetDashedStyle($which_ndxcol, $use_style = TRUE)
 {
     if ($use_style) {
         eval("\$style = {$this->default_dashed_style};");
         // See SetDefaultDashedStyle() above
         imagesetstyle($this->img, $style);
         return IMG_COLOR_STYLED;
         // Use this value as the color for drawing
     }
     return $which_ndxcol;
     // Styles are off; use original color for drawing
 }
コード例 #20
0
ファイル: image.php プロジェクト: mjiong/framework
 static function set(&$image, $value, $style = 'mix')
 {
     switch ($style) {
         case 'border':
             //画线粗细
             return imagesetthickness($image, (int) $value);
         case 'style':
             //画线风格
             return imagesetstyle($image, (array) $value);
         case 'brush':
             //画笔图像
             return imagesetbrush($image, $value);
         case 'pattern':
             //填充的贴图 图案
             return imagesettile($image, $value);
         case 'alias':
             //抗锯齿
             return imageantialias($image, (bool) $value);
         case 'alpha':
             //alpha混色标志
             return imagelayereffect($image, (int) $value);
         case 'transparent':
             //透明色
             return imagecolortransparent($image, (int) $value);
         case 'mix':
             //混色模式
         //混色模式
         default:
             return imagealphablending($image, (bool) $value);
     }
 }
コード例 #21
0
ファイル: genthumb.php プロジェクト: adhitia/schedule-builder
function scheduleToImage($data, $ids, $range, $width, $height, $n, $lines = false)
{
    $xfact = floatval($width) / count($data);
    $yfact = floatval($height) / $range;
    $image = imagecreatetruecolor($width, $height);
    imagealphablending($image, true);
    imagesavealpha($image, true);
    $bgcolors = array();
    /*
    // tetris colors
    $bgcolors[] = imagecolorallocate($image, 0, 255, 255); // cyan
    $bgcolors[] = imagecolorallocate($image, 0, 0, 255); // blue
    $bgcolors[] = imagecolorallocate($image, 255, 102, 0); //orange
    $bgcolors[] = imagecolorallocate($image, 255, 255, 0); // yellow
    $bgcolors[] = imagecolorallocate($image, 0, 255, 0); // green
    $bgcolors[] = imagecolorallocate($image, 102, 0, 255); // purple
    $bgcolors[] = imagecolorallocate($image, 255, 0, 0); // red
    */
    $bgcolors[] = imagecolorallocate($image, 255, 170, 170);
    // red
    $bgcolors[] = imagecolorallocate($image, 181, 225, 152);
    // green
    $bgcolors[] = imagecolorallocate($image, 180, 205, 235);
    // blue
    $bgcolors[] = imagecolorallocate($image, 255, 237, 160);
    // yellow
    $bgcolors[] = imagecolorallocate($image, 195, 172, 218);
    // purple
    $bgcolors[] = imagecolorallocate($image, 245, 198, 95);
    // orange
    $bgcolors[] = imagecolorallocate($image, 225, 181, 165);
    // another red
    $bgcolors[] = imagecolorallocate($image, 190, 235, 176);
    // another green
    $bgcolors[] = imagecolorallocate($image, 176, 191, 235);
    // another blue
    $shapebgcolor = imagecolorallocate($image, 255, 170, 170);
    $shapelncolor = imagecolorallocate($image, 151, 151, 151);
    $bgcolor = imagecolorallocatealpha($image, 255, 255, 255, 127);
    $dashcolor = imagecolorallocate($image, 170, 170, 170);
    imagefill($image, 0, 0, $bgcolor);
    imagesetstyle($image, array($bgcolor, $bgcolor, $dashcolor, $dashcolor));
    imageline($image, 0, $yfact * 5, $width, $yfact * 5, IMG_COLOR_STYLED);
    imageline($image, 0, $yfact * 9, $width, $yfact * 9, IMG_COLOR_STYLED);
    foreach ($data as $day => &$times) {
        foreach ($times as $off => $t) {
            if (count($t) == 0) {
                continue;
            }
            $x0 = $day * $xfact;
            $y0 = $t[0] * $yfact;
            $wd = $xfact;
            $ht = ($t[1] - $t[0]) * $yfact;
            $fillColor = false;
            if (count($ids[$day]) > 0) {
                $index = $ids[$day][$off] % count($bgcolors);
                $fillColor = $bgcolors[$n - $index];
            }
            if (!$fillColor) {
                $fillColor = $shapebgcolor;
            }
            imagefilledrectangle($image, $x0 + 1, $y0 + 1, $x0 + $wd - 2, $y0 + $ht - 2, $fillColor);
            imagerectangle($image, $x0, $y0, $x0 + $wd - 1, $y0 + $ht - 1, $shapelncolor);
            $fillColor = false;
        }
    }
    return $image;
}
コード例 #22
0
ファイル: captcha.function.php5 プロジェクト: netluxe/lolmail
function captcha_show_image()
{
    // Let's create an image
    $GLOBALS['captcha_show_credits'] ? $captcha_image = imagecreate(200, 51) : ($captcha_image = imagecreate(200, 40));
    // Random background and color scheme. Can be red, green or blue
    $captcha_backgrounds = array('FF0000', '00FF00', '0000FF');
    $captcha_color_scheme = $captcha_backgrounds[mt_rand(0, 2)];
    $captcha_colors = array(hexdec('0x' . $captcha_color_scheme[0] . $captcha_color_scheme[1]), hexdec('0x' . $captcha_color_scheme[2] . $captcha_color_scheme[3]), hexdec('0x' . $captcha_color_scheme[4] . $captcha_color_scheme[5]));
    $captcha_image_bgcolor = imagecolorallocate($captcha_image, $captcha_colors[0], $captcha_colors[1], $captcha_colors[2]);
    // Let's make some lighter and darker colors
    if ($captcha_color_scheme == 'FF0000') {
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0], $captcha_colors[1] + mt_rand(230, 240), $captcha_colors[2] + mt_rand(230, 240));
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0], $captcha_colors[1] + mt_rand(230, 240), $captcha_colors[2] + mt_rand(230, 240));
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0], $captcha_colors[1] + mt_rand(160, 220), $captcha_colors[2] + mt_rand(160, 220));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] - mt_rand(50, 100), $captcha_colors[1] + mt_rand(0, 50), $captcha_colors[2] + mt_rand(0, 50));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] - mt_rand(50, 100), $captcha_colors[1] + mt_rand(0, 50), $captcha_colors[2] + mt_rand(0, 50));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] - mt_rand(50, 100), $captcha_colors[1] + mt_rand(0, 50), $captcha_colors[2] + mt_rand(0, 50));
    } elseif ($captcha_color_scheme == '00FF00') {
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(230, 240), $captcha_colors[1], $captcha_colors[2] + mt_rand(230, 240));
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(230, 240), $captcha_colors[1], $captcha_colors[2] + mt_rand(230, 240));
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(150, 190), $captcha_colors[1], $captcha_colors[2] + mt_rand(150, 190));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 130), $captcha_colors[1] - mt_rand(50, 100), $captcha_colors[2] + mt_rand(0, 130));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 130), $captcha_colors[1] - mt_rand(50, 100), $captcha_colors[2] + mt_rand(0, 130));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 130), $captcha_colors[1] - mt_rand(50, 100), $captcha_colors[2] + mt_rand(0, 130));
    } else {
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(210, 230), $captcha_colors[1] + mt_rand(210, 230), $captcha_colors[2]);
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(210, 230), $captcha_colors[1] + mt_rand(210, 230), $captcha_colors[2]);
        $captcha_image_lcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(180, 200), $captcha_colors[1] + mt_rand(180, 200), $captcha_colors[2]);
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 100), $captcha_colors[1] + mt_rand(0, 100), $captcha_colors[2] - mt_rand(70, 150));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 100), $captcha_colors[1] + mt_rand(0, 100), $captcha_colors[2] - mt_rand(70, 150));
        $captcha_image_dcolor[] = imagecolorallocate($captcha_image, $captcha_colors[0] + mt_rand(0, 100), $captcha_colors[1] + mt_rand(0, 100), $captcha_colors[2] - mt_rand(70, 150));
    }
    // Background
    for ($i = 0; $i <= 10; $i++) {
        imagefilledrectangle($captcha_image, $i * 20 + mt_rand(4, 26), mt_rand(0, 39), $i * 20 - mt_rand(4, 26), mt_rand(0, 39), $captcha_image_dcolor[mt_rand(0, 2)]);
    }
    // Grid
    for ($i = 0; $i <= 10; $i++) {
        imageline($captcha_image, $i * 20 + mt_rand(4, 26), 0, $i * 20 - mt_rand(4, 26), 39, $captcha_image_lcolor[mt_rand(0, 2)]);
    }
    for ($i = 0; $i <= 10; $i++) {
        imageline($captcha_image, $i * 20 + mt_rand(4, 26), 39, $i * 20 - mt_rand(4, 26), 0, $captcha_image_lcolor[mt_rand(0, 2)]);
    }
    // This creates the captcha word
    $symbols = array('2', '3', '4', '5', '6', '7', '8', '9', 'A', 'C', 'E', 'G', 'H', 'K', 'M', 'N', 'P', 'R', 'S', 'U', 'V', 'W', 'Z', 'Y', 'Z');
    $captcha_word = '';
    for ($i = 0; $i <= 4; $i++) {
        $captcha_word .= $symbols[mt_rand(0, 24)];
    }
    // Let's place the word. Each letter will have random position, size, angle and font
    if (function_exists('imagettftext')) {
        for ($i = 0; $i <= 4; $i++) {
            imagettftext($captcha_image, mt_rand(24, 28), mt_rand(-20, 20), $i * mt_rand(30, 36) + mt_rand(2, 4), mt_rand(32, 36), $captcha_image_lcolor[mt_rand(0, 1)], mt_rand(1, 4) . '.ttf', $captcha_word[$i]);
        }
    } else {
        for ($i = 0; $i <= strlen($captcha_word); $i++) {
            imagestring($captcha_image, imageloadfont(mt_rand(1, 3) . '.gdf'), $i * mt_rand(20, 26), 0 + mt_rand(2, 4), $captcha_word[$i], $captcha_image_lcolor[mt_rand(0, 1)]);
        }
    }
    // Noise over the word
    imagesetstyle($captcha_image, array($captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)], $captcha_image_dcolor[mt_rand(0, 2)]));
    for ($i = 0; $i <= 4; $i++) {
        imageline($captcha_image, 0, mt_rand(0, 39), 199, mt_rand(0, 39), IMG_COLOR_STYLED);
    }
    $captcha_image_lineys = array(mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39));
    $captcha_image_lineye = array(mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39), mt_rand(0, 39));
    for ($i = 0; $i <= 4; $i++) {
        imageline($captcha_image, $i * 20 + mt_rand(1, 6), $captcha_image_lineys[$i], $i * 16 + mt_rand(1, 6), $captcha_image_lineye[$i], $captcha_image_lcolor[mt_rand(0, 1)]);
        imageline($captcha_image, $i * 20 + mt_rand(1, 6), $captcha_image_lineys[$i], $i * 16 + mt_rand(1, 6), $captcha_image_lineye[$i], $captcha_image_lcolor[mt_rand(0, 1)]);
    }
    // Credits
    if ($GLOBALS['captcha_show_credits']) {
        $captcha_creditsimg = imagecreatefrompng('protected.png');
        imagecopy($captcha_image, $captcha_creditsimg, 0, 40, 0, 0, 200, 11);
    }
    // Now we'll send a cookie or store the word in a session file
    if ($GLOBALS['captcha_method'] == 'cookie') {
        setcookie('magicword', md5($captcha_word), 0, '/');
    } else {
        session_start();
        $_SESSION['magicword'] = md5($captcha_word);
    }
    // Output the image to browser
    header('Content-type: image/png');
    header('Expires: Sun, 1 Jan 2000 12:00:00 GMT');
    header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', false);
    header('Pragma: no-cache');
    imagepng($captcha_image);
    imagedestroy($captcha_image);
}
コード例 #23
0
ファイル: jpgraph.php プロジェクト: pipporazzo/achievo
 function DashedLine($x1, $y1, $x2, $y2, $dash_length = 1, $dash_space = 4)
 {
     if ($this->line_weight <= 0) {
         return;
     }
     $x1 = round($x1);
     $x2 = round($x2);
     $y1 = round($y1);
     $y2 = round($y2);
     $style = array_fill(0, $dash_length, $this->current_color);
     $style = array_pad($style, $dash_length + $dash_space, IMG_COLOR_TRANSPARENT);
     imagesetstyle($this->img, $style);
     imageline($this->img, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
     $this->lastx = $x2;
     $this->lasty = $y2;
 }
コード例 #24
0
ファイル: co1de.php プロジェクト: nathan1217/ccad
    $num .= rand(0, 9);
}
// 4位验证码也可以用rand(1000,9999)直接生成
// 将生成的验证码写入session,备验证页面使用
Session_start();
$_SESSION["CheckCode"] = $num;
// 创建图片,定义颜色值
Header("Content-type: image/png");
srand((double) microtime() * 1000000);
$im = imagecreate(92, 35);
$black = ImageColorAllocate($im, 255, 255, 255);
$gray = ImageColorAllocate($im, 154, 25, 3);
imagefill($im, 0, 0, $gray);
// 随机绘制两条虚线,起干扰作用
$style = array($black, $black, $black, $black, $black, $gray, $gray, $gray, $gray, $gray);
imagesetstyle($im, $style);
$y1 = rand(0, 20);
$y2 = rand(0, 20);
$y3 = rand(0, 20);
$y4 = rand(0, 20);
imageline($im, 0, $y1, 60, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, 60, $y4, IMG_COLOR_STYLED);
// 在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
    imagesetpixel($im, rand(0, 60), rand(0, 70), $black);
}
// 将四个数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(3, 8);
for ($i = 0; $i < 4; $i++) {
    $strpos = rand(1, 6);
    imagestring($im, 5, $strx, $strpos, substr($num, $i, 1), $black);
コード例 #25
0
 /**
  * Renders the skelton of a chart (e.g. axis)
  *
  * @param  var[] params The axis parameters
  * @param  &img.Image img The image
  * @return &img.Image
  */
 protected function _renderAxis($params, $img)
 {
     $count = $params['count'];
     $distance = $params['distance'];
     $lower = $params['lower'];
     $upper = $params['upper'];
     $step = $params['step'];
     $leftBorder = $params['leftBorder'];
     $rightBorder = $params['rightBorder'];
     $topBorder = $params['topBorder'];
     $bottomBorder = $params['bottomBorder'];
     $font = $params['font'];
     $fontw = $params['fontWidth'];
     $fonth = $params['fontHeight'];
     $labels = $params['labels'];
     // Flood fill with background color
     $img->fill($params['backgroundColor']);
     // Calculate inner borders
     $innerWidth = $this->width - $leftBorder - $rightBorder;
     $innerHeight = $this->height - $topBorder - $bottomBorder;
     imagerectangle($img->handle, $leftBorder, $topBorder, $this->width - $rightBorder, $this->height - $bottomBorder, $params['axisColor']->handle);
     // Flood fill with background color
     $img->fill($params['chartbackColor'], $leftBorder + 1, $topBorder + 1);
     // Calculate zero line
     $zero = $this->height - $bottomBorder + $lower / ($upper - $lower) * $innerHeight;
     imageline($img->handle, $leftBorder, $zero, $this->width - $rightBorder, $zero, $params['axisColor']->handle);
     // Draw Y axis scale
     imagesetstyle($img->handle, [$params['gridColor']->handle, $params['gridColor']->handle, $params['chartbackColor']->handle, $params['chartbackColor']->handle]);
     for ($i = $lower; $i <= $upper; $i += $step) {
         $y = $zero - $i / ($upper - $lower) * $innerHeight;
         imageline($img->handle, $leftBorder - 5, $y, $leftBorder, $y, $params['axisColor']->handle);
         imagestring($img->handle, $font, $leftBorder - 10 - $fontw * strlen($i), $y - $fonth / 2, $i, $params['axisColor']->handle);
         if ($params['gridLines'] && $i > $lower && $i < $upper) {
             imageline($img->handle, $leftBorder + 1, $y, $this->width - $rightBorder - 1, $y, IMG_COLOR_STYLED);
         }
     }
     // Draw X axis
     for ($i = 0; $i < $count; $i++) {
         $x = $leftBorder + $i * $distance + $distance / 2;
         imageline($img->handle, $x, $this->height - $bottomBorder, $x, $this->height - $bottomBorder + 5, $params['axisColor']->handle);
         if (isset($labels[$i])) {
             imagestring($img->handle, $font, $x - strlen($labels[$i]) * $fontw / 2, $this->height - $bottomBorder + 5, $labels[$i], $params['axisColor']->handle);
         }
     }
     return $img;
 }
コード例 #26
0
ファイル: Helper.php プロジェクト: hippout/eco-test
 public function drawDestructorsChart($imgFile, $destructors, $skale)
 {
     $destructorsCnt = count($destructors);
     $scaler = 1.53;
     $width = round(600 * $scaler);
     $height = round((50 + 60 * $destructorsCnt) * $scaler);
     $img = imagecreatetruecolor($width, $height);
     $min = round($skale['min']);
     $max = round($skale['max']);
     $bgColor = imagecolorallocate($img, 255, 255, 255);
     imagefill($img, 0, 0, $bgColor);
     // рисуем оси
     $axisColor = imagecolorallocate($img, 134, 134, 134);
     imageline($img, 20 * $scaler, 50 * $scaler, 400 * $scaler, 50 * $scaler, $axisColor);
     imageline($img, 20 * $scaler, 50 * $scaler + 1, 400 * $scaler, 50 * $scaler + 1, $axisColor);
     imageline($img, 400 * $scaler, 50 * $scaler, 400 * $scaler, (50 + $destructorsCnt * 55) * $scaler, $axisColor);
     imageline($img, 401 * $scaler, 48 * $scaler, 401 * $scaler, (48 + $destructorsCnt * 55) * $scaler, $axisColor);
     imagettftext($img, round(10 * $scaler), 0, 397 * $scaler, 42 * $scaler, $axisColor, dirname(__FILE__) . '/fonts/georgia.ttf', $min);
     imagettftext($img, round(10 * $scaler), 0, 430 * $scaler, 42 * $scaler, $axisColor, dirname(__FILE__) . '/fonts/georgia.ttf', 'баллы');
     // рисуем вспомогательные линии
     $steps = $max - $min;
     $onePointWidth = (400 - 20) / $steps * $scaler;
     for ($i = $min; $i < $max; $i++) {
         $x = 400 * $scaler - $i * $onePointWidth;
         imageline($img, $x, 48 * $scaler, $x, (50 + $destructorsCnt * 55) * $scaler, $axisColor);
         // подписываем шкалу
         imagettftext($img, round(10 * $scaler), 0, $x - 3 * $scaler, (48 - 6) * $scaler, $axisColor, dirname(__FILE__) . '/fonts/georgia.ttf', $i + 1);
     }
     // рассчитываем какой деструктор каким цветом красим
     $maxValue = 0;
     $warningDestructorsKeys = array();
     $badDestructorsKeys = array();
     foreach ($destructors as $dKey => $desructor) {
         if ($desructor['val'] > $maxValue) {
             $badDestructorsKeys = array();
             $badDestructorsKeys[] = $dKey;
             $maxValue = $desructor['val'];
         } elseif ($desructor['val'] == $maxValue) {
             $badDestructorsKeys[] = $dKey;
         }
         if ($desructor['val'] - 1 > 0.4) {
             $warningDestructorsKeys[] = $dKey;
         }
     }
     // обрабатываем деструкторы
     $ind = 0;
     $destructorsTextColor = imagecolorallocate($img, 0, 0, 0);
     $destructorBadColor = imagecolorallocate($img, 227, 133, 163);
     $destructorComColor = imagecolorallocate($img, 255, 255, 255);
     $destructorWarnColor = imagecolorallocate($img, 232, 198, 130);
     $averageColor = imagecolorallocate($img, 210, 142, 5);
     $bordersColor = imagecolorallocate($img, 127, 127, 127);
     $averageCoords = array();
     foreach ($destructors as $dKey => $desructor) {
         // подписываем шкалы деструкторов
         $sizes = imagettfbbox(round(12 * $scaler), 0, dirname(__FILE__) . '/fonts/time.ttf', $desructor['name']);
         if ($sizes[2] > (600 - 410) * $scaler) {
             $name = $this->divideString($desructor['name']);
             $nameY = (75 + $ind * 55) * $scaler;
             if (!$name) {
                 $name = $desructor['name'];
                 $nameY = (84 + $ind * 55) * $scaler;
             }
         } else {
             $name = $desructor['name'];
             $nameY = (84 + $ind * 55) * $scaler;
         }
         imagettftext($img, round(12 * $scaler), 0, 405 * $scaler, $nameY, $destructorsTextColor, dirname(__FILE__) . '/fonts/time.ttf', $name);
         // рисуемы бары деструкторов
         $barWidth = ($desructor['val'] - $min) * $onePointWidth;
         $barHeight = 39 * $scaler;
         $dColor = in_array($dKey, $badDestructorsKeys) ? $destructorBadColor : (in_array($dKey, $warningDestructorsKeys) ? $destructorWarnColor : $destructorComColor);
         $this->drawBar($img, 400 * $scaler - $barWidth, (58 + $ind * 55) * $scaler, 400 * $scaler - 1, (97 + $ind * 55) * $scaler, $dColor);
         // рисуем границу бара
         $style = array($axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $bgColor, $bgColor, $bgColor);
         imagesetstyle($img, $style);
         imageline($img, 400 * $scaler - $barWidth, (58 + $ind * 55) * $scaler, 400 * $scaler - 1, (58 + $ind * 55) * $scaler, IMG_COLOR_STYLED);
         imageline($img, 400 * $scaler - $barWidth, (58 + $ind * 55) * $scaler, 400 * $scaler - $barWidth, (97 + $ind * 55) * $scaler, IMG_COLOR_STYLED);
         imageline($img, 400 * $scaler - $barWidth, (97 + $ind * 55) * $scaler, 400 * $scaler - 1, (97 + $ind * 55) * $scaler, IMG_COLOR_STYLED);
         // выводим значение бара
         imagettftext($img, round(12 * $scaler), 0, 400 * $scaler - $barWidth - 26 * $scaler, (84 + $ind * 55) * $scaler, $axisColor, dirname(__FILE__) . '/fonts/time.ttf', str_replace('.', ',', number_format(round($desructor['val'], 1), 1)));
         imagettftext($img, round(12 * $scaler), 0, 400 * $scaler - $barWidth - 26 * $scaler - 1, (84 + $ind * 55) * $scaler, $axisColor, dirname(__FILE__) . '/fonts/time.ttf', str_replace('.', ',', number_format(round($desructor['val'], 1), 1)));
         // отмечаем средние + подготавливаем их для кривой
         if ($desructor['av']) {
             $averageCoords[(78 + $ind * 55) * $scaler] = 400 * $scaler - ($desructor['av'] - $min) * $onePointWidth;
             $this->drawDiamond($img, 400 * $scaler - ($desructor['av'] - $min) * $onePointWidth - 5 * $scaler, (78 + $ind * 55) * $scaler - 5 * $scaler, 10 * $scaler, $averageColor);
         }
         $ind++;
     }
     // делаем легенду
     $style = array($axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $axisColor, $bgColor, $bgColor, $bgColor);
     imagesetstyle($img, $style);
     imageline($img, 30 * $scaler, 10 * $scaler, 55 * $scaler, 10 * $scaler, IMG_COLOR_STYLED);
     imageline($img, 30 * $scaler, 10 * $scaler, 30 * $scaler, 20 * $scaler, IMG_COLOR_STYLED);
     imageline($img, 30 * $scaler, 20 * $scaler, 55 * $scaler, 20 * $scaler, IMG_COLOR_STYLED);
     imageline($img, 55 * $scaler, 10 * $scaler, 55 * $scaler, 20 * $scaler, IMG_COLOR_STYLED);
     imagettftext($img, 10 * $scaler, 0, 60 * $scaler, 20 * $scaler, $destructorsTextColor, dirname(__FILE__) . '/fonts/time.ttf', 'Все без самооценки');
     if (count($averageCoords)) {
         $style = array($averageColor, $averageColor, $averageColor, $averageColor, $averageColor, $averageColor, $averageColor, $bgColor, $bgColor, $bgColor);
         imagesetstyle($img, $style);
         imagesetthickness($img, 3);
         imageline($img, 210 * $scaler, 15 * $scaler, 255 * $scaler, 15 * $scaler, IMG_COLOR_STYLED);
         imagettftext($img, 10 * $scaler, 0, 264 * $scaler, 20 * $scaler, $destructorsTextColor, dirname(__FILE__) . '/fonts/time.ttf', 'Среднее по всем оцениваемым руководителям');
         $this->drawDiamond($img, 227 * $scaler, 10 * $scaler, 10 * $scaler, $averageColor);
         // рисуем кривую среднюю
         //imageantialias($img, true);
         if (count($averageCoords) > 1) {
             $curve = new CubicSplines();
             $curve->setInitCoords($averageCoords, 1);
             $curveCoords = $curve->processCoords();
             $this->drawCurve($img, $curveCoords, $averageColor);
         }
     }
     imagepng($img, $imgFile);
     imagedestroy($img);
 }
コード例 #27
0
ファイル: maps.inc.php プロジェクト: TonywalkerCN/Zabbix
function myDrawLine($image, $x1, $y1, $x2, $y2, $color, $drawtype)
{
    if ($drawtype == MAP_LINK_DRAWTYPE_BOLD_LINE) {
        zbx_imagealine($image, $x1, $y1, $x2, $y2, $color, LINE_TYPE_BOLD);
    } elseif ($drawtype == MAP_LINK_DRAWTYPE_DASHED_LINE) {
        if (function_exists('imagesetstyle')) {
            // use imagesetstyle + imageline instead of bugged ImageDashedLine
            $style = array($color, $color, $color, $color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
            imagesetstyle($image, $style);
            zbx_imageline($image, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
        } else {
            imagedashedline($image, $x1, $y1, $x2, $y2, $color);
        }
    } elseif ($drawtype == MAP_LINK_DRAWTYPE_DOT && function_exists('imagesetstyle')) {
        $style = array($color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
        imagesetstyle($image, $style);
        zbx_imageline($image, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
    } else {
        zbx_imagealine($image, $x1, $y1, $x2, $y2, $color);
    }
}
コード例 #28
0
ファイル: styles_ex.php プロジェクト: SandyS1/presentations
<?php

define("WIDTH", 450);
define("HEIGHT", 450);
$img = imagecreate(WIDTH, HEIGHT);
$background = $white = imagecolorallocate($img, 0xff, 0xff, 0xff);
$black = imagecolorallocate($img, 0, 0, 0);
imagerectangle($img, 0, 0, WIDTH - 1, HEIGHT - 1, $black);
/* Define Style arrays */
$dashed = array($black, $black, $black, $white, $white, $white);
$sos = array($black, $black, $white, $white, $black, $black, $white, $white, $black, $black, $white, $white, $black, $black, $black, $black, $white, $white, $black, $black, $black, $black, $white, $white, $black, $black, $black, $black, $white, $white, $black, $black, $white, $white, $black, $black, $white, $white, $black, $black, $white, $white, $white, $white, $white, $white);
imagesetstyle($img, $sos);
imageline($img, 0, 0, WIDTH - 1, HEIGHT - 1, IMG_COLOR_STYLED);
imageline($img, 0, HEIGHT - 1, WIDTH - 1, 0, IMG_COLOR_STYLED);
imagesetstyle($img, $dashed);
imagerectangle($img, 30, 30, WIDTH - 31, HEIGHT - 31, IMG_COLOR_STYLED);
imagerectangle($img, 50, 50, WIDTH - 51, HEIGHT - 51, $black);
header("Content-Type: image/png");
imagepng($img);
コード例 #29
0
 function SetDashedStyle($which_ndxcol)
 {
     // See SetDefaultDashedStyle() to understand this.
     eval("\$style = {$this->default_dashed_style};");
     return imagesetstyle($this->img, $style);
 }
コード例 #30
0
ファイル: GD.php プロジェクト: hesselek/printed_module
 /**
  * Draws a circle at $x,$y with radius $r
  *
  * See {@link Style::munge_color()} for the format of the color array.
  * See {@link Cpdf::setLineStyle()} for a description of the $style
  * parameter (aka dash)
  *
  * @param float $x
  * @param float $y
  * @param float $r
  * @param array $color
  * @param float $width
  * @param array $style
  * @param bool $fill Fills the circle if true
  */
 function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false)
 {
     // Scale by the AA factor and DPI
     $x = $this->_upscale($x);
     $y = $this->_upscale($y);
     $r = $this->_upscale($r);
     $c = $this->_allocate_color($color);
     // Convert the style array if required
     if (is_array($style) && count($style) > 0 && !$fill) {
         $gd_style = array();
         foreach ($style as $length) {
             for ($i = 0; $i < $length; $i++) {
                 $gd_style[] = $c;
             }
         }
         if (!empty($gd_style)) {
             imagesetstyle($this->get_image(), $gd_style);
             $c = IMG_COLOR_STYLED;
         }
     }
     imagesetthickness($this->get_image(), $width);
     if ($fill) {
         imagefilledellipse($this->get_image(), $x, $y, $r, $r, $c);
     } else {
         imageellipse($this->get_image(), $x, $y, $r, $r, $c);
     }
 }