1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 = luaL_checkinteger(L,1);
int y = luaL_checkinteger(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_pushinteger(L, r);
lua_pushinteger(L, g);
lua_pushinteger(L, b);
return 3;
}
else
{
lua_pushnil(L);
return 1;
}
}
int iupgclua_open(lua_State * L)
{
iuplua_register(L, GetColor, "GetColor");
return 0;
}
|