diff options
Diffstat (limited to 'cd/src/lua5/cdlua5_canvas.c')
-rwxr-xr-x | cd/src/lua5/cdlua5_canvas.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/cd/src/lua5/cdlua5_canvas.c b/cd/src/lua5/cdlua5_canvas.c index d04f76f..f3b929d 100755 --- a/cd/src/lua5/cdlua5_canvas.c +++ b/cd/src/lua5/cdlua5_canvas.c @@ -273,6 +273,12 @@ static int cdlua5_updateyaxis(lua_State *L) return 1; } +static int cdlua5_yaxismode(lua_State *L) +{ + lua_pushnumber(L, cdCanvasYAxisMode(cdlua_checkcanvas(L, 1), luaL_checkint(L, 2))); + return 1; +} + static int cdlua5_invertyaxis(lua_State *L) { lua_pushnumber(L, cdfCanvasInvertYAxis(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2))); @@ -465,6 +471,56 @@ static int cdlua5_ftransformpoint(lua_State *L) \***************************************************************************/ /***************************************************************************\ +* wd.GetTransform() -> (sx, sy, tx, ty: number) * +\***************************************************************************/ +static int wdlua5_gettransform(lua_State *L) +{ + double sx, sy, tx, ty; + + wdCanvasGetTransform(cdlua_checkcanvas(L, 1), &sx, &sy, &tx, &ty); + lua_pushnumber(L, sx); + lua_pushnumber(L, sy); + lua_pushnumber(L, tx); + lua_pushnumber(L, ty); + return 4; +} + +/***************************************************************************\ +* wd.SetTransform(sx, sy, tx, ty: number) * +\***************************************************************************/ +static int wdlua5_settransform(lua_State *L) +{ + double sx = luaL_checknumber(L, 2); + double sy = luaL_checknumber(L, 3); + double tx = luaL_checknumber(L, 4); + double ty = luaL_checknumber(L, 5); + wdCanvasSetTransform(cdlua_checkcanvas(L, 1), sx, sy, tx, ty); + return 0; +} + +/***************************************************************************\ +* wd.Translate(tx, ty: number) * +\***************************************************************************/ +static int wdlua5_translate(lua_State *L) +{ + double tx = luaL_checknumber(L, 2); + double ty = luaL_checknumber(L, 3); + wdCanvasTranslate(cdlua_checkcanvas(L, 1), tx, ty); + return 0; +} + +/***************************************************************************\ +* wd.Scale(sx, sy: number) * +\***************************************************************************/ +static int wdlua5_scale(lua_State *L) +{ + double sx = luaL_checknumber(L, 2); + double sy = luaL_checknumber(L, 3); + wdCanvasScale(cdlua_checkcanvas(L, 1), sx, sy); + return 0; +} + +/***************************************************************************\ * wd.Window(xmin, xmax, ymin, ymax: number) * \***************************************************************************/ static int wdlua5_window(lua_State *L) @@ -712,7 +768,7 @@ static int cdlua5_regioncombinemode(lua_State *L) \***************************************************************************/ static int cdlua5_pointinregion(lua_State *L) { - lua_pushnumber(L, cdCanvasIsPointInRegion(cdlua_checkcanvas(L, 1), luaL_checkint(L, 2), luaL_checkint(L, 3))); + lua_pushboolean(L, cdCanvasIsPointInRegion(cdlua_checkcanvas(L, 1), luaL_checkint(L, 2), luaL_checkint(L, 3))); return 1; } @@ -721,7 +777,7 @@ static int cdlua5_pointinregion(lua_State *L) \***************************************************************************/ static int wdlua5_pointinregion(lua_State *L) { - lua_pushnumber(L, wdCanvasIsPointInRegion(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3))); + lua_pushboolean(L, wdCanvasIsPointInRegion(cdlua_checkcanvas(L, 1), luaL_checknumber(L, 2), luaL_checknumber(L, 3))); return 1; } @@ -2192,6 +2248,7 @@ static const struct luaL_reg cdlib_canvas_meta[] = { /* Coordinate System */ {"GetSize" , cdlua5_getcanvassize}, {"UpdateYAxis" , cdlua5_updateyaxis}, + {"YAxisMode" , cdlua5_yaxismode}, {"InvertYAxis" , cdlua5_invertyaxis}, {"MM2Pixel" , cdlua5_mm2pixel}, {"Pixel2MM" , cdlua5_pixel2mm}, @@ -2217,6 +2274,10 @@ static const struct luaL_reg cdlib_canvas_meta[] = { {"wGetViewport" , wdlua5_getviewport}, {"wWorld2Canvas" , wdlua5_world2canvas}, {"wCanvas2World" , wdlua5_canvas2world}, + {"wGetTransform" , wdlua5_gettransform}, + {"wSetTransform" , wdlua5_settransform}, + {"wScale" , wdlua5_scale}, + {"wTranslate" , wdlua5_translate}, {"wHardcopy" , wdlua5_hardcopy}, |