source: libcaca/trunk/test/blit.c @ 1389

Last change on this file since 1389 was 1389, checked in by Sam Hocevar, 13 years ago
  • Started writing a full API test. Not sure where it'll lead.
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
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 1389 2006-11-13 23:00:02Z 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#include "common.h"
16#if !defined(__KERNEL__)
17#   include <stdio.h>
18#   include <string.h>
19#endif
20
21#include "cucul.h"
22#include "caca.h"
23
24static char const pig[] =
25    "  ,__         __,\n"
26    "   \\)`\\_..._/`(/\n"
27    "   .'  _   _  '.\n"
28    "  /    o\\ /o   \\\n"
29    "  |    .-.-.    |  _\n"
30    "  |   /() ()\\   | (,`)\n"
31    " / \\  '-----'  / \\ .'\n"
32    "|   '-..___..-'   |\n"
33    "|                 |\n"
34    "|                 |\n"
35    ";                 ;\n"
36    " \\      / \\      /\n"
37    "  \\-..-/'-'\\-..-/\n"
38    "jgs\\/\\/     \\/\\/\n";
39
40int main(int argc, char *argv[])
41{
42    cucul_canvas_t *cv, *sprite;
43    caca_display_t *dp;
44
45    cv = cucul_create_canvas(0, 0);
46    dp = caca_create_display(cv);
47
48    sprite = cucul_create_canvas(0, 0);
49    cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK);
50    cucul_import_memory(sprite, pig, strlen(pig), "text");
51    cucul_set_canvas_handle(sprite, cucul_get_canvas_width(sprite) / 2,
52                                    cucul_get_canvas_height(sprite) / 2);
53
54    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
55    cucul_put_str(cv, 0, 0, "Centered sprite");
56
57    cucul_blit(cv, cucul_get_canvas_width(cv) / 2,
58                   cucul_get_canvas_height(cv) / 2, sprite, NULL);
59
60    caca_refresh_display(dp);
61
62    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
63
64    caca_free_display(dp);
65    cucul_free_canvas(sprite);
66    cucul_free_canvas(cv);
67
68    return 0;
69}
70
Note: See TracBrowser for help on using the repository browser.