1 | /* |
---|
2 | * blit libcaca blit test program |
---|
3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: blit.c 2101 2007-11-30 23:48:39Z sam $ |
---|
7 | * |
---|
8 | * This program is free software. It comes without any warranty, to |
---|
9 | * the extent permitted by applicable law. You can redistribute it |
---|
10 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | */ |
---|
14 | |
---|
15 | #include "config.h" |
---|
16 | #include "common.h" |
---|
17 | #if !defined(__KERNEL__) |
---|
18 | # include <stdio.h> |
---|
19 | # include <string.h> |
---|
20 | #endif |
---|
21 | |
---|
22 | #include "cucul.h" |
---|
23 | #include "caca.h" |
---|
24 | |
---|
25 | static char const pig[] = |
---|
26 | " ,__ __,\n" |
---|
27 | " \\)`\\_..._/`(/\n" |
---|
28 | " .' _ _ '.\n" |
---|
29 | " / o\\ /o \\\n" |
---|
30 | " | .-.-. | _\n" |
---|
31 | " | /() ()\\ | (,`)\n" |
---|
32 | " / \\ '-----' / \\ .'\n" |
---|
33 | "| '-..___..-' |\n" |
---|
34 | "| |\n" |
---|
35 | "| |\n" |
---|
36 | "; ;\n" |
---|
37 | " \\ / \\ /\n" |
---|
38 | " \\-..-/'-'\\-..-/\n" |
---|
39 | "jgs\\/\\/ \\/\\/\n"; |
---|
40 | |
---|
41 | int main(int argc, char *argv[]) |
---|
42 | { |
---|
43 | cucul_canvas_t *cv, *sprite; |
---|
44 | caca_display_t *dp; |
---|
45 | |
---|
46 | cv = cucul_create_canvas(80, 24); |
---|
47 | if(cv == NULL) |
---|
48 | { |
---|
49 | printf("Failed to create canvas\n"); |
---|
50 | return 1; |
---|
51 | } |
---|
52 | |
---|
53 | dp = caca_create_display(cv); |
---|
54 | if(dp == NULL) |
---|
55 | { |
---|
56 | printf("Failed to create display\n"); |
---|
57 | return 1; |
---|
58 | } |
---|
59 | |
---|
60 | sprite = cucul_create_canvas(0, 0); |
---|
61 | cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK); |
---|
62 | cucul_import_memory(sprite, pig, strlen(pig), "text"); |
---|
63 | cucul_set_canvas_handle(sprite, cucul_get_canvas_width(sprite) / 2, |
---|
64 | cucul_get_canvas_height(sprite) / 2); |
---|
65 | |
---|
66 | cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE); |
---|
67 | cucul_put_str(cv, 0, 0, "Centered sprite"); |
---|
68 | |
---|
69 | cucul_blit(cv, cucul_get_canvas_width(cv) / 2, |
---|
70 | cucul_get_canvas_height(cv) / 2, sprite, NULL); |
---|
71 | |
---|
72 | caca_refresh_display(dp); |
---|
73 | |
---|
74 | caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); |
---|
75 | |
---|
76 | caca_free_display(dp); |
---|
77 | cucul_free_canvas(sprite); |
---|
78 | cucul_free_canvas(cv); |
---|
79 | |
---|
80 | return 0; |
---|
81 | } |
---|
82 | |
---|