diff --git a/configure.ac b/configure.ac index 14b8643..dfa8435 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_PREREQ(2.50) AC_CONFIG_AUX_DIR(autotools) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE(libcaca, 0.10) +AM_INIT_AUTOMAKE(libcaca, 0.10.beta1) LT_VERSION="10:0:10" AC_SUBST(LT_VERSION) AM_CONFIG_HEADER(config.h) diff --git a/cpp/cucul++.cpp b/cpp/cucul++.cpp index 3383901..d17f993 100644 --- a/cpp/cucul++.cpp +++ b/cpp/cucul++.cpp @@ -100,9 +100,9 @@ void Cucul::printf(int x, int y, char const * format,...) putstr(x, y, buf); } -void Cucul::clear(unsigned char bg ) +void Cucul::clear(void) { - cucul_clear_canvas(cv, bg); + cucul_clear_canvas(cv); } void Cucul::blit(int x, int y, Cucul* c1, Cucul* c2) diff --git a/cpp/cucul++.h b/cpp/cucul++.h index b3d03b9..5464217 100644 --- a/cpp/cucul++.h +++ b/cpp/cucul++.h @@ -70,7 +70,7 @@ class Cucul void printf(int x , int y , char const * format,...); void putchar(int x, int y, char ch); void putstr(int x, int y, char *str); - void clear(unsigned char bg); + void clear(void); void blit(int, int, Cucul* c1, Cucul* c2); void invert(); void flip(); diff --git a/cucul/canvas.c b/cucul/canvas.c index fc3ead8..2b2e4ce 100644 --- a/cucul/canvas.c +++ b/cucul/canvas.c @@ -154,25 +154,21 @@ void cucul_printf(cucul_canvas_t *cv, int x, int y, char const *format, ...) /** \brief Clear the canvas. * - * This function clears the canvas using the given background colour. + * This function clears the canvas using the current background colour. * * \param cv The canvas to clear. - * \param bg The background colour to use. */ -void cucul_clear_canvas(cucul_canvas_t *cv, unsigned char bg) +void cucul_clear_canvas(cucul_canvas_t *cv) { - uint16_t oldfg = cv->fgcolor; - uint16_t oldbg = cv->bgcolor; - int y = cv->height; - - cucul_set_color(cv, CUCUL_COLOR_DEFAULT, bg); + uint32_t color = (cv->bgcolor << 16) | cv->fgcolor; + unsigned int n; /* We could use SLsmg_cls() etc., but drawing empty lines is much faster */ - while(y--) - cucul_putstr(cv, 0, y, cv->empty_line); - - cv->fgcolor = oldfg; - cv->bgcolor = oldbg; + for(n = cv->width * cv->height; n--; ) + { + cv->chars[n] = (uint32_t)' '; + cv->attr[n] = color; + } } /** \brief Blit a canvas onto another one. diff --git a/cucul/cucul.h b/cucul/cucul.h index 1cece8a..36aee45 100644 --- a/cucul/cucul.h +++ b/cucul/cucul.h @@ -103,7 +103,7 @@ char const *cucul_get_color_name(unsigned int); void cucul_putchar(cucul_canvas_t *, int, int, char); void cucul_putstr(cucul_canvas_t *, int, int, char const *); void cucul_printf(cucul_canvas_t *, int, int, char const *, ...); -void cucul_clear_canvas(cucul_canvas_t *, unsigned char); +void cucul_clear_canvas(cucul_canvas_t *); void cucul_blit(cucul_canvas_t *, int, int, cucul_canvas_t const *, cucul_canvas_t const *); /* @} */ diff --git a/src/cacaview.c b/src/cacaview.c index 11eb3c5..1243395 100644 --- a/src/cacaview.c +++ b/src/cacaview.c @@ -321,7 +321,8 @@ int main(int argc, char **argv) free(buffer); } - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); if(!items) { diff --git a/src/img2irc.c b/src/img2irc.c index f06a89e..aadcd3d 100644 --- a/src/img2irc.c +++ b/src/img2irc.c @@ -53,7 +53,8 @@ int main(int argc, char **argv) lines = cols * i->h * 6 / i->w / 10; cucul_set_canvas_size(cv, cols, lines); - cucul_clear_canvas(cv, CUCUL_COLOR_TRANSPARENT); + cucul_set_color(cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_TRANSPARENT); + cucul_clear_canvas(cv); cucul_dither_bitmap(cv, 0, 0, cols, lines, i->dither, i->pixels); unload_image(i); diff --git a/test/colors.c b/test/colors.c index a7244ba..c4f1730 100644 --- a/test/colors.c +++ b/test/colors.c @@ -35,7 +35,8 @@ int main(int argc, char **argv) if(!dp) return 1; - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); for(i = 0; i < 16; i++) { cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); diff --git a/test/demo.c b/test/demo.c index 50428df..9512514 100644 --- a/test/demo.c +++ b/test/demo.c @@ -142,7 +142,10 @@ int main(int argc, char **argv) } if(demo) - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + { + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); + } } else if(ev.type & CACA_EVENT_MOUSE_MOTION) { @@ -196,8 +199,8 @@ static void display_menu(void) int xo = cucul_get_canvas_width(cv) - 2; int yo = cucul_get_canvas_height(cv) - 2; - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); cucul_draw_thin_box(cv, 1, 1, xo, yo); cucul_putstr(cv, (xo - strlen("libcaca demo")) / 2, 3, "libcaca demo"); @@ -236,7 +239,8 @@ static void demo_all(void) i++; - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); /* Draw the sun */ cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); @@ -349,7 +353,8 @@ static void demo_color(void) int i, j; char buf[BUFSIZ]; - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); for(i = 0; i < 16; i++) { sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_get_color_name(i)); diff --git a/test/event.c b/test/event.c index d084e44..7869bc6 100644 --- a/test/event.c +++ b/test/event.c @@ -81,7 +81,8 @@ int main(int argc, char **argv) } while(ret); - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); /* Print current event */ cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); diff --git a/test/gamma.c b/test/gamma.c index cc253b7..7cc8432 100644 --- a/test/gamma.c +++ b/test/gamma.c @@ -90,7 +90,8 @@ int main(void) cucul_get_canvas_height(cw), right, buffer); /* Draw something on the mask */ - cucul_clear_canvas(mask, CUCUL_COLOR_BLACK); + cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(mask); cucul_set_color(mask, CUCUL_COLOR_WHITE, CUCUL_COLOR_WHITE); cucul_fill_ellipse(mask, (1.0 + sin(0.05 * (float)x)) * 0.5 * cucul_get_canvas_width(mask), diff --git a/test/spritedit.c b/test/spritedit.c index 861e775..c79a35b 100644 --- a/test/spritedit.c +++ b/test/spritedit.c @@ -100,9 +100,9 @@ int main(int argc, char **argv) } - cucul_clear_canvas(cv, CUCUL_COLOR_BLACK); - cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); + cucul_clear_canvas(cv); + cucul_draw_thin_box(cv, 0, 0, cucul_get_canvas_width(cv) - 1, cucul_get_canvas_height(cv) - 1);