source: libcaca/trunk/examples/blit.c @ 4369

Last change on this file since 4369 was 4369, checked in by sam, 4 years ago

Add the copyright unit test and update copyright information everywhere.

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/*
2 *  blit          libcaca blit test program
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#include "config.h"
14
15#if !defined(__KERNEL__)
16#   include <stdio.h>
17#   include <string.h>
18#endif
19
20#include "caca.h"
21
22static char const pig[] =
23    "  ,__         __,\n"
24    "   \\)`\\_..._/`(/\n"
25    "   .'  _   _  '.\n"
26    "  /    o\\ /o   \\\n"
27    "  |    .-.-.    |  _\n"
28    "  |   /() ()\\   | (,`)\n"
29    " / \\  '-----'  / \\ .'\n"
30    "|   '-..___..-'   |\n"
31    "|                 |\n"
32    "|                 |\n"
33    ";                 ;\n"
34    " \\      / \\      /\n"
35    \\-..-/'-'\\-..-/\n"
36    "jgs\\/\\/     \\/\\/\n";
37
38int main(int argc, char *argv[])
39{
40    caca_canvas_t *cv, *sprite;
41    caca_display_t *dp;
42
43    cv = caca_create_canvas(80, 24);
44    if(cv == NULL)
45    {
46        printf("Failed to create canvas\n");
47        return 1;
48    }
49
50    dp = caca_create_display(cv);
51    if(dp == NULL)
52    {
53        printf("Failed to create display\n");
54        return 1;
55    }
56
57    sprite = caca_create_canvas(0, 0);
58    caca_set_color_ansi(sprite, CACA_LIGHTRED, CACA_BLACK);
59    caca_import_canvas_from_memory(sprite, pig, strlen(pig), "text");
60    caca_set_canvas_handle(sprite, caca_get_canvas_width(sprite) / 2,
61                                    caca_get_canvas_height(sprite) / 2);
62
63    caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
64    caca_put_str(cv, 0, 0, "Centered sprite");
65
66    caca_blit(cv, caca_get_canvas_width(cv) / 2,
67                   caca_get_canvas_height(cv) / 2, sprite, NULL);
68
69    caca_refresh_display(dp);
70
71    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
72
73    caca_free_display(dp);
74    caca_free_canvas(sprite);
75    caca_free_canvas(cv);
76
77    return 0;
78}
79
Note: See TracBrowser for help on using the repository browser.