#include "StarImageLuaBindings.hpp" #include "StarLuaConverters.hpp" #include "StarImage.hpp" #include "StarRootBase.hpp" namespace Star { LuaMethods LuaUserDataMethods::make() { LuaMethods methods; methods.registerMethodWithSignature("size", mem_fn(&Image::size)); methods.registerMethodWithSignature("drawInto", mem_fn(&Image::drawInto)); methods.registerMethodWithSignature("copyInto", mem_fn(&Image::copyInto)); methods.registerMethod("set", [](Image& image, unsigned x, unsigned y, Color const& color) { image.set(x, y, color.toRgba()); }); methods.registerMethod("get", [](Image& image, unsigned x, unsigned y) { return Color::rgba(image.get(x, y)); }); methods.registerMethod("subImage", [](Image& image, Vec2U const& min, Vec2U const& size) { return image.subImage(min, size); }); methods.registerMethod("process", [](Image& image, String const& directives) { return processImageOperations(parseImageOperations(directives), image, [](String const& path) -> Image const* { if (auto root = RootBase::singletonPtr()) return root->assets()->image(path).get(); else return nullptr; }); }); return methods; } }