[nostalgia] Rename common package to geo

This commit is contained in:
2022-02-13 04:03:10 -06:00
parent 0aa71f1dbb
commit 320df614a9
26 changed files with 131 additions and 130 deletions
+44
View File
@@ -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
};
}