aboutsummaryrefslogtreecommitdiff
path: root/include/mglpp/system/FloatRect.hpp
blob: e187b50860df6dc8ec79792b17801c7de7d2d1b7 (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
#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 */