aboutsummaryrefslogtreecommitdiff
path: root/include/mglpp/system/FloatRect.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mglpp/system/FloatRect.hpp')
-rw-r--r--include/mglpp/system/FloatRect.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/mglpp/system/FloatRect.hpp b/include/mglpp/system/FloatRect.hpp
new file mode 100644
index 0000000..e187b50
--- /dev/null
+++ b/include/mglpp/system/FloatRect.hpp
@@ -0,0 +1,26 @@
+#ifndef MGLPP_FLOAT_RECT_HPP
+#define MGLPP_FLOAT_RECT_HPP
+
+#include "../system/vec.hpp"
+
+namespace mgl {
+ template <typename T>
+ class Rect {
+ public:
+ Rect() : position(0.0f, 0.0f), size(0.0f, 0.0f) {}
+ Rect(const vec2<T>& position, const vec2<T>& size) : position(position), size(size) {}
+
+ bool contains(const vec2<T>& point) const {
+ return point.x >= position.x && point.x <= position.x + size.x
+ && point.y >= position.y && point.y <= position.y + size.y;
+ }
+
+ vec2<T> position;
+ vec2<T> size;
+ };
+
+ typedef Rect<int> IntRect;
+ typedef Rect<float> FloatRect;
+}
+
+#endif /* MGLPP_FLOAT_RECT_HPP */