class_mcSvg.inc.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* @copyright (c) 2014, netz.coop eG
*/
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;
}
}
?>