7 class XML_SvgToPDF_Path extends XML_SvgToPDF_Base {
8 var $d; // stores the details of the path..
12 function fromXmlNode($node) {
13 parent::fromXmlNode($node);
14 $d = explode(' ',trim($this->d));
18 while ($i < count($d)) {
20 switch(strtolower($action)) {
26 $data[] = array('L',$d[$i+3],$d[$i+4]);
31 $data[] = array($action,$d[$i+1],$d[$i+2]);
34 case 'h': // move horizontal
35 case 'v': // move horizontal
36 $data[] = array($action,$d[$i+1]);
41 case 'z': // close path..
42 $data[] = array($action);
46 echo "oops found something odd in path? '$action'";
62 function shift($x,$y) {
63 //XML_SvgToPDF::debug('shift');
64 //XML_SvgToPDF::debug(array($x,$y));
65 //XML_SvgToPDF::debug($this);
66 foreach($this->d as $i=>$a) {
71 $this->d[$i][1] -= $y;
73 $this->d[$i][1] -= $x;
74 if (isset($this->d[$i][2])) {
75 $this->d[$i][2] -= $y;
84 function writePDF($pdf,$data) {
86 $l = $this->toColor(@$this->style['stroke']);
88 $pdf->setDrawColor($l[0],$l[1],$l[2]);
90 $pdf->setLineWidth($this->style['stroke-width']/ 3.543307);
94 *Not sure why this was added..
95 if (count($this->d) > 2) {
97 foreach($this->d as $a) {
101 $x = $a[1] + @$this->xx;
102 $y = $a[2] + @$this->yy;
103 $cc[] = $x/ 3.543307;
104 $cc[] = $y/ 3.543307;
106 $pdf->line($cc,0,0,0);
112 foreach($this->d as $a) {
115 $x = $a[1] + @$this->xx;
116 $y = $a[2] + @$this->yy;
121 $x = $a[1] + @$this->xx;
122 $y = $a[2] + @$this->yy;
123 $pdf->line($c[0]/ 3.543307,$c[1]/ 3.543307,$x/ 3.543307,$y/ 3.543307);
140 function toColor($color) {
141 if (!$color || ($color == 'none')) {
145 hexdec(substr($color,1,2)),
146 hexdec(substr($color,3,2)),
147 hexdec(substr($color,5,2)));