graphics
parent
9b1c1a1bb1
commit
ebcdbeb172
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
include(FetchContent)
|
||||
|
||||
set(BLT_GRAPHICS_VERSION 2.0.8)
|
||||
set(BLT_GRAPHICS_VERSION 2.0.9)
|
||||
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||
|
||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||
|
|
|
@ -32,11 +32,29 @@
|
|||
|
||||
namespace blt::gfx
|
||||
{
|
||||
enum class anchor_t
|
||||
{
|
||||
TOP_LEFT,
|
||||
TOP_RIGHT,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
CENTER, };
|
||||
|
||||
struct rectangle2d_t
|
||||
{
|
||||
vec2f pos, size;
|
||||
f32 rotation = 0;
|
||||
|
||||
rectangle2d_t(const anchor_t anchor, const f32 x, const f32 y, const f32 width, const f32 height): pos(x, y), size(width, height)
|
||||
{
|
||||
update_based_on_anchor(anchor);
|
||||
}
|
||||
|
||||
rectangle2d_t(const anchor_t anchor, const vec2f pos, const vec2f size): pos(pos), size(size)
|
||||
{
|
||||
update_based_on_anchor(anchor);
|
||||
}
|
||||
|
||||
rectangle2d_t(const f32 x, const f32 y, const f32 width, const f32 height, const f32 rotation): pos(x, y), size(width, height),
|
||||
rotation(rotation)
|
||||
{}
|
||||
|
@ -49,6 +67,29 @@ namespace blt::gfx
|
|||
|
||||
rectangle2d_t(const vec2f pos, const vec2f size): pos(pos), size(size)
|
||||
{}
|
||||
|
||||
void update_based_on_anchor(const anchor_t anchor)
|
||||
{
|
||||
switch (anchor)
|
||||
{
|
||||
case anchor_t::TOP_LEFT:
|
||||
pos += vec2f(size.x() / 2.0f, -size.y() / 2.0f);
|
||||
break;
|
||||
case anchor_t::TOP_RIGHT:
|
||||
pos += vec2f(-size.x() / 2.0f, -size.y() / 2.0f);
|
||||
break;
|
||||
case anchor_t::BOTTOM_LEFT:
|
||||
// size = vec2f(size.x() / 2.0f, size.y() / 2.0f);
|
||||
pos += vec2f(size.x() / 2.0f, size.y() / 2.0f);
|
||||
|
||||
break;
|
||||
case anchor_t::BOTTOM_RIGHT:
|
||||
pos += vec2f(-size.x() / 2.0f, size.y() / 2.0f);
|
||||
break;
|
||||
case anchor_t::CENTER:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct line2d_t
|
||||
|
|
Loading…
Reference in New Issue