diff options
author | chai <chaifix@163.com> | 2018-05-17 18:45:24 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-05-17 18:45:24 +0800 |
commit | df4b054b8e8d00f7817daaa4cbf6961712cd0b75 (patch) | |
tree | 03fae2233f3c17a91d22e61a139fcc62d6a50bf3 /src/lua/graphics/luaopen_Image.cpp | |
parent | 34947d066b994c2ef9121a83497da344982d28e2 (diff) |
v0.1.0
Diffstat (limited to 'src/lua/graphics/luaopen_Image.cpp')
-rw-r--r-- | src/lua/graphics/luaopen_Image.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp index 2637db9..b25dcc8 100644 --- a/src/lua/graphics/luaopen_Image.cpp +++ b/src/lua/graphics/luaopen_Image.cpp @@ -9,23 +9,28 @@ namespace jin namespace lua { + static inline Image* checkImage(lua_State* L) + { + return (Image*)luax_checktype(L, 1, TYPE_IMAGE); + } + static int l_getWidth(lua_State* L) { - Image* i = (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Image* i = checkImage(L); luax_pushnumber(L, i->getWidth()); return 1; } static int l_getHeight(lua_State *L) { - Image* i = (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Image* i = checkImage(L); luax_pushnumber(L, i->getHeight()); return 1; } static int l_getPixel(lua_State* L) { - Image* i = (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Image* i = checkImage(L); int x = luax_checknumber(L, 2); int y = luax_checknumber(L, 3); color c = i->getPixel(x, y); @@ -38,7 +43,7 @@ namespace lua static int l_setAnchor(lua_State* L) { - Image* i = (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Image* i = checkImage(L); int x = luax_checknumber(L, 2); int y = luax_checknumber(L, 3); i->setAnchor(x, y); @@ -47,7 +52,7 @@ namespace lua static int l_getSize(lua_State* L) { - Image* i = (Image*)luax_checktype(L, 1, TYPE_IMAGE); + Image* i = checkImage(L); luax_pushnumber(L, i->getWidth()); luax_pushnumber(L, i->getHeight()); return 2; |