choose the background colour.tags/v0.99.beta14
@@ -89,9 +89,9 @@ void Cucul::printf ( int x , int y , char const * format,...) | |||||
} | } | ||||
void Cucul::clear () | |||||
void Cucul::clear ( unsigned char bg ) | |||||
{ | { | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, bg); | |||||
} | } | ||||
void Cucul::blit ( int x, int y, Cucul* c1, Cucul* c2) | void Cucul::blit ( int x, int y, Cucul* c1, Cucul* c2) | ||||
@@ -67,7 +67,7 @@ class Cucul { | |||||
void printf ( int x , int y , char const * format,...); | void printf ( int x , int y , char const * format,...); | ||||
void putchar (int x, int y, char ch); | void putchar (int x, int y, char ch); | ||||
void putstr (int x, int y, char *str); | void putstr (int x, int y, char *str); | ||||
void clear (); | |||||
void clear (unsigned char bg); | |||||
void blit ( int, int, Cucul* c1, Cucul* c2); | void blit ( int, int, Cucul* c1, Cucul* c2); | ||||
void invert (); | void invert (); | ||||
void flip (); | void flip (); | ||||
@@ -154,15 +154,18 @@ void cucul_printf(cucul_canvas_t *cv, int x, int y, char const *format, ...) | |||||
/** \brief Clear the canvas. | /** \brief Clear the canvas. | ||||
* | * | ||||
* This function clears the canvas using a black background. | |||||
* This function clears the canvas using the given background colour. | |||||
* | |||||
* \param cv The canvas to clear. | |||||
* \param bg The background colour to use. | |||||
*/ | */ | ||||
void cucul_clear(cucul_canvas_t *cv) | |||||
void cucul_clear_canvas(cucul_canvas_t *cv, unsigned char bg) | |||||
{ | { | ||||
uint16_t oldfg = cv->fgcolor; | uint16_t oldfg = cv->fgcolor; | ||||
uint16_t oldbg = cv->bgcolor; | uint16_t oldbg = cv->bgcolor; | ||||
int y = cv->height; | int y = cv->height; | ||||
cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | |||||
cucul_set_color(cv, CUCUL_COLOR_DEFAULT, bg); | |||||
/* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ | /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ | ||||
while(y--) | while(y--) | ||||
@@ -104,7 +104,7 @@ char const *cucul_get_color_name(unsigned int); | |||||
void cucul_putchar(cucul_canvas_t *, int, int, char); | void cucul_putchar(cucul_canvas_t *, int, int, char); | ||||
void cucul_putstr(cucul_canvas_t *, int, int, char const *); | void cucul_putstr(cucul_canvas_t *, int, int, char const *); | ||||
void cucul_printf(cucul_canvas_t *, int, int, char const *, ...); | void cucul_printf(cucul_canvas_t *, int, int, char const *, ...); | ||||
void cucul_clear(cucul_canvas_t *); | |||||
void cucul_clear_canvas(cucul_canvas_t *, unsigned char); | |||||
void cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *); | void cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *); | ||||
/* @} */ | /* @} */ | ||||
@@ -321,7 +321,7 @@ int main(int argc, char **argv) | |||||
free(buffer); | free(buffer); | ||||
} | } | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
if(!items) | if(!items) | ||||
{ | { | ||||
@@ -53,7 +53,7 @@ int main(int argc, char **argv) | |||||
lines = cols * i->h * 6 / i->w / 10; | lines = cols * i->h * 6 / i->w / 10; | ||||
cucul_set_canvas_size(cv, cols, lines); | cucul_set_canvas_size(cv, cols, lines); | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_TRANSPARENT); | |||||
cucul_dither_bitmap(cv, 0, 0, cols - 1, lines - 1, i->dither, i->pixels); | cucul_dither_bitmap(cv, 0, 0, cols - 1, lines - 1, i->dither, i->pixels); | ||||
unload_image(i); | unload_image(i); | ||||
@@ -35,7 +35,7 @@ int main(int argc, char **argv) | |||||
if(!dp) | if(!dp) | ||||
return 1; | return 1; | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
for(i = 0; i < 16; i++) | for(i = 0; i < 16; i++) | ||||
{ | { | ||||
cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | ||||
@@ -142,7 +142,7 @@ int main(int argc, char **argv) | |||||
} | } | ||||
if(demo) | if(demo) | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
} | } | ||||
else if(ev.type & CACA_EVENT_MOUSE_MOTION) | else if(ev.type & CACA_EVENT_MOUSE_MOTION) | ||||
{ | { | ||||
@@ -196,7 +196,7 @@ static void display_menu(void) | |||||
int xo = cucul_get_canvas_width(cv) - 2; | int xo = cucul_get_canvas_width(cv) - 2; | ||||
int yo = cucul_get_canvas_height(cv) - 2; | int yo = cucul_get_canvas_height(cv) - 2; | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | ||||
cucul_draw_thin_box(cv, 1, 1, xo, yo); | cucul_draw_thin_box(cv, 1, 1, xo, yo); | ||||
@@ -236,7 +236,7 @@ static void demo_all(void) | |||||
i++; | i++; | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
/* Draw the sun */ | /* Draw the sun */ | ||||
cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); | ||||
@@ -349,7 +349,7 @@ static void demo_color(void) | |||||
int i, j; | int i, j; | ||||
char buf[BUFSIZ]; | char buf[BUFSIZ]; | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
for(i = 0; i < 16; i++) | for(i = 0; i < 16; i++) | ||||
{ | { | ||||
sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i)); | sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i)); | ||||
@@ -81,7 +81,7 @@ int main(int argc, char **argv) | |||||
} | } | ||||
while(ret); | while(ret); | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
/* Print current event */ | /* Print current event */ | ||||
cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); | cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); | ||||
@@ -90,7 +90,7 @@ int main(void) | |||||
cucul_get_canvas_height(cw) - 1, right, buffer); | cucul_get_canvas_height(cw) - 1, right, buffer); | ||||
/* Draw something on the mask */ | /* Draw something on the mask */ | ||||
cucul_clear(mask); | |||||
cucul_clear_canvas(mask, CUCUL_COLOR_BLACK); | |||||
cucul_set_color(mask, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE); | cucul_set_color(mask, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE); | ||||
cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x)) | cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x)) | ||||
* 0.5 * cucul_get_canvas_width(mask), | * 0.5 * cucul_get_canvas_width(mask), | ||||
@@ -100,7 +100,7 @@ int main(int argc, char **argv) | |||||
} | } | ||||
cucul_clear(cv); | |||||
cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); | |||||
cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); | ||||
cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1, | cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1, | ||||