aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/Rectangle.cpp
blob: 179d6ee674d7dce313b8403d2d908aa2ebce2d4d (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
#include "../../include/mglpp/graphics/Rectangle.hpp"

extern "C" {
#include <mgl/mgl.h>
}

namespace mgl {
    Rectangle::Rectangle() : Rectangle(vec2f(0.0f, 0.0f), vec2f(0.0f, 0.0f)) {}

    Rectangle::Rectangle(vec2f size) : Rectangle(vec2f(0.0f, 0.0f), size) {}

    Rectangle::Rectangle(vec2f position, vec2f size) {
        rectangle.color = { 255, 255, 255, 255 };
        rectangle.position = { position.x, position.y };
        rectangle.size = { size.x, size.y };
    }

    void Rectangle::set_position(vec2f position) {
        rectangle.position = { position.x, position.y };
    }

    void Rectangle::set_color(Color color) {
        rectangle.color = { color.r, color.g, color.b, color.a };
    }

    vec2f Rectangle::get_position() const {
        return { rectangle.position.x, rectangle.position.y };
    }

    void Rectangle::set_size(vec2f size) {
        rectangle.size = { size.x, size.y };
    }

    vec2f Rectangle::get_size() const {
        return { rectangle.size.x, rectangle.size.y };
    }

    void Rectangle::draw(Window&) {
        mgl_rectangle_draw(mgl_get_context(), &rectangle);
    }
}