. */ /** * For more information, please contact */ namespace Goat1000\SVGGraph; class MarkerShape extends Shape { protected $element = 'use'; protected $required = ['type', 'x', 'y']; protected $transform = ['size' => 'y']; protected $transform_from = ['size' => 'y']; protected $transform_pairs = [ ['x', 'y'] ]; /** * Override to draw a marker */ protected function drawElement(&$graph, &$attributes) { $markers = new Markers($graph); $size = isset($attributes['size']) ? $attributes['size'] : 10; $stroke_width = isset($attributes['stroke-width']) ? $attributes['stroke-width'] : 1; $opacity = isset($attributes['opacity']) ? $attributes['opacity'] : 1; $angle = isset($attributes['angle']) ? $attributes['angle'] : 0; $id = $markers->create($attributes['type'], $size, $attributes['fill'], $stroke_width, $attributes['stroke'], $opacity, $angle); $remove = ['type', 'size', 'fill', 'stroke', 'stroke-width', 'opacity', 'angle']; $use = $attributes; foreach($remove as $key) { unset($use[$key]); } // clip-path must be applied to to prevent being offset with if(isset($use['clip-path'])) { $group = ['clip-path' => $use['clip-path']]; unset($use['clip-path']); $e = $graph->element('g', $group, null, $graph->defs->useSymbol($id, $use)); } else { $e = $graph->defs->useSymbol($id, $use); } return $e; } }