This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ class SVG { private $paths; private $rects; private $circles; private $ellipses; private $lines; private $polylines; private $texts; private $linearGradients; private $radialGradients; public function __construct() { $this->paths = array(); $this->rects = array(); $this->circles = array(); $this->ellipses = array(); $this->lines = array(); $this->polylines = array(); $this->texts = array(); $this->linearGradients = array(); $this->radialGradients = array(); } public function addPath($path) { $this->paths[] = $path; } public function getPaths() { return $this->paths; } public function addRectangle($rect) { $this->rects[] = $rect; } public function getRectangles() { return $this->rects; } public function addCircle($circle) { $this->circles[] = $circle; } public function getCircles() { return $this->circles; } public function addEllipse($ellipse) { $this->ellipses[] = $ellipse; } public function getEllipses() { return $this->ellipses; } public function addLine($line) { $this->lines[] = $line; } public function getLines() { return $this->lines; } public function addPolyline($polyline) { $this->polylines[] = $polyline; } public function getPolylines() { return $this->polylines; } public function addText($text) { $this->texts[] = $text; } public function getTexts() { return $this->texts; } public function addLinearGradient($gradient) { $this->linearGradients[] = $gradient; } public function getLinearGradients() { return $this->linearGradients; } public function addRadialGradient($gradient) { $this->radialGradients[] = $gradient; } public function getRadialGradients() { return $this->radialGradients; } public function getCompleteLinearGradients() { $validGradients = array(); foreach($this->linearGradients as $gradient) { if ($gradient->isValid()) { $validGradients[] = $gradient; } else if ($gradient->getLink() != null) { $newGradient = $this->linkGradient($gradient); if ($newGradient->isValid()) { $validGradients[] = $newGradient; } } } return $validGradients; } public function getCompleteRadialGradients() { $validGradients = array(); foreach($this->radialGradients as $gradient) { if ($gradient->isValid()) { $validGradients[] = $gradient; } else if ($gradient->getLink() != null) { $newGradient = $this->linkGradient($gradient); if ($newGradient->isValid()) $validGradients[] = $gradient; } } return $validGradients; } private function linkGradient($gradient) { //search through all gradients for one with an id matching the link field $link = $gradient->getLink(); $toLink = null; foreach($this->linearGradients as $match) { if ($match->getId() == $link) { $toLink = $match; break; } } if ($toLink != null) { $gradient->setStops($toLink->getStops()); } return $gradient; } } ?>