コード例 #1
0
 /**
  * Draws an ellipse on the handle
  *
  * @param ImageMagick-object $handle The handle on which the ellipse is drawn
  * @param Zend_Image_Action_DrawEllipse $ellipseObject The object that with all info
  */
 public function perform(Zend_Image_Adapter_ImageMagick $adapter, Zend_Image_Action_DrawEllipse $ellipseObject)
 {
     $draw = new ImagickDraw();
     $strokeColor = (string) $ellipseObject->getStrokeColor();
     $strokeAlpha = $ellipseObject->getStrokeAlpha() * 0.01;
     $draw->setStrokeColor($strokeColor);
     $draw->setStrokeOpacity($strokeAlpha);
     $draw->setStrokeWidth($ellipseObject->getStrokeWidth());
     $strokeDashArray = $ellipseObject->getStrokeDashPattern();
     if (count($strokeDashArray) > 0) {
         $draw->setStrokeDashArray($strokeDashArray);
     }
     $draw->setStrokeDashOffset($ellipseObject->getStrokeDashOffset());
     if ($ellipseObject->filled()) {
         $fillColor = (string) $ellipseObject->getFillColor();
         $draw->setFillColor($fillColor);
         $draw->setFillOpacity($ellipseObject->getFillAlpha() * 0.01);
     } else {
         $draw->setFillOpacity(0);
     }
     $width = $ellipseObject->getWidth();
     $height = $ellipseObject->getHeight();
     $x = $ellipseObject->getLocation()->getX();
     $y = $ellipseObject->getLocation()->getY();
     $draw->ellipse($x, $y, $width / 2, $height / 2, 0, 360);
     $adapter->getHandle()->drawImage($draw);
 }
コード例 #2
0
ファイル: Ellipse.php プロジェクト: kosinix/grafika
 /**
  * @param ImageInterface $image
  * @return ImageInterface
  */
 public function draw($image)
 {
     $strokeColor = new \ImagickPixel($this->getBorderColor()->getHexString());
     $fillColor = new \ImagickPixel($this->getFillColor()->getHexString());
     $draw = new \ImagickDraw();
     $draw->setStrokeColor($strokeColor);
     $draw->setFillColor($fillColor);
     $draw->setStrokeWidth($this->borderSize);
     list($x, $y) = $this->pos;
     $left = $x + $this->width / 2;
     $top = $y + $this->height / 2;
     $draw->ellipse($left, $top, $this->width / 2, $this->height / 2, 0, 360);
     $image->getCore()->drawImage($draw);
     return $image;
 }
コード例 #3
0
ファイル: draw_example.php プロジェクト: badlamer/hhvm
function test_shape(&$canvas)
{
    $draw = new ImagickDraw();
    $draw->setFillColor('transparent');
    $draw->setStrokeColor('#F02B88');
    $draw->setStrokeWidth(9);
    $draw->translate(200, 100);
    $draw->rectangle(-50, -50, 50, 50);
    $draw->translate(200, 100);
    $draw->ellipse(0, 0, 100, 80, 0, 360);
    $draw->skewX(-30);
    $draw->translate(200, 100);
    $draw->circle(0, 0, 50, 50);
    $canvas->drawImage($draw);
}
コード例 #4
0
ファイル: EllipseShape.php プロジェクト: alvarobfdev/applog
 /**
  * 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)
 {
     $circle = new \ImagickDraw();
     // set background
     $bgcolor = new Color($this->background);
     $circle->setFillColor($bgcolor->getPixel());
     // set border
     if ($this->hasBorder()) {
         $border_color = new Color($this->border_color);
         $circle->setStrokeWidth($this->border_width);
         $circle->setStrokeColor($border_color->getPixel());
     }
     $circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360);
     $image->getCore()->drawImage($circle);
     return true;
 }
コード例 #5
0
ファイル: ImageLib.php プロジェクト: sujata-patne/icon_api
 public static function createDefaultLogo($path)
 {
     try {
         $image = new \Imagick();
         $image->newImage(90, 90, new \ImagickPixel("white"));
         $draw = new \ImagickDraw();
         $draw->setFillColor(new \ImagickPixel("#" . mt_rand(100000, 999999)));
         $draw->ellipse(45, 45, 45, 45, 0, 360);
         $image->drawImage($draw);
         //$draw->setFillColor( new ImagickPixel( "#".mt_rand(100000, 999999) ) );#01C3EB
         $draw->setFillColor(new \ImagickPixel("#418bc9"));
         $draw->ellipse(45, 45, 20, 20, 0, 360);
         $image->drawImage($draw);
         $image->setImageFormat("png");
         $image_name = 'image_' . time() . '.png';
         $image->writeImage($path . $image_name);
         return $image_name;
     } catch (Exception $e) {
         //echo $e->getMessage();
         return false;
     }
 }
コード例 #6
0
ファイル: Drawer.php プロジェクト: jmstan/craft-website
 /**
  * {@inheritdoc}
  */
 public function ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, $fill = false, $thickness = 1)
 {
     $width = $size->getWidth();
     $height = $size->getHeight();
     try {
         $pixel = $this->getColor($color);
         $ellipse = new \ImagickDraw();
         $ellipse->setStrokeColor($pixel);
         $ellipse->setStrokeWidth(max(1, (int) $thickness));
         if ($fill) {
             $ellipse->setFillColor($pixel);
         } else {
             $ellipse->setFillColor('transparent');
         }
         $ellipse->ellipse($center->getX(), $center->getY(), $width / 2, $height / 2, 0, 360);
         if (false === $this->imagick->drawImage($ellipse)) {
             throw new RuntimeException('Ellipse operation failed');
         }
         $pixel->clear();
         $pixel->destroy();
         $ellipse->clear();
         $ellipse->destroy();
     } catch (\ImagickException $e) {
         throw new RuntimeException('Draw ellipse operation failed', $e->getCode(), $e);
     }
     return $this;
 }
コード例 #7
0
ファイル: Imagick.php プロジェクト: popphp/pop-image
 /**
  * Draw a pie slice on the image.
  *
  * @param  int $x
  * @param  int $y
  * @param  int $start
  * @param  int $end
  * @param  int $w
  * @param  int $h
  * @return Imagick
  */
 public function pie($x, $y, $start, $end, $w, $h = null)
 {
     $wid = $w;
     $hgt = null === $h ? $w : $h;
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->image->getColor($this->fillColor));
     $x1 = $w * cos($start / 180 * pi());
     $y1 = $h * sin($start / 180 * pi());
     $x2 = $w * cos($end / 180 * pi());
     $y2 = $h * sin($end / 180 * pi());
     $points = [['x' => $x, 'y' => $y], ['x' => $x + $x1, 'y' => $y + $y1], ['x' => $x + $x2, 'y' => $y + $y2]];
     $draw->polygon($points);
     $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
     $this->image->resource()->drawImage($draw);
     if ($this->strokeWidth > 0) {
         $draw = new \ImagickDraw();
         $draw->setFillColor($this->image->getColor($this->fillColor));
         $draw->setStrokeColor($this->image->getColor($this->strokeColor));
         $draw->setStrokeWidth($this->strokeWidth);
         $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
         $draw->line($x, $y, $x + $x1, $y + $y1);
         $draw->line($x, $y, $x + $x2, $y + $y2);
         $this->image->resource()->drawImage($draw);
     }
     return $this;
 }
コード例 #8
0
ファイル: Image.php プロジェクト: s4urp8n/kohana-admin
 /**
  * Draw filled circle on current image
  *
  * @param string $color
  * @param int    $center_x
  * @param int    $center_y
  * @param int    $radius
  * @param float  $opacity
  *
  * @return image
  */
 public function fillCircle($color, $center_x, $center_y, $radius, $opacity = 1)
 {
     $fill = new \ImagickDraw();
     $fill->setfillcolor(new \ImagickPixel($color));
     $fill->setfillopacity($opacity);
     $fill->ellipse($center_x, $center_y, $radius, $radius, 0, 360);
     $this->imagick->drawimage($fill);
     return $this;
 }
コード例 #9
0
ファイル: functions.php プロジェクト: sdmmember/Imagick-demos
function ellipse($strokeColor, $fillColor, $backgroundColor)
{
    $draw = new \ImagickDraw();
    $draw->setStrokeColor($strokeColor);
    $draw->setFillColor($fillColor);
    $draw->setStrokeWidth(2);
    $draw->setFontSize(72);
    $draw->ellipse(125, 70, 100, 50, 0, 360);
    $draw->ellipse(350, 70, 100, 50, 0, 315);
    $draw->push();
    $draw->translate(125, 250);
    $draw->rotate(30);
    $draw->ellipse(0, 0, 100, 50, 0, 360);
    $draw->pop();
    $draw->push();
    $draw->translate(350, 250);
    $draw->rotate(30);
    $draw->ellipse(0, 0, 100, 50, 0, 315);
    $draw->pop();
    $imagick = new \Imagick();
    $imagick->newImage(500, 500, $backgroundColor);
    $imagick->setImageFormat("png");
    $imagick->drawImage($draw);
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}
コード例 #10
0
ファイル: Imagick.php プロジェクト: nicksagona/PopPHP
 /**
  * Method to add an arc to the image.
  *
  * @param  int $x
  * @param  int $y
  * @param  int $start
  * @param  int $end
  * @param  int $w
  * @param  int $h
  * @return \Pop\Image\Imagick
  */
 public function drawArc($x, $y, $start, $end, $w, $h = null)
 {
     $wid = $w;
     $hgt = null === $h ? $w : $h;
     $draw = new \ImagickDraw();
     $draw->setFillColor($this->setColor($this->fillColor));
     $x1 = $w * cos($start / 180 * pi());
     $y1 = $h * sin($start / 180 * pi());
     $x2 = $w * cos($end / 180 * pi());
     $y2 = $h * sin($end / 180 * pi());
     $points = array(array('x' => $x, 'y' => $y), array('x' => $x + $x1, 'y' => $y + $y1), array('x' => $x + $x2, 'y' => $y + $y2));
     $draw->polygon($points);
     $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
     $this->resource->drawImage($draw);
     if (null !== $this->strokeWidth) {
         $draw = new \ImagickDraw();
         $draw->setFillColor($this->setColor($this->fillColor));
         $draw->setStrokeColor($this->setColor($this->strokeColor));
         $draw->setStrokeWidth(null === $this->strokeWidth ? 1 : $this->strokeWidth);
         $draw->ellipse($x, $y, $wid, $hgt, $start, $end);
         $draw->line($x, $y, $x + $x1, $y + $y1);
         $draw->line($x, $y, $x + $x2, $y + $y2);
         $this->resource->drawImage($draw);
     }
     return $this;
 }