1 #ifndef BLOBS_UI_ALIGN_HPP_
2 #define BLOBS_UI_ALIGN_HPP_
4 #include "../math/glm.hpp"
28 inline Align get_x(Gravity g) noexcept {
29 return Align(int(g) % 3);
32 inline Align get_y(Gravity g) noexcept {
33 return Align(int(g) / 3);
36 inline Gravity get_gravity(Align x, Align y) noexcept {
37 return Gravity(int(y) * 3 + int(x));
40 inline glm::vec2 align(
42 const glm::vec2 &size,
43 const glm::vec2 &offset = glm::vec2(0.0f, 0.0f)
46 size.x * 0.5f * (1 - int(get_x(g))) + offset.x,
47 size.y * 0.5f * (1 - int(get_y(g))) + offset.y
51 inline glm::vec3 align(
53 const glm::vec2 &size,
54 const glm::vec3 &offset
57 size.x * 0.5f * (1 - int(get_x(g))) + offset.x,
58 size.y * 0.5f * (1 - int(get_y(g))) + offset.y,