8#include <entt/locator/locator.hpp>
25 auto& lua = entt::locator<sol::state>::value();
45 auto frect_type = lua.new_usertype<
fRect>(
"fRect", sol::constructors<fRect(), fRect(const float, const float, const float, const float)>());
50 frect_type[
"contains_point"] = sol::resolve<bool(const float, const float) const>(&
fRect::contains);
51 frect_type[
"contains"] = sol::resolve<bool(const fRect&) const>(&
fRect::contains);
61 auto irect_type = lua.new_usertype<
iRect>(
"iRect", sol::constructors<iRect(), iRect(const int, const int, const int, const int)>());
66 irect_type[
"contains_point"] = sol::resolve<bool(const int, const int) const>(&
iRect::contains);
67 irect_type[
"contains"] = sol::resolve<bool(const iRect&) const>(&
iRect::contains);
77 auto rectpack_type = lua.new_usertype<
RectPack>(
"RectPack", sol::constructors<RectPack()>());
Rectangle 2D bin packing class.
const std::vector< iRect > & get_free_space() const noexcept
Get free rectangles.
std::optional< iRect > pack(const int width, const int height)
Pack a rectangle into the master rectangle.
void clear() noexcept
Clear all data.
int get_height() const noexcept
Get total height.
void init(const int width, const int height) noexcept
Set starting width and height of rectangle.
int get_width() const noexcept
Get total width.
bool intersects(const Rect< Type > &b) const noexcept
bool contains(const Type _x, const Type _y) const noexcept
bool overlaps(const Rect< Type > &b) noexcept
void set_top_left(const glm::vec< 2, Type, glm::defaultp > &pos) noexcept
Type get_right() const noexcept
glm::vec< 2, Type, glm::defaultp > get_size() const noexcept
glm::vec< 2, Type, glm::defaultp > get_top_left() const noexcept
Type get_bottom() const noexcept
glm::vec< 2, Type, glm::defaultp > get_center() const noexcept
static std::string decode(const std::string &input)
Decompresses string into ZLib.
static std::string encode(const std::string &input)
Compresses string into ZLib.
void inject_math()
Injects math stuff into Lua.
constexpr std::uint64_t fnv1a_64(const char *const str) noexcept
Convert string to 64bit hash.
std::string encode_base64(const std::string &input)
Compresses string into Base64.
glm::vec3 random_vec3(const glm::vec3 &min, const glm::vec3 &max) noexcept
Generate a random vec3.
float constexpr normalize(const Arithmetic val, const Arithmetic max) noexcept
Calc normalized value from range.
std::string decode_base64(const std::string &input)
Decompresses string into Base64.
glm::vec2 random_vec2(const glm::vec2 &min, const glm::vec2 &max) noexcept
Generate a random vec2.
glm::vec4 random_vec4(const glm::vec4 &min, const glm::vec4 &max) noexcept
Generate a random vec4.
constexpr std::uint32_t fnv1a_32(const char *const str) noexcept
Convert string to 32bit hash.
T random(const T min, const T max) noexcept
Generate a random number of type T.