<?php
namespace Grafika\Gd\DrawingObject;
use Grafika\DrawingObject\Ellipse as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Gd\Editor;
use Grafika\ImageInterface;
class Ellipse extends Base implements DrawingObjectInterface
{
public function draw($image)
{
list($x, $y) = $this->pos;
$left = $x + $this->width / 2;
$top = $y + $this->height / 2;
if( null !== $this->fillColor ){
list($r, $g, $b, $alpha) = $this->fillColor->getRgba();
$fillColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
imagefilledellipse($image->getCore(), $left, $top, $this->width, $this->height, $fillColorResource);
}
if ( 0 < $this->getBorderSize() and null !== $this->borderColor) { list($r, $g, $b, $alpha) = $this->borderColor->getRgba();
$borderColorResource = imagecolorallocatealpha($image->getCore(), $r, $g, $b, Editor::gdAlpha($alpha));
imageellipse($image->getCore(), $left, $top, $this->width, $this->height, $borderColorResource);
}
return $image;
}
}