unlogic
Loading...
Searching...
No Matches
Rect.cpp
Go to the documentation of this file.
1#include "Rect.h"
2#include <array>
3
4using namespace unlogic;
5
6Rect::Rect(std::array<glm::vec2, 4> const &corners)
7{
8 this->vertices = {
9 Vertex{corners[0], this->color},
10 Vertex{corners[1], this->color},
11 Vertex{corners[2], this->color},
12 Vertex{corners[2], this->color},
13 Vertex{corners[3], this->color},
14 Vertex{corners[0], this->color},
15 };
16}
17
18Rect::Rect(glm::vec2 const &center, glm::vec2 const &size)
19{
20 std::array<glm::vec2, 4> corners = {
21 glm::vec2{center.x - (size.x / 2), center.y - (size.y / 2)},
22 glm::vec2{center.x + (size.x / 2), center.y - (size.y / 2)},
23 glm::vec2{center.x + (size.x / 2), center.y + (size.y / 2)},
24 glm::vec2{center.x - (size.x / 2), center.y + (size.y / 2)},
25 };
26
27 this->vertices = {
28 Vertex{corners[0], this->color},
29 Vertex{corners[1], this->color},
30 Vertex{corners[2], this->color},
31 Vertex{corners[2], this->color},
32 Vertex{corners[3], this->color},
33 Vertex{corners[0], this->color},
34 };
35}
Rect()=default
std::vector< Vertex > vertices
Definition Shape.h:14
Color color
Definition Shape.h:13