aboutsummaryrefslogtreecommitdiff
path: root/src/engine/graphics/bounds.cpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-27 17:12:49 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:53 +0200
commitfe79577396231f2edb7927f1f61ce814f03851a7 (patch)
treed353a1caa449ec772dcf9a8681084fc2d6e64116 /src/engine/graphics/bounds.cpp
parent6964d48c970e5f7b11897096c816271785af23ac (diff)
add basic engine graphics
Diffstat (limited to 'src/engine/graphics/bounds.cpp')
-rw-r--r--src/engine/graphics/bounds.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/engine/graphics/bounds.cpp b/src/engine/graphics/bounds.cpp
new file mode 100644
index 0000000..8cb83eb
--- /dev/null
+++ b/src/engine/graphics/bounds.cpp
@@ -0,0 +1,65 @@
+#include "bounds.hpp"
+
+Bounds::Bounds(const IBoundsOptions &options)
+ : _width(options.width), _height(options.height)
+{
+}
+
+unsigned int Bounds::width() const
+{
+ return _width;
+}
+
+void Bounds::width(unsigned int width)
+{
+ _width = width;
+}
+
+unsigned int Bounds::height() const
+{
+ return _height;
+}
+
+void Bounds::height(unsigned int height)
+{
+ _height = height;
+}
+
+CoordsValidation Bounds::validate_coords(const IVector2 &coords) const
+{
+ if (coords.x() >= _width)
+ {
+ return CoordsValidation::X_HIGH;
+ }
+
+ if (coords.y() >= _height)
+ {
+ return CoordsValidation::Y_HIGH;
+ }
+
+ return CoordsValidation::VALID;
+}
+
+const IBounds &Bounds::operator*=(const IBounds &bounds)
+{
+ _width *= bounds.width();
+ _height *= bounds.height();
+
+ return *this;
+}
+
+const IBounds &Bounds::operator+=(const IBounds &bounds)
+{
+ _width += bounds.width();
+ _height += bounds.height();
+
+ return *this;
+}
+
+const IBounds &Bounds::operator-=(const IBounds &bounds)
+{
+ _width -= bounds.width();
+ _height -= bounds.height();
+
+ return *this;
+}