#include <rectangle.h>
Inheritance diagram for rectangle< T >:
Public Member Functions | |
rectangle () | |
rectangle (T x, T y, T width, T height) | |
rectangle (Vector2< T > thePosition, Vector2< T > theSize) | |
void | SetPosition (T x, T y) |
void | SetPosition (const Vector2< T > &newPos) |
void | SetPositionX (T x) |
void | SetPositionY (T y) |
void | SetSize (T sizeX, T sizeY) |
void | SetSizeX (T sizeX) |
void | SetSizeY (T sizeY) |
void | SetSize (Vector2< T > newSize) |
rectangle< T > | GetRectangle () const |
Vector2< T > | GetPosition () const |
T | GetPositionX () const |
T | GetPositionY () const |
Vector2< T > | GetSize () const |
T | GetSizeX () const |
T | GetSizeY () const |
void | Clip (const rectangle &cr) |
bool | Contains (const Vector2< T > p) const |
bool | Contains (const rectangle< T > &r2) const |
bool | Intersect (const rectangle< T > &r2) const |
Vector2< T > | GetTopLeftPoint () const |
Vector2< T > | GetTopRightPoint () const |
Vector2< T > | GetBottomLeftPoint () const |
Vector2< T > | GetBottomRightPoint () const |
bool | IsSizeZero () const |
Protected Attributes | |
Vector2< T > | position |
Vector2< T > | size |
T | Type for position and size of the Rectangle |
Definition at line 36 of file rectangle.h.
Constructor for building a new rectangle.
x | Position among the x axe. | |
y | Position among the y axe. | |
width | Width of the new rectangle. | |
height | Height of the new rectangle. |
Definition at line 59 of file rectangle.h.
rectangle< T >::rectangle | ( | Vector2< T > | thePosition, | |
Vector2< T > | theSize | |||
) | [inline] |
Constructor for building a new rectangle with the position and size specified.
thePosition | Position of the new rectangle. | |
theSize | Size of the new rectangle. |
Definition at line 70 of file rectangle.h.
Clip the current rectangle using an other rectangle.
cr | The rectangle used for clipping |
Definition at line 183 of file rectangle.h.
00183 { 00184 if( !Intersect(cr) ){ 00185 size.x = 0; 00186 size.y = 0; 00187 00188 return; 00189 } 00190 00191 Vector2<T> newPositionBR = GetBottomRightPoint(); 00192 00193 if( position.x < cr.position.x ) 00194 position.x = cr.position.x; 00195 00196 if( position.x > cr.GetBottomRightPoint().x ) 00197 position.x = cr.GetBottomRightPoint().x; 00198 00199 if( position.y < cr.position.y ) 00200 position.y = cr.position.y; 00201 00202 if( position.y > cr.GetBottomRightPoint().y ) 00203 position.y = cr.GetBottomRightPoint().y; 00204 00205 if( newPositionBR.x < cr.position.x ) 00206 newPositionBR.x = cr.position.x; 00207 00208 if( newPositionBR.x > cr.GetBottomRightPoint().x ) 00209 newPositionBR.x = cr.GetBottomRightPoint().x; 00210 00211 if( newPositionBR.y < cr.position.y ) 00212 newPositionBR.y = cr.position.y; 00213 00214 if( newPositionBR.y > cr.GetBottomRightPoint().y ) 00215 newPositionBR.y = cr.GetBottomRightPoint().y; 00216 00217 size = newPositionBR - position + 1 ; 00218 assert( cr.Contains( *this ) ); 00219 }
Here is the caller graph for this function:
Return true if r2 is contained in the current rectangle.
r2 | The rectangle for witch the check if performed. |
Definition at line 239 of file rectangle.h.
00239 { 00240 if( r2.IsSizeZero() ) 00241 return false; 00242 00243 return Contains( r2.GetTopLeftPoint() ) && 00244 Contains( r2.GetBottomRightPoint() ); 00245 }
Return true if the point p is contained in the rectangle.
p | Point used to perform the check. |
Definition at line 226 of file rectangle.h.
00226 { 00227 if( IsSizeZero() ) 00228 return false; 00229 00230 return p >= GetTopLeftPoint() && 00231 p <= GetBottomRightPoint(); 00232 }
Here is the caller graph for this function:
Return the point in the bottom left corner of the rectangle.
If the rectangle has a size of zero, this point doesn't exist, so the program crash with a failled assertion.
Definition at line 301 of file rectangle.h.
00301 { 00302 assert( !IsSizeZero() ); 00303 Vector2<T> r = position; 00304 00305 r.y += size.y - 1; 00306 00307 return r; 00308 }
Return the point in the top left corner of the rectangle.
If the rectangle has a size of zero, this point doesn't exist, so the program crash with a failled assertion.
Definition at line 315 of file rectangle.h.
00315 { 00316 assert( !IsSizeZero() ); 00317 return position + size - 1; 00318 }
Here is the caller graph for this function:
Return the position of the rectangle.
Definition at line 151 of file rectangle.h.
00151 { 00152 return position; 00153 }
Here is the caller graph for this function:
T rectangle< T >::GetPositionX | ( | ) | const [inline] |
Definition at line 155 of file rectangle.h.
00155 { 00156 return position.x; 00157 }
Here is the caller graph for this function:
T rectangle< T >::GetPositionY | ( | ) | const [inline] |
Definition at line 159 of file rectangle.h.
00159 { 00160 return position.y; 00161 }
Here is the caller graph for this function:
Return the size of the rectangle.
Definition at line 166 of file rectangle.h.
00166 { 00167 return size; 00168 }
Here is the caller graph for this function:
T rectangle< T >::GetSizeX | ( | ) | const [inline] |
Definition at line 170 of file rectangle.h.
00170 { 00171 return size.x; 00172 }
Here is the caller graph for this function:
T rectangle< T >::GetSizeY | ( | ) | const [inline] |
Definition at line 174 of file rectangle.h.
00174 { 00175 return size.y; 00176 }
Here is the caller graph for this function:
Return the point in the top left corner of the rectangle.
If the rectangle has a size of zero, this point doesn't exist, so the program crash with a failled assertion.
Definition at line 275 of file rectangle.h.
00275 { 00276 assert( !IsSizeZero() ); 00277 return position; 00278 }
Here is the caller graph for this function:
Return the point in the top right corner of the rectangle.
If the rectangle has a size of zero, this point doesn't exist, so the program crash with a failled assertion.
Definition at line 286 of file rectangle.h.
00286 { 00287 assert( !IsSizeZero() ); 00288 Vector2<T> r = position; 00289 00290 r.x += size.x - 1; 00291 00292 return r; 00293 }
Return true if there is an intersection between the current rectangle and the r2 rectangle.
r2 | The second rectangle. |
Definition at line 253 of file rectangle.h.
00253 { 00254 if( IsSizeZero() || r2.IsSizeZero() ) 00255 return false; 00256 00257 Vector2<T> r1BR = GetBottomRightPoint(); 00258 Vector2<T> r2BR = r2.GetBottomRightPoint(); 00259 Vector2<T> r1TL = GetTopLeftPoint(); 00260 Vector2<T> r2TL = r2.GetTopLeftPoint(); 00261 00262 if( r1BR.x < r2TL.x || r1BR.y < r2TL.y || 00263 r2BR.x < r1TL.x || r2BR.y < r1TL.y ) 00264 return false; 00265 00266 return true; 00267 }
Here is the caller graph for this function:
bool rectangle< T >::IsSizeZero | ( | ) | const [inline] |
Return true if the rectangle has a size of zero.
Definition at line 323 of file rectangle.h.
Here is the caller graph for this function:
Change the position of the rectangle.
newPos | The new position of the rectangle. |
Definition at line 90 of file rectangle.h.
00090 { 00091 position = newPos; 00092 }
void rectangle< T >::SetPosition | ( | T | x, | |
T | y | |||
) | [inline] |
Set the position of the rectangle.
x | New X position. | |
y | New Y position. |
Definition at line 81 of file rectangle.h.
00081 { 00082 position.SetValues(x, y); 00083 }
Here is the caller graph for this function:
void rectangle< T >::SetPositionX | ( | T | x | ) | [inline] |
Change the x position of the rectangle.
x | New X position. |
Definition at line 99 of file rectangle.h.
00099 { 00100 position.x = x; 00101 }
Here is the caller graph for this function:
void rectangle< T >::SetPositionY | ( | T | y | ) | [inline] |
Change the y position of the rectangle.
y | New Y position. |
Definition at line 108 of file rectangle.h.
00108 { 00109 position.y = y; 00110 }
Here is the caller graph for this function:
void rectangle< T >::SetSize | ( | T | sizeX, | |
T | sizeY | |||
) | [inline] |
Set the size of the rectangle.
sizeX | new size among the x axe. | |
sizeY | new size among the y axe. |
Definition at line 118 of file rectangle.h.
00118 { 00119 size.SetValues(sizeX, sizeY); 00120 }
Here is the caller graph for this function:
void rectangle< T >::SetSizeX | ( | T | sizeX | ) | [inline] |
Change the X size of the rectangle.
x | New size among x axe. |
Definition at line 127 of file rectangle.h.
00127 { 00128 size.x = sizeX; 00129 }
Here is the caller graph for this function:
void rectangle< T >::SetSizeY | ( | T | sizeY | ) | [inline] |
Change the Y size of the rectangle.
y | New size among y axe. |
Definition at line 136 of file rectangle.h.
00136 { 00137 size.y = sizeY; 00138 }
Here is the caller graph for this function:
Position of the rectangle.
Definition at line 40 of file rectangle.h.
Size of the rectangle.
Definition at line 42 of file rectangle.h.