* 增加裁切功能
This commit is contained in:
+114
-42
@@ -144,6 +144,21 @@ namespace dl
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
static Array<T, N> lua_Array_op_add(const Array<T, N>& a, const Array<T, N>& b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
template<typename T, size_t N>
|
||||
static Array<T, N> lua_Array_op_sub(const Array<T, N>& a, const Array<T, N>& b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
template<typename T, size_t N>
|
||||
static Array<T, N> lua_Array_op_nag(const Array<T, N>& a)
|
||||
{
|
||||
return -a;
|
||||
}
|
||||
|
||||
void lua_register_base(lua_State* L)
|
||||
{
|
||||
@@ -161,51 +176,68 @@ namespace dl
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Position>("Position")
|
||||
.addConstructor<void (*)()>()
|
||||
.addPropertyReadWrite("x", &Position::x)
|
||||
.addPropertyReadWrite("y", &Position::y);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Position4>("Position4")
|
||||
.addConstructor<void (*)()>()
|
||||
.addPropertyReadWrite("x", &Position4::x)
|
||||
.addPropertyReadWrite("y", &Position4::y)
|
||||
.addPropertyReadWrite("z", &Position4::z)
|
||||
.addPropertyReadWrite("w", &Position4::w);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Point>("Point")
|
||||
.addConstructor<void (*)()>()
|
||||
.addFunction("__add", lua_Array_op_add<int, 2>)
|
||||
.addFunction("__sub", lua_Array_op_sub<int, 2>)
|
||||
.addFunction("__unm", lua_Array_op_nag<int, 2>)
|
||||
.addPropertyReadWrite("x", &Point::x)
|
||||
.addPropertyReadWrite("y", &Point::y);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Size>("Size")
|
||||
.addConstructor<void (*)()>()
|
||||
.addPropertyReadWrite("w", &Size::w)
|
||||
.addPropertyReadWrite("h", &Size::h);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<PointU>("PointU")
|
||||
.addConstructor<void (*)()>()
|
||||
.addPropertyReadWrite("x", &PointU::x)
|
||||
.addPropertyReadWrite("y", &PointU::y);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<RectU>("RectU")
|
||||
.addConstructor<void (*)()>()
|
||||
.addPropertyReadWrite("lt", &RectU::lt)
|
||||
.addPropertyReadWrite("rt", &RectU::rt)
|
||||
.addPropertyReadWrite("rb", &RectU::rb)
|
||||
.addPropertyReadWrite("lb", &RectU::lb);
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("Align")
|
||||
.addFunction("GetSize", Align::GetSize<unsigned>)
|
||||
.addFunction("GetLT", Align::GetLT<unsigned>)
|
||||
.endNamespace();
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.addFunction("toPoint", toPoint<unsigned, 2>);
|
||||
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("String")
|
||||
.addFunction("ErasePath", String::ErasePath)
|
||||
.addFunction("GetFileStem", String::GetFileStem)
|
||||
.addFunction("toPosition2", String::toPosition2)
|
||||
.addFunction("toPoint2", String::toPoint2)
|
||||
.addFunction("ReplaceExtension",
|
||||
luabridge::overload<std::string_view, std::string_view>(String::ReplaceExtension))
|
||||
.addFunction("EraseFilename",
|
||||
luabridge::overload<std::string_view>(String::EraseFilename))
|
||||
.endNamespace();
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("Img")
|
||||
.addVariable("REGEX_FORMAT", Img::REGEX_FORMAT)
|
||||
//.addFunction("Resize",
|
||||
// luabridge::overload<const Image*, float>(Img::Resize),
|
||||
// luabridge::overload<const Image*, const Size&>(Img::Resize))
|
||||
.addFunction("SetAlphaZero",
|
||||
luabridge::overload<Image*>(Img::SetAlphaZero),
|
||||
luabridge::overload<Image*, uint8_t, uint32_t>(Img::SetAlphaZero))
|
||||
/*.addFunction("Create",
|
||||
luabridge::overload<std::string_view>(Img::Create),
|
||||
luabridge::overload<const Size&, const Color&>(Img::Create))*/
|
||||
.addFunction("Save", Img::Save)
|
||||
.endNamespace();
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Image>("Image")
|
||||
.endClass();
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("ColorDef")
|
||||
.addVariable("NONE", ColorDef::NONE)
|
||||
.addVariable("RED", ColorDef::RED)
|
||||
.endNamespace();
|
||||
}
|
||||
|
||||
void lua_register_system(lua_State* L)
|
||||
@@ -321,23 +353,6 @@ namespace dl
|
||||
auto result = luabridge::push(L, g_factory);
|
||||
lua_setglobal(L, "g_factory");
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("Img")
|
||||
.addFunction("Create",
|
||||
luabridge::overload<const Size&, const Color&>(&Img::Create),
|
||||
luabridge::overload<std::string_view>(&Img::Create))
|
||||
.addFunction("CreateSvg", &Img::CreateSvg)
|
||||
.addFunction("CreateWebp",
|
||||
luabridge::overload<std::string_view>(&Img::CreateWebp),
|
||||
luabridge::overload<BufferView>(&Img::CreateWebp))
|
||||
.addFunction("Save", &Img::Save)
|
||||
.addFunction("SetAlphaZero",
|
||||
luabridge::overload<Image*>(&Img::SetAlphaZero),
|
||||
luabridge::overload<Image*, uint8_t, uint32_t>(&Img::SetAlphaZero))
|
||||
.addFunction("Resize",
|
||||
luabridge::overload<const Image*, const Size&>(&Img::Resize),
|
||||
luabridge::overload<const Image*, Float>(&Img::Resize))
|
||||
.endNamespace();
|
||||
}
|
||||
|
||||
void lua_register_sprite(lua_State* L)
|
||||
@@ -550,6 +565,62 @@ namespace dl
|
||||
.endClass();
|
||||
}
|
||||
|
||||
void lua_register_image(lua_State* L)
|
||||
{
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("Img")
|
||||
.addVariable("REGEX_FORMAT", Img::REGEX_FORMAT)
|
||||
.addFunction("Create",
|
||||
luabridge::overload<const Size&, const Color&>(&Img::Create),
|
||||
luabridge::overload<std::string_view>(&Img::Create))
|
||||
.addFunction("CreateSvg", &Img::CreateSvg)
|
||||
.addFunction("CreateWebp",
|
||||
luabridge::overload<std::string_view>(&Img::CreateWebp),
|
||||
luabridge::overload<BufferView>(&Img::CreateWebp))
|
||||
.addFunction("Save", &Img::Save)
|
||||
.addFunction("CalcLeastRect", &Img::CalcLeastRect)
|
||||
.addFunction("SetAlphaZero",
|
||||
luabridge::overload<Image*>(&Img::SetAlphaZero),
|
||||
luabridge::overload<Image*, uint8_t, uint32_t>(&Img::SetAlphaZero))
|
||||
.addFunction("Resize",
|
||||
luabridge::overload<const Image*, const Size&>(&Img::Resize),
|
||||
luabridge::overload<const Image*, Float>(&Img::Resize))
|
||||
.addFunction("AddRect", Img::AddRect)
|
||||
.addFunction("SetAlphaZero",
|
||||
luabridge::overload<Image*>(Img::SetAlphaZero),
|
||||
luabridge::overload<Image*, uint8_t, uint32_t>(Img::SetAlphaZero))
|
||||
.addFunction("Save", Img::Save)
|
||||
.endNamespace();
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginClass<Image>("Image")
|
||||
.endClass();
|
||||
|
||||
luabridge::getGlobalNamespace(L)
|
||||
.beginNamespace("ColorDef")
|
||||
.addVariable("NONE", ColorDef::NONE)
|
||||
.addVariable("WHITE", ColorDef::WHITE)
|
||||
.addVariable("BLACK", ColorDef::BLACK)
|
||||
.addVariable("RED", ColorDef::RED)
|
||||
.addVariable("GREEN", ColorDef::GREEN)
|
||||
.addVariable("BLUE", ColorDef::BLUE)
|
||||
.addVariable("YELLOW", ColorDef::YELLOW)
|
||||
.addVariable("PURPLE", ColorDef::PURPLE)
|
||||
.addVariable("CYAN", ColorDef::CYAN)
|
||||
.addVariable("ORANGE", ColorDef::ORANGE)
|
||||
.addVariable("GREEN_DARK", ColorDef::GREEN_DARK)
|
||||
.addVariable("DISABLE", ColorDef::DISABLE)
|
||||
.addVariable("TEXT_BG", ColorDef::TEXT_BG)
|
||||
.addVariable("FACTOR_GRAY", ColorDef::FACTOR_GRAY)
|
||||
.addVariable("GRAY", ColorDef::GRAY)
|
||||
.addVariable("GRAY_LIGHT", ColorDef::GRAY_LIGHT)
|
||||
.addVariable("GRAY_DARK", ColorDef::GRAY_DARK)
|
||||
.addVariable("CLEAR_SCREEN", ColorDef::CLEAR_SCREEN)
|
||||
.addVariable("AXIS_X", ColorDef::AXIS_X)
|
||||
.addVariable("AXIS_Y", ColorDef::AXIS_Y)
|
||||
.addVariable("AXIS_Z", ColorDef::AXIS_Z)
|
||||
.endNamespace();
|
||||
}
|
||||
|
||||
#if DL_PLATFORM == DL_PLATFORM_WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
@@ -574,6 +645,7 @@ namespace dl
|
||||
lua_register_memory(L);
|
||||
lua_register_other(L);
|
||||
lua_register_json(L);
|
||||
lua_register_image(L);
|
||||
|
||||
#if DL_PLATFORM == DL_PLATFORM_WIN32
|
||||
lua_register_win32(L);
|
||||
|
||||
Reference in New Issue
Block a user