source: libcaca/trunk/test/text.c @ 1394

Last change on this file since 1394 was 1394, checked in by Sam Hocevar, 14 years ago
  • Documented flip/flop/rotate as being involutive.
  • Updated text test.
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/*
2 *  text          canvas text import/export
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: text.c 1394 2006-11-14 07:59:52Z 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#   include <stdlib.h>
23#endif
24#include "cucul.h"
25
26#define STRING \
27  "  _,----._  \n" \
28  " (/ @  @ \\) \n" \
29  "  |  OO  |  \n" \
30  "  \\ `--' /  \n" \
31  "   `----'   \n" \
32  "Hello world!\n"
33
34int main(int argc, char *argv[])
35{
36    cucul_canvas_t *cv, *pig;
37    void *buffer;
38    unsigned long int len;
39
40    pig = cucul_create_canvas(0, 0);
41    cucul_import_memory(pig, STRING, strlen(STRING), "text");
42
43    cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
44                             cucul_get_canvas_height(pig) * 2);
45
46    cucul_blit(cv, 0, 0, pig, NULL);
47    cucul_flip(pig);
48    cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
49    cucul_flip(pig);
50    cucul_flop(pig);
51    cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
52    cucul_flop(pig);
53    cucul_rotate(pig);
54    cucul_blit(cv, cucul_get_canvas_width(pig),
55                   cucul_get_canvas_height(pig), pig, NULL);
56
57    buffer = cucul_export_memory(cv, "utf8", &len);
58    fwrite(buffer, len, 1, stdout);
59    free(buffer);
60
61    cucul_free_canvas(pig);
62    cucul_free_canvas(cv);
63
64    return 0;
65}
66
Note: See TracBrowser for help on using the repository browser.