. */ /** * For more information, please contact */ namespace Goat1000\SVGGraph; class Image extends Shape { protected $element = 'image'; protected $required = ['src', 'x', 'y']; protected $transform = ['width' => 'x', 'height' => 'y']; protected $transform_from = ['width' => 'x', 'height' => 'y']; protected $transform_pairs = [ ['x', 'y'] ]; protected $attrs = ['preserveAspectRatio' => 'xMinYMin']; /** * Override to draw an image */ protected function drawElement(&$graph, &$attributes) { $attributes['xlink:href'] = $attributes['src']; if(isset($attributes['stretch']) && $attributes['stretch']) $attributes['preserveAspectRatio'] = 'none'; unset($attributes['src'], $attributes['stretch']); return parent::drawElement($graph, $attributes); } }