composer package updates
[openemr.git] / vendor / phenx / php-svg-lib / src / Svg / Tag / Image.php
blobf356b28de0ca8257c4da5c216084823647dab3a1
1 <?php
2 /**
3 * @package php-svg-lib
4 * @link http://github.com/PhenX/php-svg-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license GNU LGPLv3+ http://www.gnu.org/copyleft/lesser.html
7 */
9 namespace Svg\Tag;
11 class Image extends AbstractTag
13 protected $x = 0;
14 protected $y = 0;
15 protected $width = 0;
16 protected $height = 0;
17 protected $href = null;
19 protected function before($attributes)
21 parent::before($attributes);
23 $surface = $this->document->getSurface();
24 $surface->save();
26 $this->applyTransform($attributes);
29 public function start($attributes)
31 $document = $this->document;
32 $height = $this->document->getHeight();
33 $this->y = $height;
35 if (isset($attributes['x'])) {
36 $this->x = $attributes['x'];
38 if (isset($attributes['y'])) {
39 $this->y = $height - $attributes['y'];
42 if (isset($attributes['width'])) {
43 $this->width = $attributes['width'];
45 if (isset($attributes['height'])) {
46 $this->height = $attributes['height'];
49 if (isset($attributes['xlink:href'])) {
50 $this->href = $attributes['xlink:href'];
53 $document->getSurface()->transform(1, 0, 0, -1, 0, $height);
55 $document->getSurface()->drawImage($this->href, $this->x, $this->y, $this->width, $this->height);
58 protected function after()
60 $this->document->getSurface()->restore();