class_mcSvg.inc.php 1.65 KB
<?php

class mcSvg {
	public static function getGraticuleAsDomElement(DOMElement $param_domelement, $param_x=0, $param_y=0, $param_lenght=10, $param_disableCircleIfSmallAs=false, $param_color='black') {
		$group = new DOMElement('g');
		$group = $param_domelement->appendChild($group);		
		
		if($param_disableCircleIfSmallAs && $param_lenght >= $param_disableCircleIfSmallAs) {
			//	 <circle cx ="40" cy ="40" r ="20" />
				$circle = $group->appendChild(new DOMElement('circle'));									
				$circle->setAttribute('cx', $param_x);
				$circle->setAttribute('cy', $param_y);
				$circle->setAttribute('r', $param_lenght/3);
				$circle->setAttribute('style', 'fill:#FFFFFF; stroke:'.$param_color.'; stroke-width:.01cm;');					
		}

		
		//	<line x1="5" y1="5" x2="200" y2="100" style="stroke:black;stroke-width:3;" />
			$line_vertikal = $group->appendChild(new DOMElement('line'));									
			$line_vertikal->setAttribute('x1', $param_x);
			$line_vertikal->setAttribute('y1', $param_y - ($param_lenght/2));
			$line_vertikal->setAttribute('x2', $param_x);
			$line_vertikal->setAttribute('y2', $param_y + ($param_lenght/2));						
			$line_vertikal->setAttribute('style', 'stroke:'.$param_color.'; stroke-width:.01cm;');					
		
			$line_horizontal = $group->appendChild(new DOMElement('line'));									
			$line_horizontal->setAttribute('x1', $param_x - ($param_lenght/2));
			$line_horizontal->setAttribute('y1', $param_y);
			$line_horizontal->setAttribute('x2', $param_x + ($param_lenght/2));
			$line_horizontal->setAttribute('y2', $param_y);						
			$line_horizontal->setAttribute('style', 'stroke:'.$param_color.'; stroke-width:.01cm;');								
			
		return $group;
	}
}
?>