blip  0.1
Rectangle.hpp
Go to the documentation of this file.
1 #ifndef __blip_Rectangle_hpp
2 #define __blip_Rectangle_hpp
3 
4 #include <blip/Blip.hpp>
5 
6 namespace blip {
7 
12 class Rectangle
13 {
14  public:
15 
19  Rectangle() throw();
20 
28  Rectangle(int x, int y, int width, int height) throw();
29 
31  ~Rectangle() throw();
32 
40  void reshape(int x, int y, int width, int height) throw();
41 
45  void merge(const Rectangle& other) throw();
46 
48  bool intersects(const Rectangle& other) const throw();
49 
54  void clip(const Rectangle& other) throw();
55 
57  bool contains(const Rectangle& other) const throw();
58 
60  inline bool isEmpty() const throw()
61  { return((_width == 0) || (_height == 0)); }
62 
64  inline int getX() const throw()
65  { return(_x); }
66 
68  inline int getY() const throw()
69  { return(_y); }
70 
72  inline int getWidth() const throw()
73  { return(_width); }
74 
76  inline int getHeight() const throw()
77  { return(_height); }
78 
79  private:
80 
81  int _x;
82  int _y;
83  int _width;
84  int _height;
85  int _xm;
86  int _ym;
87 };
88 
89 } // namespace blip
90 
91 #endif // __blip_Rectangle_hpp
int getHeight() const
Get the rectangle&#39;s height.
Definition: Rectangle.hpp:76
~Rectangle()
Destructor.
Definition: Rectangle.cpp:36
Rectangle()
Construct a new Rectangle of zero size and upper-left corner located at the origin.
Definition: Rectangle.cpp:10
bool isEmpty() const
Test if the rectangle is empty, i.e., has zero width and/or height.
Definition: Rectangle.hpp:60
void merge(const Rectangle &other)
Reshape this rectangle such that it contains both its original shape and the shape of another rectang...
Definition: Rectangle.cpp:56
void reshape(int x, int y, int width, int height)
Change the shape of the rectangle.
Definition: Rectangle.cpp:43
int getY() const
Get the Y-coordinate of the rectangle&#39;s upper-left corner.
Definition: Rectangle.hpp:68
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
A rectangle in cartesian space.
Definition: Rectangle.hpp:12
int getX() const
Get the X-coordinate of the rectangle&#39;s upper-left corner.
Definition: Rectangle.hpp:64
bool intersects(const Rectangle &other) const
Test if this rectangle intersects another rectangle.
Definition: Rectangle.cpp:73
int getWidth() const
Get the rectangle&#39;s width.
Definition: Rectangle.hpp:72
void clip(const Rectangle &other)
If this rectangle intersects another, reshape it such that it consists only of the intersection of th...
Definition: Rectangle.cpp:82
bool contains(const Rectangle &other) const
Test if this rectangle completely contains another rectangle.
Definition: Rectangle.cpp:99