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);
16 function fromNode($node) {
17 parent::fromNode($node);
24 $d = explode(' ',trim($this->d));
28 while ($i < count($d)) {
30 switch(strtolower($action)) {
36 $data[] = array('L',$d[$i+3],$d[$i+4]);
41 $data[] = array($action,$d[$i+1],$d[$i+2]);
44 case 'h': // move horizontal
45 case 'v': // move horizontal
46 $data[] = array($action,$d[$i+1]);
51 case 'z': // close path..
52 $data[] = array($action);
56 echo "oops found something odd in path? '$action'";
72 function shift($x,$y) {
73 //XML_SvgToPDF::debug('shift');
74 //XML_SvgToPDF::debug(array($x,$y));
75 //XML_SvgToPDF::debug($this);
76 foreach($this->d as $i=>$a) {
81 $this->d[$i][1] -= $y;
83 $this->d[$i][1] -= $x;
84 if (isset($this->d[$i][2])) {
85 $this->d[$i][2] -= $y;
94 function writePDF($pdf,$data) {
96 $l = $this->toColor(@$this->style['stroke']);
98 $pdf->setDrawColor($l[0],$l[1],$l[2]);
100 $pdf->setLineWidth($this->style['stroke-width']/ 3.543307);
104 *Not sure why this was added..
105 if (count($this->d) > 2) {
107 foreach($this->d as $a) {
111 $x = $a[1] + @$this->xx;
112 $y = $a[2] + @$this->yy;
113 $cc[] = $x/ 3.543307;
114 $cc[] = $y/ 3.543307;
116 $pdf->line($cc,0,0,0);
120 if (!is_array($this->d)) {
124 foreach($this->d as $a) {
127 $x = $a[1] + @$this->xx;
128 $y = $a[2] + @$this->yy;
133 $x = $a[1] + @$this->xx;
134 $y = $a[2] + @$this->yy;
135 $pdf->line($c[0]/ 3.543307,$c[1]/ 3.543307,$x/ 3.543307,$y/ 3.543307);
152 function toColor($color) {
153 if (!$color || ($color == 'none')) {
157 hexdec(substr($color,1,2)),
158 hexdec(substr($color,3,2)),
159 hexdec(substr($color,5,2)));