Completed
Push — master ( 1f6ac0...60e18b )
by Edgar
16:30
created

Ellipse::getBoundingBox()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
namespace nstdio\svg\shape;
3
4
use nstdio\svg\ElementInterface;
5
6
/**
7
 * Class Ellipse
8
 * The 'ellipse' element defines an ellipse which is axis-aligned with the current user coordinate system based on a
9
 * center point and two radii.
10
 *
11
 * @link    https://www.w3.org/TR/SVG11/shapes.html#EllipseElement
12
 *
13
 * @property float rx
14
 * @property float $ry
15
 *
16
 * @package nstdio\svg\shape
17
 * @author  Edgar Asatryan <[email protected]>
18
 */
19
class Ellipse extends RoundedShape
20
{
21
    public function __construct(ElementInterface $parent, $cx, $cy, $rx, $ry)
22
    {
23
        parent::__construct($parent, $cx, $cy);
24
25
        $this->rx = $rx;
26
        $this->ry = $ry;
27
    }
28
29
    public function getName()
30
    {
31
        return 'ellipse';
32
    }
33
34
    public function getBoundingBox()
35
    {
36
        return [
37
            'width' => 2 * $this->rx,
38
            'height' => 2 * $this->ry,
39
            'x' => abs($this->cx - $this->rx),
40
            'y' => abs($this->cy - $this->ry),
41
        ];
42
    }
43
}