7 class XML_SvgToPDFAlt_Path extends XML_SvgToPDFAlt_Base {
9 function fromNode($node) {
10 parent::fromNode($node);
11 $d = explode(' ',trim($this->d));
15 while ($i < count($d)) {
17 switch(strtolower($action)) {
23 $data[] = array('L',$d[$i+3],$d[$i+4]);
28 $data[] = array($action,$d[$i+1],$d[$i+2]);
31 case 'h': // move horizontal
32 case 'v': // move horizontal
33 $data[] = array($action,$d[$i+1]);
38 case 'z': // close path..
39 $data[] = array($action);
43 echo "oops found something odd in path? '$action'";
59 function shift($x,$y) {
60 //XML_SvgToPDF::debug('shift');
61 //XML_SvgToPDF::debug(array($x,$y));
62 //XML_SvgToPDF::debug($this);
63 foreach($this->d as $i=>$a) {
68 $this->d[$i][1] -= $y;
70 $this->d[$i][1] -= $x;
71 if (isset($this->d[$i][2])) {
72 $this->d[$i][2] -= $y;
81 function writePDF($pdf,$data) {
83 $l = $this->toColor(@$this->style['stroke']);
85 $pdf->setDrawColor($l[0],$l[1],$l[2]);
87 $pdf->setLineWidth($this->style['stroke-width']/ 3.543307);
90 if (count($this->d) > 2) {
92 foreach($this->d as $a) {
96 $x = $a[1] + @$this->xx;
97 $y = $a[2] + @$this->yy;
101 $pdf->line($cc,0,0,0);
105 foreach($this->d as $a) {
108 $x = $a[1] + @$this->xx;
109 $y = $a[2] + @$this->yy;
114 $x = $a[1] + @$this->xx;
115 $y = $a[2] + @$this->yy;
116 $pdf->line($c[0]/ 3.543307,$c[1]/ 3.543307,$x/ 3.543307,$y/ 3.543307);
133 function toColor($color) {
134 if (!$color || ($color == 'none')) {
138 hexdec(substr($color,1,2)),
139 hexdec(substr($color,3,2)),
140 hexdec(substr($color,5,2)));