98 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			98 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
|   | <?php | ||
|  | /* | ||
|  | SVG to dojox.gfx Parser | ||
|  | Copyright (C) 2009  Aaron Lindsay <aclindsay@aclindsay.com> | ||
|  | 
 | ||
|  | 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. | ||
|  | */ | ||
|  | 
 | ||
|  | require_once("objects/Gradient.php"); | ||
|  | 
 | ||
|  | class RadialGradient extends Gradient { | ||
|  | 	private $cx; | ||
|  | 	private $cy; | ||
|  | 	private $r; | ||
|  | 	private $fx; | ||
|  | 	private $fy; | ||
|  | 	 | ||
|  | 	private $transformsApplied = false; | ||
|  | 
 | ||
|  | 	public function __construct() { | ||
|  | 		parent::__construct(); | ||
|  | 	} | ||
|  | 	 | ||
|  | 	public function setCx($x) { | ||
|  | 		$this->cx = $x; | ||
|  | 	} | ||
|  | 	public function setCy($x) { | ||
|  | 		$this->cy = $x; | ||
|  | 	} | ||
|  | 	public function setR($x) { | ||
|  | 		$this->r = $x; | ||
|  | 	} | ||
|  | 	public function setFx($x) { | ||
|  | 		$this->fx = $x; | ||
|  | 	} | ||
|  | 	public function setFy($x) { | ||
|  | 		$this->fy = $x; | ||
|  | 	} | ||
|  | 	 | ||
|  | 	public function getCx() { | ||
|  | 		return $this->cx; | ||
|  | 	} | ||
|  | 	public function getCy() { | ||
|  | 		return $this->cy; | ||
|  | 	} | ||
|  | 	public function getR() { | ||
|  | 		return $this->r; | ||
|  | 	} | ||
|  | 	public function getFx() { | ||
|  | 		return $this->fx; | ||
|  | 	} | ||
|  | 	public function getFy() { | ||
|  | 		return $this->fy; | ||
|  | 	} | ||
|  | 	 | ||
|  | 	public function isValid() { | ||
|  | 		if (!parent::isValid()) | ||
|  | 			return false; | ||
|  | 		if (!isset($this->cx) || !isset($this->cy) || !isset($this->r) || !isset($this->fx)  || !isset($this->fy)) | ||
|  | 			return false; | ||
|  | 		 | ||
|  | 		return true; | ||
|  | 	} | ||
|  | 	 | ||
|  | 	public function transformsApplied() { | ||
|  | 		return $this->transformsApplied; | ||
|  | 	} | ||
|  | 	 | ||
|  | 	//apply all the transforms to the points in this gradient
 | ||
|  | 	public function applyTransforms() { | ||
|  | 		$transforms = $this->getTransforms(); | ||
|  | 		foreach($transforms as $transform) { | ||
|  | 			$oldCx = $this->cx; | ||
|  | 			$oldCy = $this->cy; | ||
|  | 			$oldFx = $this->fx; | ||
|  | 			$oldFy = $this->fy; | ||
|  | 			$this->cx = $transform->applyToX($oldCx, $oldCy); | ||
|  | 			$this->cy = $transform->applyToY($oldCx, $oldCy); | ||
|  | 			$this->fx = $transform->applyToX($oldFx, $oldFy); | ||
|  | 			$this->fy = $transform->applyToY($oldFx, $oldFy); | ||
|  | 		} | ||
|  | 		$this->transformsApplied = true; | ||
|  | 	} | ||
|  | } | ||
|  | ?>
 |