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 849 2006-04-22 19:46:43Z sam $ |
---|
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 | |
---|
16 | #if defined(HAVE_INTTYPES_H) |
---|
17 | # include <inttypes.h> |
---|
18 | #else |
---|
19 | typedef unsigned char uint8_t; |
---|
20 | typedef unsigned short uint16_t; |
---|
21 | typedef unsigned int uint32_t; |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <stdio.h> |
---|
25 | |
---|
26 | #include "cucul.h" |
---|
27 | #include "caca.h" |
---|
28 | |
---|
29 | int main(void) |
---|
30 | { |
---|
31 | cucul_canvas_t *cv; |
---|
32 | caca_display_t *dp; |
---|
33 | |
---|
34 | int n, frame; |
---|
35 | |
---|
36 | /* Create a canvas with 200 frames */ |
---|
37 | cv = cucul_create_canvas(0, 0); |
---|
38 | for(frame = 1; frame < 200; frame++) |
---|
39 | cucul_create_canvas_frame(cv, frame); |
---|
40 | |
---|
41 | /* Resize it to 150 x 80 (around 19MB) */ |
---|
42 | cucul_set_canvas_size(cv, 150, 80); |
---|
43 | |
---|
44 | /* Resize it to a more decent size */ |
---|
45 | cucul_set_canvas_size(cv, 41, 16); |
---|
46 | |
---|
47 | dp = caca_create_display(cv); |
---|
48 | caca_set_delay(dp, 50000); |
---|
49 | |
---|
50 | /* Fill the first 16 frames with a different colour */ |
---|
51 | for(frame = 0; frame < 16; frame++) |
---|
52 | { |
---|
53 | cucul_set_canvas_frame(cv, frame); |
---|
54 | cucul_set_color(cv, CUCUL_COLOR_WHITE, frame); |
---|
55 | cucul_clear_canvas(cv); |
---|
56 | cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); |
---|
57 | cucul_putstr(cv, frame * 5 / 2, frame, "CACA"); |
---|
58 | } |
---|
59 | |
---|
60 | n = 0; |
---|
61 | while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0)) |
---|
62 | { |
---|
63 | cucul_set_canvas_frame(cv, n % 16); |
---|
64 | caca_refresh_display(dp); |
---|
65 | n++; |
---|
66 | } |
---|
67 | |
---|
68 | caca_free_display(dp); |
---|
69 | |
---|
70 | /* It is possible, though not necessary, to free all additional frames |
---|
71 | * separately. */ |
---|
72 | cucul_free_canvas(cv); |
---|
73 | |
---|
74 | return 0; |
---|
75 | } |
---|
76 | |
---|