1 | <?php |
||
13 | class Box |
||
14 | { |
||
15 | /** |
||
16 | * @var float |
||
17 | * @JMS\Type("float") |
||
18 | */ |
||
19 | protected $x; |
||
20 | |||
21 | /** |
||
22 | * @var float |
||
23 | * @JMS\Type("float") |
||
24 | */ |
||
25 | protected $y; |
||
26 | |||
27 | /** |
||
28 | * @var float |
||
29 | * @JMS\Type("float") |
||
30 | */ |
||
31 | protected $width; |
||
32 | |||
33 | /** |
||
34 | * @var float |
||
35 | * @JMS\Type("float") |
||
36 | */ |
||
37 | protected $height; |
||
38 | |||
39 | /** |
||
40 | * @var float |
||
41 | * @JMS\Exclude() |
||
42 | */ |
||
43 | protected $top; |
||
44 | |||
45 | /** |
||
46 | * @var float |
||
47 | * @JMS\Exclude() |
||
48 | */ |
||
49 | protected $bottom; |
||
50 | |||
51 | /** |
||
52 | * @var float |
||
53 | * @JMS\Exclude() |
||
54 | */ |
||
55 | protected $left; |
||
56 | |||
57 | /** |
||
58 | * @var float |
||
59 | * @JMS\Exclude() |
||
60 | */ |
||
61 | protected $right; |
||
62 | |||
63 | 29 | public function __construct($x, $y, $width, $height) |
|
72 | |||
73 | 1 | public static function constructFromImagine(PointInterface $point, BoxInterface $box) |
|
77 | |||
78 | 29 | public function update() |
|
85 | |||
86 | /** |
||
87 | * Detect box collision |
||
88 | * This algorithm only works with Axis-Aligned boxes! |
||
89 | * @param Box $box The other rectangle to test collision with |
||
90 | * @return boolean True is the boxes collide, false otherwise |
||
91 | */ |
||
92 | 12 | public function intersects(Box $box) |
|
100 | |||
101 | /** |
||
102 | * @param Box $box |
||
103 | * @return bool |
||
104 | */ |
||
105 | 5 | public function inside(Box $box) |
|
113 | |||
114 | /** |
||
115 | * @param float $deltaX |
||
116 | * @param float $deltaY |
||
117 | * @return \SixtyNine\Cloud\Model\Box |
||
118 | */ |
||
119 | 5 | public function move($deltaX, $deltaY) |
|
123 | |||
124 | public function resize($count) |
||
133 | |||
134 | /** |
||
135 | * @return float |
||
136 | */ |
||
137 | 10 | public function getBottom() |
|
141 | |||
142 | /** |
||
143 | * @return float |
||
144 | */ |
||
145 | 25 | public function getHeight() |
|
149 | |||
150 | /** |
||
151 | * @return float |
||
152 | */ |
||
153 | 12 | public function getLeft() |
|
157 | |||
158 | /** |
||
159 | * @return float |
||
160 | */ |
||
161 | 12 | public function getRight() |
|
165 | |||
166 | /** |
||
167 | * @return float |
||
168 | */ |
||
169 | 10 | public function getTop() |
|
173 | |||
174 | /** |
||
175 | * @return float |
||
176 | */ |
||
177 | 25 | public function getWidth() |
|
181 | |||
182 | /** |
||
183 | * @return float |
||
184 | */ |
||
185 | 22 | public function getX() |
|
189 | |||
190 | /** |
||
191 | * @return float |
||
192 | */ |
||
193 | 22 | public function getY() |
|
197 | |||
198 | /** |
||
199 | * @return Point |
||
200 | */ |
||
201 | 1 | public function getPosition() |
|
205 | |||
206 | /** |
||
207 | * @return \Imagine\Image\Box |
||
208 | */ |
||
209 | 5 | public function getDimensions() |
|
213 | |||
214 | 5 | function __toString() |
|
218 | } |
||
219 | |||
220 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.