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

Last change on this file since 1346 was 1346, checked in by Sam Hocevar, 13 years ago
  • Made cucul_blit() handle-aware. Added a blit test for that.
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1/*
2 *  unicode       libcaca Unicode rendering test program
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: blit.c 1346 2006-11-11 15:38:40Z 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#   if defined(HAVE_INTTYPES_H)
18#      include <inttypes.h>
19#   endif
20#   include <stdio.h>
21#   include <string.h>
22#endif
23
24#include "cucul.h"
25#include "caca.h"
26
27static char const pig[] =
28    "  ,__         __,\n"
29    "   \\)`\\_..._/`(/\n"
30    "   .'  _   _  '.\n"
31    "  /    o\\ /o   \\\n"
32    "  |    .-.-.    |  _\n"
33    "  |   /() ()\\   | (,`)\n"
34    " / \\  '-----'  / \\ .'\n"
35    "|   '-..___..-'   |\n"
36    "|                 |\n"
37    "|                 |\n"
38    ";                 ;\n"
39    " \\      / \\      /\n"
40    "  \\-..-/'-'\\-..-/\n"
41    "jgs\\/\\/     \\/\\/\n";
42
43int main(int argc, char *argv[])
44{
45    cucul_canvas_t *cv, *sprite;
46    caca_display_t *dp;
47
48    cv = cucul_create_canvas(0, 0);
49    dp = caca_create_display(cv);
50
51    sprite = cucul_create_canvas(0, 0);
52    cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK);
53    cucul_import_memory(sprite, pig, strlen(pig), "text");
54    cucul_set_canvas_handle(sprite, cucul_get_canvas_width(sprite) / 2,
55                                    cucul_get_canvas_height(sprite) / 2);
56
57    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
58    cucul_putstr(cv, 0, 0, "Centered sprite");
59
60    cucul_blit(cv, cucul_get_canvas_width(cv) / 2,
61                   cucul_get_canvas_height(cv) / 2, sprite, NULL);
62
63    caca_refresh_display(dp);
64
65    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
66
67    caca_free_display(dp);
68    cucul_free_canvas(sprite);
69    cucul_free_canvas(cv);
70
71    return 0;
72}
73
Note: See TracBrowser for help on using the repository browser.