diff --git a/src/app/script/rectangle_class.cpp b/src/app/script/rectangle_class.cpp index 38611d703..4bca7a300 100644 --- a/src/app/script/rectangle_class.cpp +++ b/src/app/script/rectangle_class.cpp @@ -9,6 +9,7 @@ #endif #include "app/script/luacpp.h" +#include "gfx/point.h" #include "gfx/rect.h" namespace app { @@ -64,6 +65,38 @@ int Rectangle_eq(lua_State* L) return 1; } +int Rectangle_contains(lua_State* L) +{ + const auto a = get_obj(L, 1); + const auto b = get_obj(L, 2); + lua_pushboolean(L, a->contains(*b)); + return 1; +} + +int Rectangle_intersects(lua_State* L) +{ + const auto a = get_obj(L, 1); + const auto b = get_obj(L, 2); + lua_pushboolean(L, a->intersects(*b)); + return 1; +} + +int Rectangle_union(lua_State* L) +{ + const auto a = get_obj(L, 1); + const auto b = get_obj(L, 2); + push_obj(L, a->createUnion(*b)); + return 1; +} + +int Rectangle_intersect(lua_State* L) +{ + const auto a = get_obj(L, 1); + const auto b = get_obj(L, 2); + push_obj(L, a->createIntersection(*b)); + return 1; +} + int Rectangle_get_x(lua_State* L) { const auto rc = get_obj(L, 1); @@ -130,6 +163,10 @@ int Rectangle_get_isEmpty(lua_State* L) const luaL_Reg Rectangle_methods[] = { { "__gc", Rectangle_gc }, { "__eq", Rectangle_eq }, + { "contains", Rectangle_contains }, + { "intersects", Rectangle_intersects }, + { "union", Rectangle_union }, + { "intersect", Rectangle_intersect }, { nullptr, nullptr } };