Ignore:
Timestamp:
Jun 16, 2008, 4:33:19 PM (13 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Added delayed (recurrent) functions, as well as a window-killing eyecandy
File:
1 edited

Legend:

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

    r2421 r2445  
    209209    cucul_printf(cv, x, y++, "See http://libcaca.zoy.org/wiki/neercs for more informations");
    210210}
     211
     212
     213
     214
     215#define DELAY 500000.0f
     216
     217int close_screen_recurrent(struct screen_list* screen_list, struct recurrent* rec, void *user, long long unsigned int t)
     218{
     219    long long unsigned int delta = t - rec->start_time;
     220
     221    screen_list->dont_update_coords = 1;
     222    rec->kill_me = 0;
     223    if(delta>=DELAY)
     224    {
     225        rec->kill_me = 1;
     226        remove_screen(screen_list, screen_list->pty, 1);
     227        screen_list->pty = screen_list->prevpty;
     228        screen_list->prevpty = 0;
     229        screen_list->dont_update_coords = 0;
     230    }
     231    else
     232    {
     233        float r = 1 - ((DELAY - (DELAY - delta)) / DELAY);
     234        cucul_canvas_t *old, *new;
     235        struct screen *s = screen_list->screen[screen_list->pty];
     236        int w = s->orig_w * r;
     237        int h = s->orig_h * r;
     238
     239
     240        old = s->cv;
     241        new = cucul_create_canvas(w, h);
     242        cucul_blit(new, 0, 0, old, NULL);
     243        s->cv = new;
     244        cucul_free_canvas(old);
     245        set_tty_size(s->fd, w, h);
     246
     247        s->w = w;
     248        s->h = h;
     249
     250        s->x =
     251            (s->orig_x * r) +
     252            ((s->orig_w/2) - s->w/2);
     253        s->y =
     254            (s->orig_y * r) +
     255            ((s->orig_h/2) - s->h/2);
     256
     257    }
     258
     259    return 1;
     260}
Note: See TracChangeset for help on using the changeset viewer.