aboutsummaryrefslogtreecommitdiff
path: root/src/lua/graphics/luaopen_Image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/graphics/luaopen_Image.cpp')
-rw-r--r--src/lua/graphics/luaopen_Image.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp
index 8d89a80..b1672d5 100644
--- a/src/lua/graphics/luaopen_Image.cpp
+++ b/src/lua/graphics/luaopen_Image.cpp
@@ -1,43 +1,42 @@
#include "lua/luax.h"
#include "lua/luaopen_types.h"
-#include "Image.h"
-#include "Color.h"
+#include "libjin/jin.h"
namespace jin
{
namespace lua
{
- using namespace lua::graphics;
+ using namespace jin::graphics;
- static inline Image* checkImage(lua_State* L)
+ typedef Texture Image;
+
+ static inline Ref<Image>& checkImage(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_IMAGE);
- if (proxy != nullptr)
- return (Image*)proxy->object;
- return nullptr;
+ return proxy->getRef<Image>();
}
static int l_getWidth(lua_State* L)
{
- Image* i = checkImage(L);
- luax_pushnumber(L, i->getWidth());
+ Ref<Image>& ref = checkImage(L);
+ luax_pushnumber(L, (*ref).getWidth());
return 1;
}
static int l_getHeight(lua_State *L)
{
- Image* i = checkImage(L);
- luax_pushnumber(L, i->getHeight());
+ Ref<Image>& ref = checkImage(L);
+ luax_pushnumber(L, (*ref).getHeight());
return 1;
}
static int l_getPixel(lua_State* L)
{
- Image* i = checkImage(L);
+ Ref<Image>& ref = checkImage(L);
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
- color c = i->getPixel(x, y);
+ color c = (*ref).getPixel(x, y);
luax_pushnumber(L, c.rgba.r);
luax_pushnumber(L, c.rgba.g);
luax_pushnumber(L, c.rgba.b);
@@ -47,18 +46,18 @@ namespace lua
static int l_setAnchor(lua_State* L)
{
- Image* i = checkImage(L);
+ Ref<Image>& ref = checkImage(L);
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
- i->setAnchor(x, y);
+ (*ref).setAnchor(x, y);
return 0;
}
static int l_getSize(lua_State* L)
{
- Image* i = checkImage(L);
- luax_pushnumber(L, i->getWidth());
- luax_pushnumber(L, i->getHeight());
+ Ref<Image>& ref = checkImage(L);
+ luax_pushnumber(L, (*ref).getWidth());
+ luax_pushnumber(L, (*ref).getHeight());
return 2;
}