blob: 782fd025e35b7e1c0c013e2a99f7608201dae4fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#include "bounds.hpp"
Bounds::Bounds(BoundsOpts opts) : _width(opts.width), _height(opts.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;
}
void Bounds::verify_coords(const Vector2 &coords) const
{
if (coords.x() >= _width)
{
throw "X coordinate cannot be higher than or equal to bounds width";
}
if (coords.y() >= _height)
{
throw "Y coordinate cannot be higher than or equal to bounds height";
}
}
Bounds Bounds::operator*(const Bounds &bounds) const
{
return Bounds(
{.width = _width * bounds.width(), .height = _height * bounds.height()});
}
Bounds Bounds::operator+(const Bounds &bounds) const
{
return Bounds(
{.width = _width + bounds.width(), .height = _height + bounds.height()});
}
|