source: libcaca/trunk/test/frames.c @ 1048

Last change on this file since 1048 was 1048, checked in by Jean-Yves Lamoureux, 14 years ago
  • Updated kernel 'driver', still not working, but most of the work is done
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/*
2 *  frames        canvas frame switching features
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: frames.c 1048 2006-09-17 12:44:18Z jylam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "config.h"
15#include "common.h"
16#if !defined(__KERNEL__)
17#   if defined(HAVE_INTTYPES_H)
18#      include <inttypes.h>
19#   endif
20
21#   include <stdio.h>
22#endif
23#include "cucul.h"
24#include "caca.h"
25
26int main(int argc, char *argv[])
27{
28    cucul_canvas_t *cv;
29    caca_display_t *dp;
30
31    int n, frame;
32
33    /* Create a canvas with 200 frames */
34    cv = cucul_create_canvas(0, 0);
35    for(frame = 1; frame < 200; frame++)
36        cucul_create_canvas_frame(cv, frame);
37
38    /* Resize it to 150 x 80 (around 19MB) */
39    cucul_set_canvas_size(cv, 150, 80);
40
41    /* Resize it to a more decent size */
42    cucul_set_canvas_size(cv, 41, 16);
43
44    dp = caca_create_display(cv);
45    caca_set_display_time(dp, 50000);
46
47    /* Fill the first 16 frames with a different colour */
48    for(frame = 0; frame < 16; frame++)
49    {
50        cucul_set_canvas_frame(cv, frame);
51        cucul_set_color(cv, CUCUL_COLOR_WHITE, frame);
52        cucul_clear_canvas(cv);
53        cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
54        cucul_putstr(cv, frame * 5 / 2, frame, "CACA");
55    }
56
57    n = 0;
58    while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
59    {
60        cucul_set_canvas_frame(cv, n % 16);
61        caca_refresh_display(dp);
62        n++;
63    }
64
65    caca_free_display(dp);
66
67    /* It is possible, though not necessary, to free all additional frames
68     * separately. */
69    cucul_free_canvas(cv);
70
71    return 0;
72}
73
Note: See TracBrowser for help on using the repository browser.