Pop\Image\Gd::drawEllipse PHP Метод

drawEllipse() публичный Метод

Method to add an ellipse to the image.
public drawEllipse ( integer $x, integer $y, integer $w, integer $h = null ) : Gd
$x integer
$y integer
$w integer
$h integer
Результат Gd
    public function drawEllipse($x, $y, $w, $h = null)
    {
        $wid = $w * 2;
        $hgt = (null === $h ? $w : $h) * 2;
        // Create an image resource.
        $this->createResource();
        // Create stroke, if applicable.
        if (null !== $this->strokeColor) {
            $stroke = $this->setColor($this->strokeColor);
            if (null === $this->strokeWidth) {
                $this->strokeWidth = 1;
            }
            imagefilledellipse($this->resource, $x, $y, $wid + $this->strokeWidth, $hgt + $this->strokeWidth, $stroke);
        }
        // Set fill color and create ellipse.
        if (null === $this->fillColor && null === $this->backgroundColor) {
            $fill = $this->setColor(new Rgb(255, 255, 255));
        } else {
            if (null === $this->fillColor) {
                $fill = $this->setColor($this->backgroundColor);
            } else {
                $fill = $this->setColor($this->fillColor);
            }
        }
        imagefilledellipse($this->resource, $x, $y, $wid, $hgt, $fill);
        $this->output = $this->resource;
        return $this;
    }

Usage Example

Пример #1
0
 public function testAddEllipse()
 {
     $i = new Gd(__DIR__ . '/../tmp/test.jpg');
     $i->setStrokeColor(new Rgb(0, 0, 0))->drawEllipse(10, 10, 100, 100);
     $i->setBackgroundColor(new Rgb(255, 0, 0));
     $i->drawEllipse(10, 10, 100, 100);
     $i->setFillColor(new Rgb(255, 0, 0));
     $i->drawEllipse(10, 10, 100, 100);
     $this->assertEquals(640, $i->getWidth());
 }