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

Last change on this file since 1462 was 1462, checked in by Sam Hocevar, 13 years ago
  • Bwarf, typo in the no warranty clause.
  • Property svn:keywords set to Id
File size: 1.7 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 1462 2006-12-12 01:53:54Z 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#   if defined(HAVE_INTTYPES_H)
19#      include <inttypes.h>
20#   endif
21#   include <stdio.h>
22#   include <string.h>
23#   include <stdlib.h>
24#endif
25#include "cucul.h"
26
27#define STRING \
28  "  _,----._  \n" \
29  " (/ @  @ \\) \n" \
30  "  |  OO  |  \n" \
31  "  \\ `--' /  \n" \
32  "   `----'   \n" \
33  "Hello world!\n"
34
35int main(int argc, char *argv[])
36{
37    cucul_canvas_t *cv, *pig;
38    void *buffer;
39    unsigned long int len;
40
41    pig = cucul_create_canvas(0, 0);
42    cucul_import_memory(pig, STRING, strlen(STRING), "text");
43
44    cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
45                             cucul_get_canvas_height(pig) * 2);
46
47    cucul_blit(cv, 0, 0, pig, NULL);
48    cucul_flip(pig);
49    cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
50    cucul_flip(pig);
51    cucul_flop(pig);
52    cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
53    cucul_flop(pig);
54    cucul_rotate(pig);
55    cucul_blit(cv, cucul_get_canvas_width(pig),
56                   cucul_get_canvas_height(pig), pig, NULL);
57
58    buffer = cucul_export_memory(cv, "utf8", &len);
59    fwrite(buffer, len, 1, stdout);
60    free(buffer);
61
62    cucul_free_canvas(pig);
63    cucul_free_canvas(cv);
64
65    return 0;
66}
67
Note: See TracBrowser for help on using the repository browser.