* @package cleversvg * @subpackage elements */ class csImage extends csBaseShape { protected $title = NULL, $xml_node_name = 'image'; /** * Class constructor * * @param mixed $x * @param mixed $y * @param mixed $width * @param mixed $height * @param array $attrs */ public function __construct($x=null, $y=null, $width=null, $height=null, $attrs=array()) { $this->setX($x); $this->setY($y); $this->setWidth($width); $this->setHeight($height); $this->attributes = array_merge($attrs, $this->attributes); } /** * Computes DOMXML Node * * @param boolean $embedded Is SVG element embedded ? * @return DOMElement */ public function compile($embedded=false) { $group_node = parent::compile($embedded); $dom = $this->getDomDocument(); // Add title tag if (!is_null($this->title)) { $node_name = $embedded ? 'svg:title' : 'title'; $title_node = $dom->createElement($node_name, $this->title); $group_node->appendChild($title_node); } return $group_node; } /** * The x-axis coordinate of one corner of the rectangular region into which an * embedded 'svg' element is placed. * */ public function setX($x) { $this->setAttribute('x', $x); } /** * The y-axis coordinate of one corner of the rectangular region into which an * embedded 'svg' element is placed. * */ public function setY($y) { $this->setAttribute('y', $y); } /** * For outermost 'svg' elements, the intrinsic width of the SVG document * fragment. For embedded 'svg' elements, the width of the rectangular * region into which the 'svg' element is placed. * */ public function setWidth($width) { $this->setAttribute('width', $width); } /** * For outermost 'svg' elements, the intrinsic height of the SVG document * fragment. For embedded 'svg' elements, the height of the rectangular * region into which the 'svg' element is placed. * */ public function setHeight($height) { $this->setAttribute('height', $height); } /** * A URI reference. * * @param string $href URI reference */ public function setHref($href) { $this->setAttribute('xlink:href', $href); } /** * Adds a title tag to image tag * * @param string $title Title */ public function setTitle($title) { $this->title = $title; } }