e7ce2295bbef4e0bfa6f53a56bf4d22fef189409
[pear] / XML / SvgToPdf / Rect.php
1 <?php
2
3 /* output a rectangle
4
5 */
6
7 class XML_SvgToPDF_Rect  extends XML_SvgToPDF_Base {
8     
9     var $xx = 0;
10     var $yy = 0;
11     var $nonprintable = false;
12     
13     function writePDF($pdf,$data) {
14         
15         //print_r(array("rect:", $this->x , $this->y , ':', $this->xx, $this->yy));
16         
17         $x =  $this->x   + @$this->xx;
18         $y =  $this->y  + @$this->yy;
19         
20         
21         
22         $pdf->setLineWidth($this->style['stroke-width']); 
23         $f = $this->toColor($this->style['fill']);
24         if ($f) {
25             $pdf->setFillColor($f[0],$f[1],$f[2]);
26         }
27         
28         $l = $this->toColor(@$this->style['stroke']);
29         if ($l) {
30             $pdf->setDrawColor($l[0],$l[1],$l[2]);
31         }
32         // no fill, no line = dont draw...
33         if (!$l && !$f) {
34             return;
35         }
36         XML_SvgToPDF::debug("RECT:" .($x/ 3.543307).',' .($y/ 3.543307). ','
37              .($this->width/ 3.543307).',' . ($this->height/ 3.543307));
38         $pdf->rect($x/ 3.543307,$y/ 3.543307,
39             $this->width/ 3.543307,$this->height/ 3.543307,($l ? 'D' : ''). ($f ? 'F' : ''));
40     
41     
42     
43     }
44
45
46     function toColor($color) {
47         if (!$color || ($color == 'none')) {
48             return false;
49         }
50         return array(
51             hexdec(substr($color,1,2)),
52             hexdec(substr($color,3,2)),
53             hexdec(substr($color,5,2)));
54         
55     }
56
57
58 }