Example #1
0
 /**
  * Outputs the Captcha image.
  *
  * @param   boolean  html output
  * @return  mixed
  */
 public function render($html)
 {
     // Creates a black image to start from
     $this->image_create(Captcha::$config['background']);
     // Add random white/gray arcs, amount depends on complexity setting
     $count = (Captcha::$config['width'] + Captcha::$config['height']) / 2;
     $count = $count / 5 * min(10, Captcha::$config['complexity']);
     for ($i = 0; $i < $count; $i++) {
         imagesetthickness($this->image, mt_rand(1, 2));
         $color = imagecolorallocatealpha($this->image, 255, 255, 255, mt_rand(0, 120));
         imagearc($this->image, mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(-Captcha::$config['width'], Captcha::$config['width']), mt_rand(-Captcha::$config['height'], Captcha::$config['height']), mt_rand(0, 360), mt_rand(0, 360), $color);
     }
     // Use different fonts if available
     $font = Captcha::$config['fontpath'] . Captcha::$config['fonts'][array_rand(Captcha::$config['fonts'])];
     // Draw the character's white shadows
     $size = (int) min(Captcha::$config['height'] / 2, Captcha::$config['width'] * 0.8 / strlen($this->response));
     $angle = mt_rand(-15 + strlen($this->response), 15 - strlen($this->response));
     $x = mt_rand(1, Captcha::$config['width'] * 0.9 - $size * strlen($this->response));
     $y = (Captcha::$config['height'] - $size) / 2 + $size;
     $color = imagecolorallocate($this->image, 255, 255, 255);
     imagefttext($this->image, $size, $angle, $x + 1, $y + 1, $color, $font, $this->response);
     // Add more shadows for lower complexities
     Captcha::$config['complexity'] < 10 and imagefttext($this->image, $size, $angle, $x - 1, $y - 1, $color, $font, $this->response);
     Captcha::$config['complexity'] < 8 and imagefttext($this->image, $size, $angle, $x - 2, $y + 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 6 and imagefttext($this->image, $size, $angle, $x + 2, $y - 2, $color, $font, $this->response);
     Captcha::$config['complexity'] < 4 and imagefttext($this->image, $size, $angle, $x + 3, $y + 3, $color, $font, $this->response);
     Captcha::$config['complexity'] < 2 and imagefttext($this->image, $size, $angle, $x - 3, $y - 3, $color, $font, $this->response);
     // Finally draw the foreground characters
     $color = imagecolorallocate($this->image, 0, 0, 0);
     imagefttext($this->image, $size, $angle, $x, $y, $color, $font, $this->response);
     // Output
     return $this->image_render($html);
 }
Example #2
0
 public function apply($resource)
 {
     // Extract arguments
     @(list(, $x1, $y1, $x2, $y2, $thickness, $color) = func_get_args());
     $x1 = (int) $x1;
     $y1 = (int) $y1;
     $x2 = (int) $x2;
     $y2 = (int) $y2;
     $thickness = (int) $thickness;
     if (!$color) {
         $color = '#000000';
     }
     $rgb = html2rgb($color);
     if ($thickness < 1) {
         $thickness = 1;
     }
     // Draw line
     if (!imagesetthickness($resource, $thickness)) {
         throw new Exception("Thickness line changing failed");
     }
     if (!imageline($resource, $x1, $y1, $x2, $y2, imagecolorallocate($resource, $rgb[0], $rgb[1], $rgb[2]))) {
         throw new Exception("Line drawing failed");
     }
     return $resource;
 }
 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);
     }
 }
Example #4
0
function check($len = 4)
{
    session_start();
    header('content-type:image/png');
    $fs = ['/a.ttf', '/b.ttf', '/f.ttf'];
    $font = dirname(__FILE__) . $fs[mt_rand(0, 1)];
    $w = 35 * $len;
    $h = 50;
    $i = imagecreatetruecolor($w, $h);
    $c = imagecolorallocatealpha($i, 0, 0, 0, 127);
    //imagecolortransparent($i,$c);
    //imagefill($i,0,0,$c);
    imagefilledrectangle($i, 0, 0, $w, $h, gc($i, 'ffffff', mt_rand(0, 2)));
    $sss = '';
    for ($j = 0; $j < $len; $j++) {
        $st = gs(1);
        $sss .= $st;
        imagettftext($i, mt_rand(15, 25), mt_rand(-30, 30), $j * 35 + 10, mt_rand(28, 38), gc($i), $font, $st);
    }
    $_SESSION['code'] = $sss;
    imagesetthickness($i, mt_rand(2, 8));
    for ($j = 0; $j < mt_rand(5, 10); $j++) {
        imagefilledarc($i, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, 360), mt_rand(0, 360), gc($i, 'rand', mt_rand(100, 120)), IMG_ARC_NOFILL);
    }
    for ($j = 0; $j < 10; $j++) {
        imagettftext($i, mt_rand(10, 15), mt_rand(-5, 5), mt_rand(0, $w), mt_rand(0, $h), gc($i, 'rand', mt_rand(100, 120)), $font, gs(1));
    }
    imagepng($i);
    imagedestroy($i);
}
Example #5
0
 /**
  * Makes a graphical captcha from the provided text string
  *
  * @param string $captcha_text string to make image captcha from
  * @return string $data_url a data url containing the obfuscated image
  */
 function makeGraphicalCaptcha($captcha_text)
 {
     $image = @imagecreatetruecolor(195, 35);
     // defines background color, random lines color and text color
     $bg_color = imagecolorallocate($image, mt_rand(0, 255), 255, 0);
     imagefill($image, 0, 0, $bg_color);
     $lines_color = imagecolorallocate($image, 0x99, 0xcc, 0x99);
     $text_color = imagecolorallocate($image, mt_rand(0, 255), 0, 255);
     // draws random lines
     for ($i = 0; $i < 4; $i++) {
         imageline($image, 0, rand(0, 35), 195, rand(0, 35), $lines_color);
     }
     $captcha_letter_array = str_split($captcha_text);
     foreach ($captcha_letter_array as $i => $captcha_letter) {
         imagesetthickness($image, 1);
         imagestring($image, 5, 5 + $i * 35, rand(2, 14), $captcha_letter, $text_color);
     }
     // creates image
     ob_start();
     imagejpeg($image);
     $image_data = ob_get_contents();
     ob_end_clean();
     $data_url = "data:image/jpeg;base64," . base64_encode($image_data);
     imagedestroy($image);
     return $data_url;
 }
Example #6
0
 /**
  * renders the current captcha image
  */
 function showImage()
 {
     $image = imagecreatetruecolor($this->width, $this->height);
     $width = imagesx($image);
     $height = imagesy($image);
     $black = imagecolorallocate($image, 0, 0, 0);
     $white = imagecolorallocate($image, 250, 250, 250);
     $red = imagecolorallocatealpha($image, 225, 225, 225, 75);
     $green = imagecolorallocatealpha($image, 150, 150, 150, 75);
     $blue = imagecolorallocatealpha($image, 200, 200, 200, 75);
     imagefilledrectangle($image, 0, 0, $width, $height, $white);
     imagefilledellipse($image, ceil(rand(5, 145)), ceil(rand(0, 35)), 30, 30, $red);
     $points = array(rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50), rand(0, 150), rand(0, 50));
     imagefilledpolygon($image, $points, 4, $blue);
     imagefilledpolygon($image, array_reverse($points), 6, $green);
     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);
     for ($i = 0; $i < 50; $i++) {
         //imagefilledrectangle($im, $i + $i2, 5, $i + $i3, 70, $black);
         imagesetthickness($image, rand(1, 5));
         imagearc($image, rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(1, 150), rand(1, 50), rand(0, 1) ? $green : $red);
     }
     if (function_exists("imagettftext")) {
         $font = DIR_ROOT . 'view/fonts/Duality.ttf';
         imagettftext($image, 24, rand(-5, 5), intval(($width - strlen($this->code) * 10) / 2), intval(($height + 10) / 2), $black, $font, $this->code);
     } else {
         imagestring($image, 5, intval(($width - strlen($this->code) * 9) / 2), intval(($height - 15) / 2), $this->code, $black);
     }
     header('Content-type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }
Example #7
0
 private function creat_line()
 {
     imagesetthickness($this->img, 3);
     $xpos = $this->size * 2 + rand(-5, 5);
     $width = $this->width / 2.66 + rand(3, 10);
     $height = $this->size * 2.14;
     if (rand(0, 100) % 2 == 0) {
         $start = rand(0, 66);
         $ypos = $this->height / 2 - rand(10, 30);
         $xpos += rand(5, 15);
     } else {
         $start = rand(180, 246);
         $ypos = $this->height / 2 + rand(10, 30);
     }
     $end = $start + rand(75, 110);
     imagearc($this->img, $xpos, $ypos, $width, $height, $start, $end, $this->color);
     if (rand(1, 75) % 2 == 0) {
         $start = rand(45, 111);
         $ypos = $this->height / 2 - rand(10, 30);
         $xpos += rand(5, 15);
     } else {
         $start = rand(200, 250);
         $ypos = $this->height / 2 + rand(10, 30);
     }
     $end = $start + rand(75, 100);
     imagearc($this->img, $this->width * 0.75, $ypos, $width, $height, $start, $end, $this->color);
 }
Example #8
0
function drawLine()
{
    //header('Content-type: image/png');
    $png_image = imagecreate(150, 150);
    imagecolorallocate($png_image, 15, 142, 210);
    imagesetthickness($png_image, 5);
    $black = imagecolorallocate($png_image, 0, 0, 0);
    $x = 0;
    $y = 0;
    $w = imagesx($png_image) - 1;
    $z = imagesy($png_image) - 1;
    // Rectangle
    // imageline ($image, $x1, $y1, $x2, $y2, $color)
    imageline($png_image, $x, $y, $x, $y + $z, $black);
    imageline($png_image, $x, $y, $x + $w, $y, $black);
    imageline($png_image, $x + $w, $y, $x + $w, $y + $z, $black);
    imageline($png_image, $x, $y + $z, $x + $w, $y + $z, $black);
    // Lines
    imageline($png_image, $x, $y, $w, $z, $black);
    imagepng($png_image, 'simpletext.png');
    //imagepng($png_image);
    imagedestroy($png_image);
    $imgNumber = new NumberImage(1, 50, 50, 10);
    $imgNumber->setFileName("jedan");
    $imgNumber->drawNumberLineImage();
}
Example #9
0
 function generate_image($canvas)
 {
     global $captcha_font_path, $captcha_img_path;
     imagesetthickness($canvas, 1);
     //$rand = preg_replace("/([0-9])/e","chr((\\1+112))",rand(100000,999999));
     $var = rand(0, 1);
     $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     $liney = rand(3, 6);
     $linex = rand(6, 12);
     for ($i = $liney; $i > 0; $i--) {
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
         //	if ($i==0)
         //	{
         //	$this->arrow($canvas,10,$i*60/$liney,200,$i*60/$liney, 5, 5, $color );
         //	}
         //     else
         //     {
         imageline($canvas, 10, $i * 60 / $liney, 200, $i * 60 / $liney, $color);
         //    }
         imagefttext($canvas, 8, rand(-45, 45), 3, $i * 60 / $liney, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $liney - $i);
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     }
     for ($i = 0; $i < $linex; $i++) {
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
         imageline($canvas, 30 + $i * 160 / $linex, 0, 30 + $i * 160 / $linex, 70, $color);
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
         imagefttext($canvas, 8, rand(-45, 45), 30 + $i * 160 / $linex, 80, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", $i);
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     }
     $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     imagesetthickness($canvas, 1);
     $x = rand(0, $linex - 1);
     $y = rand(0, $liney - 1);
     for ($i = -5; $i < 5; $i++) {
         $xr = rand(0, $linex);
         $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
         $yr = rand(0, $liney);
         imageline($canvas, 30 + $x * 160 / $linex, ($liney - $y) * 60 / $liney, 30 + $xr * 160 / $linex, ($liney - $yr) * 60 / $liney, $color);
     }
     $color = imagecolorallocate($canvas, rand(100, 255), rand(100, 255), rand(100, 255));
     //echo "!".$x."===".$y."!<br>";
     if ($var) {
         imagefttext($canvas, 20, rand(-45, 45), 40 + 20, 50, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", "y=?");
     } else {
         imagefttext($canvas, 12, rand(-45, 45), 100, 70, $color, $captcha_font_path . "/LiberationMono-Bold.ttf", "X=?");
     }
     $nme = $this->ucaptcha->get_filename();
     imagepng($canvas);
     //imagepng($canvas,$captcha_img_path."/".$nme.".png");
     $captcha[0] = $nme;
     if ($var) {
         $captcha[1] = $y;
         $captcha[2] = "Введите координату Y точки, откуда берут начало прямые";
     } else {
         $captcha[1] = $x;
         $captcha[2] = "Введите координату X точки, откуда берут начало прямые";
     }
     return $captcha;
 }
Example #10
0
 private function drawLines()
 {
     $lineCnt = mt_rand(4, 8);
     for ($i = 0; $i < $lineCnt; $i++) {
         imagesetthickness($this->tmpImage, rand(1, 3));
         imagearc($this->tmpImage, mt_rand(-10, $this->width), mt_rand(-10, $this->height), mt_rand(30, 300), mt_rand(20, 200), mt_rand(80, 360), mt_rand(0, 300), $this->textColor);
     }
 }
 /**
  * {@inheritdoc}
  */
 public final function draw(CanvasInterface $canvas, StyleInterface $style = null)
 {
     if (!$canvas->isHandlerSet()) {
         throw new CanvasEmptyException(sprintf('Can Not Draw Drawable (%s) - Canvas Is Empty', (string) $this));
     }
     @imagesetthickness($canvas->getHandler(), $this->getLineThickness());
     $this->doDraw($canvas, $style);
     return $this;
 }
Example #12
0
 protected function renderStroke($image, array $params, $color, $strokeWidth)
 {
     imagesetthickness($image, $strokeWidth);
     if ($params['open']) {
         $this->renderStrokeOpen($image, $params['points'], $color);
         return;
     }
     imagepolygon($image, $params['points'], $params['numpoints'], $color);
 }
Example #13
0
 private function randsquare()
 {
     imagesetthickness($this->image, 1);
     srand($this->make_seed());
     $x = rand(0, $this->larguaImagem - 15);
     $y = rand(0, $this->alturaImagem - 15);
     imageFilledRectangle($this->image, $x, $y, $x + 10, $y + 10, $this->color($this->corRetangulos));
     imagerectangle($this->image, $x - 10, $y, $x + 10, $y + 10, $this->randcolor());
 }
Example #14
0
 /**
  * Draw polygon.
  * 
  * @param array $points An array containing the polygon's vertices.
  * @param null|array $options
  */
 public function drawPolygon(array $points, array $options = null)
 {
     $this->setOptions($options);
     $colorRgb = Utility::htmlToRgb($this->optionStrokeColor);
     $color = $this->allocateColor($this->Resource, $colorRgb['r'], $colorRgb['g'], $colorRgb['b']);
     imagesetthickness($this->Resource, $this->optionStrokeWidth);
     $numPoints = count($points) / 2;
     imagepolygon($this->Resource, $points, $numPoints, $color);
 }
 public function __construct($width, $height)
 {
     // create a GD image to display results and debug
     $this->width = $width;
     $this->height = $height;
     $this->image = imagecreatetruecolor($width, $height);
     $white = imagecolorallocate($this->image, 0xff, 0xff, 0xff);
     imagefill($this->image, 0, 0, $white);
     imagesetthickness($this->image, 3);
 }
Example #16
0
function store_map($im, $passthru, $shape, $row, $col, $x1, $y1, $x2, $y2)
{
    static $color = NULL;
    if (!isset($color)) {
        $color = imagecolorallocate($im, 255, 0, 0);
    }
    imagesetthickness($im, 3);
    imagerectangle($im, $x1, $y1, $x2, $y2, $color);
    imagesetthickness($im, 1);
}
function make_cut_image($row, $verts, $width, $height)
{
    $center = new vertex(0, 0, 0);
    $image = imagecreatetruecolor($width, $height);
    if (isset($_REQUEST['usealpha'])) {
        $trans_color = imagecolorallocatealpha($image, 255, 255, 255, 0);
        imagefill($image, 0, 0, $trans_color);
    }
    $verticies = explode("\n", $verts);
    $start = new vertex(0, 0, 0);
    $start->parse_llvector($verticies[0]);
    $count = count($verticies);
    $x = 0.0;
    $t = 0.0;
    $start_color = new vertex(0, 128, 0);
    $end_color = new vertex(255, 255, 255);
    $previous = $start;
    foreach ($verticies as $point) {
        $current = new vertex(0, 0, 0);
        $current->parse_llvector($point);
        $center->add($current);
        ++$x;
    }
    $center->mult(1.0 / $x);
    $x = 0;
    imagesetthickness($image, 2);
    foreach ($verticies as $point) {
        $t = $x / $count;
        $current = new vertex(0, 0, 0);
        $current->parse_llvector($point);
        if ($verticies[0] != $point) {
            $vcolor = $start_color->get_interp($end_color, $t);
            $color = $vcolor->allocate_color($image);
            fill_pie($image, $center, $previous, $current, $width, $height, $color);
        }
        $previous = $current;
        ++$x;
    }
    $color = imagecolorallocate($image, $end_color->x, $end_color->y, $end_color->z);
    fill_pie($image, $center, $previous, $start, $width, $height, $color);
    $x = 0;
    foreach ($verticies as $point) {
        ++$x;
        $t = $x / $count;
        $current = new vertex(0, 0, 0);
        $current->parse_llvector($point);
        $current->x = ($current->x + 1) * 0.5;
        $current->y = 1.0 - ($current->y + 1) * 0.5;
        $current->x *= $width;
        $current->y *= $height;
        $color = $color = imagecolorallocate($image, 255 * $t, 0, 255 * (1 - $t));
        imagefilledellipse($image, intval($current->x), intval($current->y), 8, 8, $color);
    }
    return $image;
}
 /**
  * Draw rectangle to given image at certain position
  *
  * @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);
     imagefilledrectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imagerectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $border_color->getInt());
     }
     return true;
 }
Example #19
0
 /**
  * Draw polygon 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);
     imagefilledpolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         imagepolygon($image->getCore(), $this->points, intval(count($this->points) / 2), $border_color->getInt());
     }
     return true;
 }
Example #20
0
 /**
  * Draw rectangle to given GD resource
  *
  * @param  resource $resource
  * @param  integer  $x
  * @param  integer  $y
  * @return boolean
  */
 private function applyToResource($resource, $x, $y)
 {
     $background = new Color($this->background);
     imagefilledrectangle($resource, $this->x1, $this->y1, $this->x2, $this->y2, $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($resource, $this->border_width);
         imagerectangle($resource, $this->x1, $this->y1, $this->x2, $this->y2, $border_color->getInt());
     }
     return true;
 }
 public function draw($sx, $sy, $ex, $ey, $gobj, $colour)
 {
     $cur_x = $sx;
     $cur_y = $sy;
     $first = true;
     foreach ($this->data as $points) {
         $bounds = $this->translate($points, $sx, $sy, $ex, $ey);
         $tex = $bounds[0];
         $tey = $bounds[1];
         imagesetthickness($gobj, 3);
         if (!$first) {
             /*if($this->style)
                       {
                           $split = preg_split('//',$this->style);
                           
                           foreach($split as $one_or_zero)
                           {
                               if($one_or_zero)
                                   $element = '$colour';
                               else
                                   $element = 'IMG_COLOR_TRANSPARENT';
               
                               $args[] = $element;
                           }
               
                           $str = implode(',',$args);
                           eval('$style = array('.$str.');');
                           //$brush = imagecreatetruecolor(50,50);
                           imageantialias($gobj,false);
                           //imagefilledellipse($brush,25,25,50,50,$colour);
                           //imagesetbrush($gobj,$brush);
                           imagesetstyle($gobj,$style);
                           //$colour_to_use = IMG_COLOR_STYLEDBRUSHED;
                           $colour_to_use = IMG_COLOR_STYLED;
                       }
                       
                       else
                           $colour_to_use = $colour;*/
             //imageline($gobj,$cur_x,$cur_y,$tex,$tey,$colour_to_use);
             imageline($gobj, $cur_x, $cur_y, $tex, $tey, $colour);
             if ($this->style == 'square') {
                 imagefilledrectangle($gobj, $tex - 10, $tey - 10, $tex + 10, $tey + 10, $colour);
             } else {
                 if ($this->style == 'circle') {
                     imagefilledellipse($gobj, $tex, $tey, 20, 20, $colour);
                 }
             }
         } else {
             $first = false;
         }
         $cur_x = $tex;
         $cur_y = $tey;
     }
 }
 /**
  * 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;
 }
Example #23
0
 /**
  * Draw polygon on given GD resource
  *
  * @param  resource $resource
  * @param  integer  $x
  * @param  interger $y
  * @return boolean
  */
 private function applyToResource($resource, $x, $y)
 {
     $background = new Color($this->background);
     imagefilledpolygon($resource, $this->points, intval(count($this->points) / 2), $background->getInt());
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         imagesetthickness($resource, $this->border_width);
         imagepolygon($resource, $this->points, intval(count($this->points) / 2), $border_color->getInt());
     }
     return true;
 }
Example #24
0
 function drawPie($centerX, $centerY, $radius, $begin, $end, $style)
 {
     $radius = $radius * 2;
     if ($begin != 0 || $end != 360) {
         $tmp = -$begin;
         $begin = -$end;
         $end = $tmp;
     }
     $this->_convertPosition($centerX, $centerY);
     $radius = $radius * min($this->width, $this->height);
     imagefilledarc($this->gd, $centerX, $centerY, $radius, $radius, $begin, $end, $style['fill'], IMG_ARC_PIE);
     imagesetthickness($this->gd, $style['line-width']);
     imagefilledarc($this->gd, $centerX, $centerY, $radius, $radius, $begin, $end, $style['line'], IMG_ARC_NOFILL | IMG_ARC_EDGED);
 }
Example #25
0
 protected function renderStroke($image, array $params, $color, $strokeWidth)
 {
     imagesetthickness($image, $strokeWidth);
     $width = $params['width'];
     if (intval($width) % 2 === 0) {
         $width += 1;
     }
     $height = $params['height'];
     if (intval($height) % 2 === 0) {
         $height += 1;
     }
     // imageellipse ignores imagesetthickness; draw arc instead
     imagearc($image, $params['cx'], $params['cy'], $width, $height, 0, 360, $color);
 }
Example #26
0
 /**
  * Draw ellipse on given gd resource
  *
  * @param  resource $resource
  * @return boolean
  */
 private function applyToResource($resource, $x, $y)
 {
     // parse background color
     $background = new Color($this->background);
     if ($this->hasBorder()) {
         // slightly smaller ellipse to keep 1px bordered edges clean
         imagefilledellipse($resource, $x, $y, $this->width - 1, $this->height - 1, $background->getInt());
         $border_color = new Color($this->border_color);
         imagesetthickness($resource, $this->border_width);
         // gd's imageellipse doesn't respect imagesetthickness so i use imagearc with 359.9 degrees here
         imagearc($resource, $x, $y, $this->width, $this->height, 0, 359.99, $border_color->getInt());
     } else {
         imagefilledellipse($resource, $x, $y, $this->width, $this->height, $background->getInt());
     }
 }
Example #27
0
 public function demoGrid()
 {
     $black = imagecolorallocate($this->image, 0, 0, 0);
     imagesetthickness($this->image, 3);
     $cellWidth = ($this->realWidth - 1) / $this->gridWidth;
     // note: -1 to avoid writting
     $cellHeight = ($this->realHeight - 1) / $this->gridHeight;
     // a pixel outside the image
     for ($x = 0; $x <= $this->gridWidth; $x++) {
         for ($y = 0; $y <= $this->gridHeight; $y++) {
             imageline($this->image, $x * $cellWidth, 0, $x * $cellWidth, $this->realHeight, $black);
             imageline($this->image, 0, $y * $cellHeight, $this->realWidth, $y * $cellHeight, $black);
         }
     }
 }
Example #28
0
function draw_xy($img, $white, $black, $x, $y, $x_s, $y_s)
{
    imagefill($img, 0, 0, $white);
    imageline($img, 100, 510, 100, 10, $black);
    imageline($img, 90, 500, 750, 500, $black);
    for ($i = 1; $i < 5; $i++) {
        imageline($img, 100 + $x_s * $i, 500, 100 + $x_s * $i, 510, $black);
        imagestring($img, 5, 175 + $x_s * ($i - 1), 520, 'Day' . $i, $black);
    }
    for ($i = 0; $i <= 6; $i++) {
        imageline($img, 90, 500 - $i * $y_s, 750, 500 - $i * $y_s, $black);
        $fen = $i * 5;
        imagestring($img, 5, 55, $y - $i * $y_s - 6, $fen, $black);
    }
    imagesetthickness($img, 3);
}
Example #29
0
 /**
  * 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)
 {
     // parse background color
     $background = new Color($this->background);
     if ($this->hasBorder()) {
         // slightly smaller ellipse to keep 1px bordered edges clean
         imagefilledellipse($image->getCore(), $x, $y, $this->width - 1, $this->height - 1, $background->getInt());
         $border_color = new Color($this->border_color);
         imagesetthickness($image->getCore(), $this->border_width);
         // gd's imageellipse doesn't respect imagesetthickness so i use imagearc with 359.9 degrees here
         imagearc($image->getCore(), $x, $y, $this->width, $this->height, 0, 359.99, $border_color->getInt());
     } else {
         imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
     }
     return true;
 }
function image_thumbnail()
{
    // creates finalized thumbnail
    // input data: [0] => image_id
    $function_arguments = func_get_args();
    $file_dest = $_SERVER['DOCUMENT_ROOT'] . "/images/main/Tattoos/preview" . $function_arguments[0] . ".gif";
    $image_src = image_picture($function_arguments[0]);
    $image_dest = imagecreatetruecolor(90, 90);
    $col_line = imagecolorallocatealpha($image_dest, 99, 108, 90, 0);
    imagesetthickness($image_dest, 2);
    imagecopy($image_dest, $image_src, 0, 0, 0, 0, 90, 90);
    imagerectangle($image_dest, 0, 1, 89, 88, $col_line);
    imagetruecolortopalette($image_dest, 0, 128);
    imagegif($image_dest, $file_dest);
    imagedestroy($image_src);
    imagedestroy($image_dest);
}