aboutsummaryrefslogtreecommitdiff
path: root/src/lua/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/graphics')
-rw-r--r--src/lua/graphics/luaopen_Canvas.cpp24
-rw-r--r--src/lua/graphics/luaopen_Font.cpp6
-rw-r--r--src/lua/graphics/luaopen_Image.cpp14
-rw-r--r--src/lua/graphics/luaopen_JSL.cpp6
-rw-r--r--src/lua/graphics/luaopen_graphics.cpp63
5 files changed, 52 insertions, 61 deletions
diff --git a/src/lua/graphics/luaopen_Canvas.cpp b/src/lua/graphics/luaopen_Canvas.cpp
index 302d139..0009ff4 100644
--- a/src/lua/graphics/luaopen_Canvas.cpp
+++ b/src/lua/graphics/luaopen_Canvas.cpp
@@ -9,7 +9,9 @@ namespace lua
using namespace jin::graphics;
- static inline Ref<Canvas>& checkCanvas(lua_State* L)
+ typedef Ref<Canvas>& CanvasRef;
+
+ static inline CanvasRef checkCanvas(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS);
return proxy->getRef<Canvas>();
@@ -17,21 +19,21 @@ namespace lua
static int l_getWidth(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
return 1;
}
static int l_getHeight(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getHeight());
return 1;
}
static int l_getSize(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
luax_pushnumber(L, ref->getHeight());
return 2;
@@ -39,7 +41,7 @@ namespace lua
static int l_setAnchor(lua_State* L)
{
- Ref<Canvas>& ref = checkCanvas(L);
+ CanvasRef ref = checkCanvas(L);
int x = luax_checknumber(L, 1);
int y = luax_checknumber(L, 2);
ref->setAnchor(x, y);
@@ -54,12 +56,12 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"getWidth", l_getWidth},
- {"getHeight", l_getHeight},
- {"getSize", l_getSize},
- {"setAnchor", l_setAnchor},
- {0, 0 }
+ { "__gc", l_gc },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "getSize", l_getSize },
+ { "setAnchor", l_setAnchor },
+ { 0, 0 }
};
int luaopen_Canvas(lua_State* L)
diff --git a/src/lua/graphics/luaopen_Font.cpp b/src/lua/graphics/luaopen_Font.cpp
index 6686d03..5e13806 100644
--- a/src/lua/graphics/luaopen_Font.cpp
+++ b/src/lua/graphics/luaopen_Font.cpp
@@ -32,9 +32,9 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"box", l_box},
- {0, 0}
+ { "__gc", l_gc },
+ { "box", l_box },
+ { 0, 0 }
};
int luaopen_Font(lua_State* L)
diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp
index 4ed92cf..df9b411 100644
--- a/src/lua/graphics/luaopen_Image.cpp
+++ b/src/lua/graphics/luaopen_Image.cpp
@@ -69,13 +69,13 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc},
- {"getWidth", l_getWidth},
- {"getHeight", l_getHeight},
- {"getSize", l_getSize},
- {"getPixel", l_getPixel},
- {"setAnchor", l_setAnchor},
- {0, 0 }
+ { "__gc", l_gc },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "getSize", l_getSize },
+ { "getPixel", l_getPixel },
+ { "setAnchor", l_setAnchor },
+ { 0, 0 }
};
int luaopen_Image(lua_State* L)
diff --git a/src/lua/graphics/luaopen_JSL.cpp b/src/lua/graphics/luaopen_JSL.cpp
index cd77a03..1c46f84 100644
--- a/src/lua/graphics/luaopen_JSL.cpp
+++ b/src/lua/graphics/luaopen_JSL.cpp
@@ -127,9 +127,9 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"__gc", l_gc },
- {"send", l_send},
- {0, 0}
+ { "__gc", l_gc },
+ { "send", l_send },
+ { 0, 0 }
};
/**
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp
index 4a5ccce..b86b523 100644
--- a/src/lua/graphics/luaopen_graphics.cpp
+++ b/src/lua/graphics/luaopen_graphics.cpp
@@ -473,43 +473,32 @@ namespace lua
}
static const luaL_Reg f[] = {
- {"init", l_init},
- {"size", l_getSize},
- {"Image", l_newImage},
- {"Shader", l_newShader},
- {"Canvas", l_newCanvas},
- {"Font", l_newFont},
- /**
- * before using box and write
- * must call study to set
- * current font
- */
- {"box", l_box},
- {"write", l_write},
- {"clear", l_clear},
- {"draw", l_draw},
- {"color", l_setColor},
- {"palette", l_getColor},
- {"present", l_present},
- //{"blend", l_setBlend},
- // study font
- {"study", l_study},
- // bind canvas
- {"bind", l_bindCanvas},
- {"unbind", l_unbindCanvas},
- // use shader
- {"use", l_useShader},
- {"unuse", l_unuseShader},
- // draw shapes
- {"point", l_drawpoint},
- {"line", l_drawLine},
- {"rect", l_drawRect},
- {"circle", l_drawCircle},
- {"triangle", l_drawTriangle},
- {"polygon", l_drawPolygon},
- // quit window
- {"destroy", l_destroy},
- {0, 0}
+ { "init", l_init },
+ { "size", l_getSize },
+ { "Image", l_newImage },
+ { "Shader", l_newShader },
+ { "Canvas", l_newCanvas },
+ { "Font", l_newFont },
+ { "box", l_box },
+ { "write", l_write },
+ { "clear", l_clear },
+ { "draw", l_draw },
+ { "color", l_setColor },
+ { "palette", l_getColor },
+ { "present", l_present },
+ { "study", l_study },
+ { "bind", l_bindCanvas },
+ { "unbind", l_unbindCanvas },
+ { "use", l_useShader },
+ { "unuse", l_unuseShader },
+ { "point", l_drawpoint },
+ { "line", l_drawLine },
+ { "rect", l_drawRect },
+ { "circle", l_drawCircle },
+ { "triangle", l_drawTriangle },
+ { "polygon", l_drawPolygon },
+ { "destroy", l_destroy },
+ { 0, 0 }
};
extern int luaopen_Image(lua_State* L);