summaryrefslogtreecommitdiff
path: root/cd/src/lua5/cdlua5_canvas.c
diff options
context:
space:
mode:
Diffstat (limited to 'cd/src/lua5/cdlua5_canvas.c')
-rwxr-xr-xcd/src/lua5/cdlua5_canvas.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/cd/src/lua5/cdlua5_canvas.c b/cd/src/lua5/cdlua5_canvas.c
index f3b929d..c2f6008 100755
--- a/cd/src/lua5/cdlua5_canvas.c
+++ b/cd/src/lua5/cdlua5_canvas.c
@@ -1494,7 +1494,7 @@ static int wdlua5_gettextbox(lua_State *L)
}
/***************************************************************************************************************\
-* cd.GetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) *
+* cd.GetTextBounds(x, y: number, text: string) -> (rect: table) *
\***************************************************************************************************************/
static int cdlua5_gettextbounds(lua_State *L)
{
@@ -1502,21 +1502,20 @@ static int cdlua5_gettextbounds(lua_State *L)
int x = luaL_checkint(L, 2);
int y = luaL_checkint(L, 3);
const char* s = luaL_checkstring(L, 4);
+ int i;
cdCanvasGetTextBounds(cdlua_checkcanvas(L, 1), x, y, s, rect);
- lua_pushnumber(L, rect[0]);
- lua_pushnumber(L, rect[1]);
- lua_pushnumber(L, rect[2]);
- lua_pushnumber(L, rect[3]);
- lua_pushnumber(L, rect[4]);
- lua_pushnumber(L, rect[5]);
- lua_pushnumber(L, rect[6]);
- lua_pushnumber(L, rect[7]);
- return 4;
+ lua_newtable(L);
+ for (i=0; i < 8; i++)
+ {
+ lua_pushnumber(L, rect[i]);
+ lua_rawseti(L, -2, i+1);
+ }
+ return 1;
}
/****************************************************************************************************************\
-* cd.wGetTextBounds(x, y: number, text: string) -> (rect0, rect1, rect2, rect3, rect4, rect5, rect6, rect7: number) *
+* cd.wGetTextBounds(x, y: number, text: string) -> (rect: table) *
\****************************************************************************************************************/
static int wdlua5_gettextbounds(lua_State *L)
{
@@ -1524,17 +1523,16 @@ static int wdlua5_gettextbounds(lua_State *L)
double x = luaL_checknumber(L, 2);
double y = luaL_checknumber(L, 3);
const char* s = luaL_checkstring(L, 4);
+ int i;
wdCanvasGetTextBounds(cdlua_checkcanvas(L, 1), x, y, s, rect);
- lua_pushnumber(L, rect[0]);
- lua_pushnumber(L, rect[1]);
- lua_pushnumber(L, rect[2]);
- lua_pushnumber(L, rect[3]);
- lua_pushnumber(L, rect[4]);
- lua_pushnumber(L, rect[5]);
- lua_pushnumber(L, rect[6]);
- lua_pushnumber(L, rect[7]);
- return 4;
+ lua_newtable(L);
+ for (i=0; i < 8; i++)
+ {
+ lua_pushnumber(L, rect[i]);
+ lua_rawseti(L, -2, i+1);
+ }
+ return 1;
}
@@ -2205,6 +2203,12 @@ static int cdlua5_vertex(lua_State *L)
return 0;
}
+static int cdlua5_pathset(lua_State *L)
+{
+ cdCanvasPathSet(cdlua_checkcanvas(L, 1), luaL_checkint(L, 2));
+ return 0;
+}
+
static int wdlua5_vertex(lua_State *L)
{
wdCanvasVertex(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3));
@@ -2429,6 +2433,7 @@ static const struct luaL_reg cdlib_canvas_meta[] = {
/* Polygon */
{"Begin" , cdlua5_begin},
+ {"PathSet" , cdlua5_pathset},
{"Vertex" , cdlua5_vertex},
{"wVertex" , wdlua5_vertex},
{"fVertex" , cdlua5_fvertex},