Bladeren bron

* Changed cucul_clear_canvas() again. It now uses the current foreground

and background colours to clear the screen.
tags/v0.99.beta14
Sam Hocevar sam 18 jaren geleden
bovenliggende
commit
bde0e5ca7e
12 gewijzigde bestanden met toevoegingen van 35 en 29 verwijderingen
  1. +1
    -1
      configure.ac
  2. +2
    -2
      cpp/cucul++.cpp
  3. +1
    -1
      cpp/cucul++.h
  4. +9
    -13
      cucul/canvas.c
  5. +1
    -1
      cucul/cucul.h
  6. +2
    -1
      src/cacaview.c
  7. +2
    -1
      src/img2irc.c
  8. +2
    -1
      test/colors.c
  9. +9
    -4
      test/demo.c
  10. +2
    -1
      test/event.c
  11. +2
    -1
      test/gamma.c
  12. +2
    -2
      test/spritedit.c

+ 1
- 1
configure.ac Bestand weergeven

@@ -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)


+ 2
- 2
cpp/cucul++.cpp Bestand weergeven

@@ -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)


+ 1
- 1
cpp/cucul++.h Bestand weergeven

@@ -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();


+ 9
- 13
cucul/canvas.c Bestand weergeven

@@ -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.


+ 1
- 1
cucul/cucul.h Bestand weergeven

@@ -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 *);
/* @} */



+ 2
- 1
src/cacaview.c Bestand weergeven

@@ -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)
{


+ 2
- 1
src/img2irc.c Bestand weergeven

@@ -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);


+ 2
- 1
test/colors.c Bestand weergeven

@@ -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);


+ 9
- 4
test/demo.c Bestand weergeven

@@ -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));


+ 2
- 1
test/event.c Bestand weergeven

@@ -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);


+ 2
- 1
test/gamma.c Bestand weergeven

@@ -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),


+ 2
- 2
test/spritedit.c Bestand weergeven

@@ -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);



Laden…
Annuleren
Opslaan