lua: push color without alpha is not needed

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-10 15:35:17 +02:00
parent 6614ffcb06
commit 313e0ce8a5
1 changed files with 5 additions and 1 deletions

6
lua.c
View File

@ -979,6 +979,10 @@ luaA_pushcolor(lua_State *L, const xcolor_t *c)
uint8_t b = (unsigned)c->blue * 0xff / 0xffff;
uint8_t a = (unsigned)c->alpha * 0xff / 0xffff;
char s[10];
snprintf(s, sizeof(s), "#%02x%02x%02x%02x", r, g, b, a);
/* do not print alpha if it's full */
if(a == 0xff)
snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b);
else
snprintf(s, sizeof(s), "#%02x%02x%02x%02x", r, g, b, a);
lua_pushlstring(L, s, sizeof(s));
}