mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-28 06:21:25 +00:00
[lua] Add Size:union() function
This commit is contained in:
parent
3280b87a53
commit
88296340a6
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
// Copyright (C) 2017-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -154,6 +154,14 @@ int Size_pow(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Size_union(lua_State* L)
|
||||
{
|
||||
const auto a = get_obj<gfx::Size>(L, 1);
|
||||
const auto b = get_obj<gfx::Size>(L, 2);
|
||||
push_obj(L, a->createUnion(*b));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Size_get_width(lua_State* L)
|
||||
{
|
||||
const auto sz = get_obj<gfx::Size>(L, 1);
|
||||
@ -198,6 +206,7 @@ const luaL_Reg Size_methods[] = {
|
||||
{ "__mod", Size_mod },
|
||||
{ "__pow", Size_pow },
|
||||
{ "__idiv", Size_div },
|
||||
{ "union", Size_union },
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- Copyright (C) 2019 Igara Studio S.A.
|
||||
-- Copyright (C) 2019-2023 Igara Studio S.A.
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
@ -73,3 +73,9 @@ assert(sz.height == 25)
|
||||
sz = Size(31, 10) // 3
|
||||
assert(sz.width == 10)
|
||||
assert(sz.height == 3)
|
||||
|
||||
-- Size:union
|
||||
|
||||
sz = Size(4, 2):union(Size(1, 8))
|
||||
assert(sz.width == 4)
|
||||
assert(sz.height == 8)
|
||||
|
Loading…
Reference in New Issue
Block a user