summaryrefslogtreecommitdiff
path: root/iup/srclua5/il_getcolor.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-04 11:56:41 -0800
committerPixel <pixel@nobis-crew.org>2009-11-04 11:59:33 -0800
commitd577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch)
tree590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/srclua5/il_getcolor.c
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/srclua5/il_getcolor.c')
-rwxr-xr-xiup/srclua5/il_getcolor.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/iup/srclua5/il_getcolor.c b/iup/srclua5/il_getcolor.c
new file mode 100755
index 0000000..d468d38
--- /dev/null
+++ b/iup/srclua5/il_getcolor.c
@@ -0,0 +1,46 @@
+/** \file
+ * \brief IupGetColor bindig to Lua 5.
+ *
+ * See Copyright Notice in "iup.h"
+ */
+
+#include <stdlib.h>
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "iup.h"
+
+#include "iuplua.h"
+#include "il.h"
+#include "il_controls.h"
+
+
+static int GetColor(lua_State *L)
+{
+ int x = (int)luaL_checknumber(L,1);
+ int y = (int)luaL_checknumber(L,2);
+ unsigned char r = (unsigned char) luaL_optnumber(L,3,0);
+ unsigned char g = (unsigned char) luaL_optnumber(L,4,0);
+ unsigned char b = (unsigned char) luaL_optnumber(L,5,0);
+ int ret = IupGetColor(x,y,&r,&g,&b);
+ if (ret)
+ {
+ lua_pushnumber(L, (int) r);
+ lua_pushnumber(L, (int) g);
+ lua_pushnumber(L, (int) b);
+ return 3;
+ }
+ else
+ {
+ lua_pushnil(L);
+ return 1;
+ }
+}
+int iupgclua_open(lua_State * L)
+{
+ lua_pushcfunction(L, GetColor);
+ lua_setglobal(L, "GetColor");
+ return 0;
+}
+