Lua: matchcolor2() now takes an optional argument that is the weight of lightness in color proximity algorithm (instead of the 0.25 default).
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1821 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
@@ -711,12 +711,23 @@ int L_MatchColor2(lua_State* L)
|
||||
int c;
|
||||
int nb_args=lua_gettop(L);
|
||||
|
||||
LUA_ARG_LIMIT (3, "matchcolor2");
|
||||
if (nb_args < 3 || nb_args > 4)
|
||||
{
|
||||
return luaL_error(L, "matchcolor2: Expected 3 or 4 arguments, but found %d.", nb_args);
|
||||
}
|
||||
LUA_ARG_NUMBER(1, "matchcolor2", r, -DBL_MAX, DBL_MAX);
|
||||
LUA_ARG_NUMBER(2, "matchcolor2", g, -DBL_MAX, DBL_MAX);
|
||||
LUA_ARG_NUMBER(3, "matchcolor2", b, -DBL_MAX, DBL_MAX);
|
||||
|
||||
c = Best_color_perceptual(clamp_byte(r),clamp_byte(g),clamp_byte(b));
|
||||
if (nb_args == 3)
|
||||
{
|
||||
c = Best_color_perceptual(clamp_byte(r),clamp_byte(g),clamp_byte(b));
|
||||
}
|
||||
else // nb_args == 4
|
||||
{
|
||||
float weight;
|
||||
LUA_ARG_NUMBER(4, "matchcolor2", weight, -DBL_MAX, DBL_MAX);
|
||||
c = Best_color_perceptual_weighted(clamp_byte(r),clamp_byte(g),clamp_byte(b),weight);
|
||||
}
|
||||
lua_pushinteger(L, c);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user