Color: Remove, we are only using xcolor now

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2010-10-06 20:12:57 +02:00
parent e12212855b
commit 2c52bc7001
2 changed files with 0 additions and 83 deletions

69
color.c
View File

@ -75,29 +75,6 @@ color_parse(const char *colstr, ssize_t len,
return true; return true;
} }
/** Send a request to initialize a color.
* If you are only interested in the color's pixel value or need both, the pixel
* value and the rgba components, use xcolor_init_unchecked() and/or
* xcolor_to_color() instead.
* \param color color_t struct to store color into.
* \param colstr Color specification.
* \param len The length of colstr (which still MUST be NULL terminated).
* \return True if color allocation was successful.
*/
bool
color_init_unchecked(color_t *color, const char *colstr, ssize_t len)
{
if(!len)
return false;
/* The color is given in RGB value */
if(!color_parse(colstr, len, &color->red, &color->green, &color->blue, &color->alpha))
return false;
color->initialized = true;
return true;
}
/** Send a request to initialize a X color. /** Send a request to initialize a X color.
* If you are only interested in the rgba values and don't need the color's * If you are only interested in the rgba values and don't need the color's
* pixel value, you should use color_init_unchecked() instead. * pixel value, you should use color_init_unchecked() instead.
@ -174,29 +151,6 @@ xcolor_init_reply(xcolor_init_request_t req)
return false; return false;
} }
/** Convert a xcolor struct to a color one.
* \param xcol The X color.
* \param col The color.
* \return True if everything has been converted.
*/
bool
xcolor_to_color(const xcolor_t *xcol, color_t *col)
{
if (!xcol->initialized)
{
col->initialized = false;
return false;
}
col->initialized = true;
col->red = RGB_16TO8(xcol->red);
col->green = RGB_16TO8(xcol->green);
col->blue = RGB_16TO8(xcol->blue);
col->alpha = RGB_16TO8(xcol->alpha);
return true;
}
/** Push a color as a string onto the stack /** Push a color as a string onto the stack
* \param L The Lua VM state. * \param L The Lua VM state.
* \param c The color to push. * \param c The color to push.
@ -220,27 +174,4 @@ luaA_pushxcolor(lua_State *L, const xcolor_t c)
return 1; return 1;
} }
/** Push a color as a string onto the stack
* \param L The Lua VM state.
* \param c The color to push.
* \return The number of elements pushed on stack.
*/
int
luaA_pushcolor(lua_State *L, const color_t *c)
{
uint8_t r = c->red;
uint8_t g = c->green;
uint8_t b = c->blue;
uint8_t a = c->alpha;
char s[10];
int len;
/* do not print alpha if it's full */
if(a == 0xff)
len = snprintf(s, sizeof(s), "#%02x%02x%02x", r, g, b);
else
len = snprintf(s, sizeof(s), "#%02x%02x%02x%02x", r, g, b, a);
lua_pushlstring(L, s, len);
return 1;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

14
color.h
View File

@ -27,15 +27,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <lua.h> #include <lua.h>
typedef struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
uint8_t alpha;
bool initialized;
} color_t;
typedef struct typedef struct
{ {
uint32_t pixel; uint32_t pixel;
@ -55,15 +46,10 @@ typedef struct
const char *colstr; const char *colstr;
} xcolor_init_request_t; } xcolor_init_request_t;
bool color_init_unchecked(color_t *, const char *, ssize_t);
xcolor_init_request_t xcolor_init_unchecked(xcolor_t *, const char *, ssize_t); xcolor_init_request_t xcolor_init_unchecked(xcolor_t *, const char *, ssize_t);
bool xcolor_init_reply(xcolor_init_request_t); bool xcolor_init_reply(xcolor_init_request_t);
bool xcolor_to_color(const xcolor_t *, color_t *);
int luaA_pushxcolor(lua_State *, const xcolor_t); int luaA_pushxcolor(lua_State *, const xcolor_t);
int luaA_pushcolor(lua_State *, const color_t *);
#endif #endif