ref: 20462b4b4afbc56235201903221a1fb15f14d605
parent: 70de7329ed0cdf8dac3e7e9126f13e5ed61d2c28
author: phil9 <telephil9@gmail.com>
date: Mon Dec 5 14:12:34 EST 2022
make color related functions accept a color table created with color()
--- a/api.c
+++ b/api.c
@@ -151,8 +151,22 @@
c = lua_gettop(L);
if(c == 1){
- g = luaL_checkinteger(L, 1);
- i = color(g, g, g, 0);
+ if(lua_istable(L, 1)){
+ lua_pushstring(L, "r");
+ lua_gettable(L, 1);
+ r = luaL_checkinteger(L, -1);
+ lua_pushstring(L, "g");
+ lua_gettable(L, 1);
+ g = luaL_checkinteger(L, -1);
+ lua_pushstring(L, "b");
+ lua_gettable(L, 1);
+ b = luaL_checkinteger(L, -1);
+ }else{
+ r = luaL_checkinteger(L, 1);
+ g = r;
+ b = r;
+ }
+ i = color(r, g, b, 0);
}else if(c == 3){
r = luaL_checkinteger(L, 1);
g = luaL_checkinteger(L, 2);