示例#1
0
 public function ellipse($x, $y, $radiusX, $radiusY, $rotation, $startAngle, $endAngle, $anticlockwise)
 {
     if (self::DEBUG) {
         echo __FUNCTION__ . "\n";
     }
     $this->canvas->ellipse($x, $y, $radiusX, $radiusY);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function ellipse(PointInterface $center, BoxInterface $size, Color $color, $fill = false, $thickness = 1)
 {
     $width = $size->getWidth();
     $height = $size->getHeight();
     try {
         $pixel = $this->getColor($color);
         $ellipse = new \GmagickDraw();
         $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);
         $this->gmagick->drawImage($ellipse);
         $pixel = null;
         $ellipse = null;
     } catch (\GmagickException $e) {
         throw new RuntimeException('Draw ellipse operation failed', $e->getCode(), $e);
     }
     return $this;
 }
示例#3
0
 /**
  * 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 Gmagick
  */
 public function pie($x, $y, $start, $end, $w, $h = null)
 {
     $wid = $w;
     $hgt = null === $h ? $w : $h;
     $draw = new \GmagickDraw();
     $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 \GmagickDraw();
         $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;
 }