See Release Notes
Long Term Support Release
1 <?php namespace RedeyeVentures\GeoPattern; 2 3 use RedeyeVentures\GeoPattern\SVGElements\Group; 4 use RedeyeVentures\GeoPattern\SVGElements\Polyline; 5 use RedeyeVentures\GeoPattern\SVGElements\Rectangle; 6 use RedeyeVentures\GeoPattern\SVGElements\Circle; 7 use RedeyeVentures\GeoPattern\SVGElements\Path; 8 9 class SVG { 10 11 protected $width; 12 protected $height; 13 protected $svgString; 14 15 function __construct($options=array()) 16 { 17 $this->width = 100; 18 $this->height = 100; 19 $this->svgString = ''; 20 } 21 22 public function setWidth($width) 23 { 24 $this->width = floor($width); 25 return $this; 26 } 27 28 public function setHeight($height) 29 { 30 $this->height = floor($height); 31 return $this; 32 } 33 34 protected function getSvgHeader() 35 { 36 return "<?xml version=\"1.0\"?><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\">"; 37 } 38 39 protected function getSvgFooter() 40 { 41 return '</svg>'; 42 } 43 44 public function addRectangle($x, $y, $width, $height, $args=array()) 45 { 46 $rectangle = new Rectangle($x, $y, $width, $height, $args); 47 $this->svgString .= $rectangle; 48 return $this; 49 } 50 51 public function addCircle($cx, $cy, $r, $args=array()) 52 { 53 $circle = new Circle($cx, $cy, $r, $args); 54 $this->svgString .= $circle; 55 return $this; 56 } 57 58 public function addPath($d, $args=array()) 59 { 60 $path = new Path($d, $args); 61 $this->svgString .= $path; 62 return $this; 63 } 64 65 public function addPolyline($points, $args=array()) 66 { 67 $polyline = new Polyline($points, $args); 68 $this->svgString .= $polyline; 69 return $this; 70 } 71 72 public function addGroup($group, $args=array()) 73 { 74 if ($group instanceof Group) 75 { 76 $group->setArgs($args); 77 $this->svgString .= $group; 78 return $this; 79 } 80 throw new \InvalidArgumentException("The group provided is not a valid instance of Group."); 81 } 82 83 public function getString() 84 { 85 return $this->getSvgHeader().$this->svgString.$this->getSvgFooter(); 86 } 87 88 public function __toString() 89 { 90 return $this->getString(); 91 } 92 93 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body