FifeGUI 0.2.0
A C++ GUI library designed for games.
rectangle.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_RECTANGLE_HPP_
6#define INCLUDE_FIFECHAN_RECTANGLE_HPP_
7
8#include <iostream>
9
10#include "fifechan/platform.hpp"
11
12namespace fcn
13{
19 class FIFEGUI_API Rectangle
20 {
21 public:
26 Rectangle();
27
36 Rectangle(int x, int y, int width, int height);
37
46 void setAll(int x, int y, int width, int height);
47
54 bool isIntersecting(Rectangle const & rectangle) const;
55
64 bool isContaining(int x, int y) const;
65
73 bool isContaining(Rectangle const & other) const;
74
82 bool isEmpty() const;
83
91 Rectangle operator+(Rectangle const & rh) const;
92
100 Rectangle const & operator+=(Rectangle const & rh);
101
108 Rectangle intersection(Rectangle const & rh) const;
109
116 friend std::ostream& operator<<(std::ostream& out, Rectangle const & rectangle);
117
121 int x;
122
126 int y;
127
131 int width;
132
137 };
138} // namespace fcn
139
140#endif // INCLUDE_FIFECHAN_RECTANGLE_HPP_
friend std::ostream & operator<<(std::ostream &out, Rectangle const &rectangle)
Output operator for output.
Rectangle()
Constructor.
Definition rectangle.cpp:11
bool isContaining(int x, int y) const
Checks the rectangle contains a point.
Definition rectangle.cpp:52
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.
Definition rectangle.cpp:15
Rectangle operator+(Rectangle const &rh) const
Adds a rectangle to this rectangle.
Definition rectangle.cpp:76
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.
Definition rectangle.cpp:89
bool isIntersecting(Rectangle const &rectangle) const
Checks if another rectangle intersects with the rectangle.
Definition rectangle.cpp:23
bool isEmpty() const
Checks whether the rectangle is empty or not.
Definition rectangle.cpp:71