[nostalgia] Rename common package to geo
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<imgui.h>)
|
||||
#include <imgui.h>
|
||||
#endif
|
||||
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
namespace nostalgia::geo {
|
||||
|
||||
struct Vec2 {
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
|
||||
constexpr Vec2() noexcept = default;
|
||||
|
||||
constexpr Vec2(float pX, float pY) noexcept: x(pX), y(pY) {
|
||||
}
|
||||
|
||||
#if __has_include(<imgui.h>)
|
||||
explicit constexpr Vec2(const ImVec2 &v) noexcept: x(v.x), y(v.y) {
|
||||
}
|
||||
#endif
|
||||
|
||||
constexpr auto &operator[](std::size_t i) noexcept {
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
constexpr const auto &operator[](std::size_t i) const noexcept {
|
||||
return (&x)[i];
|
||||
}
|
||||
|
||||
#if __has_include(<imgui.h>)
|
||||
explicit operator ImVec2() const noexcept {
|
||||
return {x, y};
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user