5#include "fifechan/rectangle.hpp"
35 }
else if (x_ + width_ > rectangle.
width) {
36 width_ = rectangle.
width - x_;
41 }
else if (y_ + height_ > rectangle.
height) {
42 height_ = rectangle.
height - y_;
45 if (width_ <= 0 || height_ <= 0) {
82 int const nx =
x < rh.
x ?
x : rh.
x;
83 int const ny =
y < rh.
y ?
y : rh.
y;
86 return {nx, ny, nx2 - nx, ny2 - ny};
100 x =
x < rh.
x ?
x : rh.
x;
101 y =
y < rh.
y ?
y : rh.
y;
111 int const nx =
x > rh.
x ?
x : rh.
x;
112 int const ny =
y > rh.
y ?
y : rh.
y;
115 return {nx, ny, 0, 0};
120 Rectangle result(nx, ny, nx2 - nx, ny2 - ny);
123 return {nx, ny, 0, 0};
131 out <<
"Rectangle [x = " << rectangle.
x <<
", y = " << rectangle.
y <<
", width = " << rectangle.
width
132 <<
", height = " << rectangle.
height <<
"]";
friend std::ostream & operator<<(std::ostream &out, Rectangle const &rectangle)
Output operator for output.
bool isContaining(int x, int y) const
Checks the rectangle contains a point.
int width
Holds the width of the rectangle.
Rectangle intersection(Rectangle const &rh) const
Gets the intersection between two rectangles.
int y
Holds the x coordinate of the rectangle.
void setAll(int x, int y, int width, int height)
Sets the dimension of a rectangle.
Rectangle operator+(Rectangle const &rh) const
Adds a rectangle to this rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.
Rectangle const & operator+=(Rectangle const &rh)
Adds a rectangle to this rectangle.
bool isIntersecting(Rectangle const &rectangle) const
Checks if another rectangle intersects with the rectangle.
bool isEmpty() const
Checks whether the rectangle is empty or not.