root/cleversvg/trunk/elements/csRect.class.php

Revision 318, 2.1 kB (checked in by nperriault, 11 months ago)

refs #41 - classes autoloading

  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 /**
3  * SVG Rectangle class
4  *
5  * @author     Nicolas Perriault <nperriault@gmail.com>
6  * @package    cleversvg
7  * @subpackage elements
8  */
9 class csRect extends csBaseShape
10 {
11
12   protected
13     $xml_node_name = 'rect';
14
15   /**
16    * Class constructor
17    *
18    * @param  mixed  $x
19    * @param  mixed  $y
20    * @param  mixed  $width
21    * @param  mixed  $height
22    * @param  array  $attrs
23    */
24   public function __construct($x=null, $y=null, $width=null, $height=null, $attrs=array())
25   {
26     $this->setX($x);
27     $this->setY($y);
28     $this->setWidth($width);
29     $this->setHeight($height);
30     $this->attributes = array_merge($attrs, $this->attributes);
31   }
32  
33   /**
34    * The x-axis coordinate of one corner of the rectangular region into which an
35    * embedded 'svg' element is placed.
36    *
37    */
38   public function setX($x)
39   {
40     $this->setAttribute('x', $x);
41   }
42  
43   /**
44    * The y-axis coordinate of one corner of the rectangular region into which an
45    * embedded 'svg' element is placed.
46    *
47    */
48   public function setY($y)
49   {
50     $this->setAttribute('y', $y);
51   }
52  
53   /**
54    * For outermost 'svg'  elements, the intrinsic width of the SVG document
55    * fragment. For embedded 'svg'  elements, the width of the rectangular
56    * region into which the 'svg' element is placed.
57    *
58    */
59   public function setWidth($width)
60   {
61     $this->setAttribute('width', $width);
62   }
63  
64   /**
65    * For outermost 'svg'  elements, the intrinsic height of the SVG document
66    * fragment. For embedded 'svg' elements, the height of the rectangular
67    * region into which the 'svg' element is placed.
68    *
69    */
70   public function setHeight($height)
71   {
72     $this->setAttribute('height', $height);
73   }
74  
75   /**
76    * Sets the radius of the corners
77    *
78    * @param  int  $radius
79    */
80   public function setRadius($radius)
81   {
82     $this->setAttribute('rx', $radius);
83     $this->setAttribute('ry', $radius);
84   }
85  
86   /**
87    * Sets the x-radius
88    *
89    * @param  int $rx
90    */
91   public function setRx($rx)
92   {
93     $this->setAttribute('rx', $rx);
94   }
95  
96   /**
97    * Sets the y-radius
98    *
99    * @param  int $ry
100    */
101   public function setRy($ry)
102   {
103     $this->setAttribute('ry', $ry);
104   }
105  
106 }
107
Note: See TracBrowser for help on using the browser.