DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Rect.h
1 /* -*- mode: c++ -*- */
9 /*
10  * \@copyright This File is part of the Board library which is
11  * licensed under the terms of the GNU Lesser General Public Licence.
12  * See the LICENCE file for further details.
13  */
14 #ifndef _BOARD_RECT_H_
15 #define _BOARD_RECT_H_
16 
17 #include <iostream>
18 #include "Board/Point.h"
19 
20 namespace LibBoard {
21 
26 struct Rect {
27 
28  double left;
29  double top;
30  double width;
31  double height;
43  Rect( double leftX = 0.0f, double topY = 0.0f, double rectWidth = 0.0f, double rectHeight = 0.0f )
44  :left( leftX ), top( topY ), width( rectWidth ), height( rectHeight ) { }
45 
46  Point topLeft() { return Point( left, top ); }
47  Point topRight() { return Point( left + width, top ); }
48  Point bottomLeft() { return Point( left, top - height ); }
49  Point bottomRight() { return Point( left + width, top - height ); }
50 };
51 
60 Rect operator||( const Rect & rectA, const Rect & rectB );
61 
70 Rect operator&&( const Rect & rectA, const Rect & rectB );
71 
72 
73 } // mamespace BoardLib
74 
83 std::ostream & operator<<( std::ostream & out, const LibBoard::Rect & rect );
84 
85 #endif // _RECT_H_