summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscuri <scuri>2009-12-01 20:33:02 +0000
committerscuri <scuri>2009-12-01 20:33:02 +0000
commit837b9b863299bd05b5348b47f9c028091c70de61 (patch)
treecc64af440937937ca8e3d70e04e357ee29527a24 /src
parenta70ccabdeb03fa5c6a2b1a594202659a7ebacd33 (diff)
New: function CanvasYAxisMode to control the Y axis orientation.
Diffstat (limited to 'src')
-rw-r--r--src/cd.c16
-rw-r--r--src/cd.def1
-rw-r--r--src/lua5/cdlua5_canvas.c7
3 files changed, 23 insertions, 1 deletions
diff --git a/src/cd.c b/src/cd.c
index b88cc1b..6435d0a 100644
--- a/src/cd.c
+++ b/src/cd.c
@@ -586,6 +586,20 @@ void cdCanvasClear(cdCanvas* canvas)
canvas->cxClear(canvas->ctxcanvas);
}
+int cdCanvasYAxisMode(cdCanvas* canvas, int invert)
+{
+ int old_invert_yaxis;
+ assert(canvas);
+ if (!_cdCheckCanvas(canvas)) return CD_ERROR;
+
+ if (invert == CD_QUERY)
+ return canvas->invert_yaxis;
+
+ old_invert_yaxis = canvas->invert_yaxis;
+ canvas->invert_yaxis = invert;
+ return old_invert_yaxis;
+}
+
int cdCanvasUpdateYAxis(cdCanvas* canvas, int* y)
{
assert(canvas);
@@ -609,7 +623,7 @@ double cdfCanvasUpdateYAxis(cdCanvas* canvas, double* y)
assert(y);
if (!_cdCheckCanvas(canvas)) return CD_ERROR;
- if(canvas->invert_yaxis)
+ if (canvas->invert_yaxis)
{
*y = _cdInvertYAxis(canvas, *y);
diff --git a/src/cd.def b/src/cd.def
index dd2f7ed..0aa2c35 100644
--- a/src/cd.def
+++ b/src/cd.def
@@ -297,6 +297,7 @@ EXPORTS
cdCanvasInvertYAxis
cdfCanvasUpdateYAxis
cdfCanvasInvertYAxis
+ cdCanvasYAxisMode
cdContextRegisterCallback
cdCanvasBackground
cdCanvasForeground
diff --git a/src/lua5/cdlua5_canvas.c b/src/lua5/cdlua5_canvas.c
index eeecc6d..7fb5402 100644
--- a/src/lua5/cdlua5_canvas.c
+++ b/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)));
@@ -2192,6 +2198,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},