Ignore:
Timestamp:
Jul 10, 2009, 12:44:42 PM (11 years ago)
Author:
Pascal Terjan
Message:
  • Use masks in screensaver to avoid truncated toasters
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/screensaver.c

    r2995 r3549  
    5656#define PRECISION 100
    5757
    58 char toaster1_text[] = {
     58char toaster_text[3][99] = { {
    5959"      __._ \n"
    6060"   .-'== _',\n"
     
    6262"   | --|   \\'.-_ \n"
    6363"   |   | \\  \" _.\n"
    64 "    `-_|.-\\_.-\n"};
    65 
    66 char toaster2_text[] = {
     64"    `-_|.-\\_.-\n"
     65}, {
    6766"      __._ \n"
    6867"   .-'== _',\n"
     
    7170"   |   | ___.-\n"
    7271"    `-_|.-\n"
    73 };
    74 
    75 char toaster3_text[] = {
     72}, {
    7673"   _- __._\n"
    7774"  /.-'== _',_.-.\n"
     
    7976"   | --| / .-\n"
    8077"   |   |  _.|\n"
    81 "    `-_|.-\n"};
     78"    `-_|.-\n"} };
     79
     80char toaster_mask[3][99] = { {
     81"      __._ \n"
     82"   .-'== _',\n"
     83"  <|_=X.-'XX|\n"
     84"   |X--|XXX\\'.-_ \n"
     85"   |XXX|X\\XX\"X_.\n"
     86"    `-_|.-\\_.-\n"
     87}, {
     88
     89"      __._ \n"
     90"   .-'== _',\n"
     91"  \\|_= .-'XX|\n"
     92"   |X--|XX__'-.\n"
     93"   |XXX|X___.-\n"
     94"    `-_|.-\n"
     95}, {
     96"   _- __._\n"
     97"  /.-'== _',_.-.\n"
     98"  \\|_= .-'/XX_.'\n"
     99"   |X--|X/X.-\n"
     100"   |XXX|XX_.|\n"
     101"    `-_|.-\n"} };
    82102
    83103struct flying_toaster
     
    85105    int x[COUNT], y[COUNT], s[COUNT];
    86106    caca_canvas_t **toaster;
     107    caca_canvas_t **mask;
    87108};
    88109
     
    96117    flying_toaster = malloc(sizeof(struct flying_toaster));
    97118    flying_toaster->toaster = (caca_canvas_t **)malloc(sizeof(caca_canvas_t*)*3);
     119    flying_toaster->mask = (caca_canvas_t **)malloc(sizeof(caca_canvas_t*)*3);
    98120
    99 
    100     flying_toaster->toaster[0] = caca_create_canvas(0, 0);
    101     flying_toaster->toaster[1] = caca_create_canvas(0, 0);
    102     flying_toaster->toaster[2] = caca_create_canvas(0, 0);
    103 
    104 
    105     caca_import_memory(flying_toaster->toaster[0],
    106                         toaster1_text,
    107                         strlen(toaster1_text), "ansi");
    108     caca_import_memory(flying_toaster->toaster[1],
    109                         toaster2_text,
    110                         strlen(toaster2_text), "ansi");
    111     caca_import_memory(flying_toaster->toaster[2],
    112                         toaster3_text,
    113                         strlen(toaster3_text), "ansi");
     121    for(i = 0; i < 3; i++)
     122    {
     123        flying_toaster->toaster[i] = caca_create_canvas(0, 0);
     124        flying_toaster->mask[i] = caca_create_canvas(0, 0);
     125        caca_import_memory(flying_toaster->toaster[i],
     126                           toaster_text[i],
     127                           strlen(toaster_text[i]), "ansi");       
     128        caca_import_memory(flying_toaster->mask[i],
     129                           toaster_mask[i],
     130                           strlen(toaster_mask[i]), "ansi");       
     131    }
    114132
    115133    for(i = 0; i < COUNT; i++)
     
    149167    caca_clear_canvas(screen_list->cv);
    150168
    151 
    152 
    153169    for(i = 0; i < COUNT; i++)
    154170    {
    155         caca_blit(screen_list->cv, d->x[i]/PRECISION, d->y[i]/PRECISION, d->toaster[d->s[i]/PRECISION], NULL);
     171        caca_blit(screen_list->cv, d->x[i]/PRECISION, d->y[i]/PRECISION, d->toaster[d->s[i]/PRECISION], d->mask[d->s[i]/PRECISION]);
    156172
    157173        d->x[i]-=40;
Note: See TracChangeset for help on using the changeset viewer.