From 313e0ce8a5a6cc73c3da75390422842afacb5e06 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 10 Sep 2008 15:35:17 +0200 Subject: [PATCH] lua: push color without alpha is not needed Signed-off-by: Julien Danjou --- lua.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua.c b/lua.c index 7ea9ed172..a4557bb47 100644 --- a/lua.c +++ b/lua.c @@ -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)); }