summaryrefslogtreecommitdiff
path: root/src/lua5
diff options
context:
space:
mode:
authorscuri <scuri>2009-12-02 17:28:14 +0000
committerscuri <scuri>2009-12-02 17:28:14 +0000
commitd8f5733cca135168f0c197d24258253a3e6b6d08 (patch)
tree6bc21b1b62640709588d4f4474d4aee8bd24a950 /src/lua5
parent837b9b863299bd05b5348b47f9c028091c70de61 (diff)
New: functions wdCanvasSetTransform, wdCanvasGetTransform, wdCanvasTranslate and wdCanvasScale, to better control the WD transformation.
Diffstat (limited to 'src/lua5')
-rw-r--r--src/lua5/cdlua5_canvas.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/lua5/cdlua5_canvas.c b/src/lua5/cdlua5_canvas.c
index 7fb5402..f3b929d 100644
--- a/src/lua5/cdlua5_canvas.c
+++ b/src/lua5/cdlua5_canvas.c
@@ -471,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)
@@ -2224,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},