mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-23 18:39:55 +00:00
lua: add Rectangle:contains/union/intersect(s) functions
This commit is contained in:
parent
76718f59d5
commit
7f68d5f2e8
@ -9,6 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "app/script/luacpp.h"
|
#include "app/script/luacpp.h"
|
||||||
|
#include "gfx/point.h"
|
||||||
#include "gfx/rect.h"
|
#include "gfx/rect.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
@ -64,6 +65,38 @@ int Rectangle_eq(lua_State* L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Rectangle_contains(lua_State* L)
|
||||||
|
{
|
||||||
|
const auto a = get_obj<gfx::Rect>(L, 1);
|
||||||
|
const auto b = get_obj<gfx::Rect>(L, 2);
|
||||||
|
lua_pushboolean(L, a->contains(*b));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Rectangle_intersects(lua_State* L)
|
||||||
|
{
|
||||||
|
const auto a = get_obj<gfx::Rect>(L, 1);
|
||||||
|
const auto b = get_obj<gfx::Rect>(L, 2);
|
||||||
|
lua_pushboolean(L, a->intersects(*b));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Rectangle_union(lua_State* L)
|
||||||
|
{
|
||||||
|
const auto a = get_obj<gfx::Rect>(L, 1);
|
||||||
|
const auto b = get_obj<gfx::Rect>(L, 2);
|
||||||
|
push_obj(L, a->createUnion(*b));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Rectangle_intersect(lua_State* L)
|
||||||
|
{
|
||||||
|
const auto a = get_obj<gfx::Rect>(L, 1);
|
||||||
|
const auto b = get_obj<gfx::Rect>(L, 2);
|
||||||
|
push_obj(L, a->createIntersection(*b));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int Rectangle_get_x(lua_State* L)
|
int Rectangle_get_x(lua_State* L)
|
||||||
{
|
{
|
||||||
const auto rc = get_obj<gfx::Rect>(L, 1);
|
const auto rc = get_obj<gfx::Rect>(L, 1);
|
||||||
@ -130,6 +163,10 @@ int Rectangle_get_isEmpty(lua_State* L)
|
|||||||
const luaL_Reg Rectangle_methods[] = {
|
const luaL_Reg Rectangle_methods[] = {
|
||||||
{ "__gc", Rectangle_gc },
|
{ "__gc", Rectangle_gc },
|
||||||
{ "__eq", Rectangle_eq },
|
{ "__eq", Rectangle_eq },
|
||||||
|
{ "contains", Rectangle_contains },
|
||||||
|
{ "intersects", Rectangle_intersects },
|
||||||
|
{ "union", Rectangle_union },
|
||||||
|
{ "intersect", Rectangle_intersect },
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user