Board  0.9.2
Rect.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
26 #ifndef _BOARD_RECT_H_
27 #define _BOARD_RECT_H_
28 
29 #include <iostream>
30 #include "board/Point.h"
31 
32 namespace LibBoard {
33 
38 struct Rect {
39  double left;
40  double top;
41  double width;
42  double height;
54  Rect( double left = 0.0f, double top = 0.0f,
55  double width = 0.0f, double height = 0.0f )
56  :left( left ), top( top ), width( width ), height( height ) { }
57 
58  Point topLeft() const { return Point( left, top ); }
59  Point topRight() const { return Point( left + width, top ); }
60  Point bottomLeft() const { return Point( left, top - height ); }
61  Point bottomRight() const { return Point( left + width, top - height ); }
62  Point center() const { return Point(left+width/2.0,top-height/2.0); }
63  double bottom() const { return top - height; }
64  double right() const { return left + width; }
65 };
66 
75 Rect operator||( const Rect & rectA, const Rect & rectB );
76 
85 Rect operator&&( const Rect & rectA, const Rect & rectB );
86 
87 
88 } // mamespace BoardLib
89 
98 std::ostream & operator<<( std::ostream & out, const LibBoard::Rect & rect );
99 
100 #endif // _RECT_H_
Definition: Board.h:40
The Point structure. @copyright This source code is part of the Board project, a C++ library whose pu...
double top
Definition: Rect.h:40
Rect(double left=0.0f, double top=0.0f, double width=0.0f, double height=0.0f)
Definition: Rect.h:54
double left
Definition: Rect.h:39
Struct representing a 2D point.
Definition: Point.h:38
std::ostream & operator<<(std::ostream &out, const LibBoard::Rect &rect)
Definition: Rect.cpp:69
double height
Definition: Rect.h:42
Struct representing a rectangle on the plane.
Definition: Rect.h:38
double width
Definition: Rect.h:41