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

Last change on this file since 1805 was 1805, checked in by Sam Hocevar, 14 years ago
  • Implemented cucul_rotate_left_wide() and cucul_rotate_right_wide(). They suck massively for now.
  • Property svn:keywords set to Id
File size: 2.0 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 1805 2007-07-10 17:02:46Z 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  "  (/ @  @ \\)  \n" \
31  "   |  OO  |   \n" \
32  "   \\ `--' /   \n" \
33  "    `----'    \n" \
34  "              \n" \
35  " Hello world! \n" \
36  "              \n"
37
38int main(int argc, char *argv[])
39{
40    cucul_canvas_t *cv, *pig;
41    void *buffer;
42    unsigned long int len;
43
44    pig = cucul_create_canvas(0, 0);
45    cucul_import_memory(pig, STRING, strlen(STRING), "text");
46
47    cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
48                             cucul_get_canvas_height(pig) * 2);
49
50    if(cv == NULL || pig == NULL)
51    {
52        printf("Can't created canvas\n");
53        return -1;
54    }
55
56    cucul_blit(cv, 0, 0, pig, NULL);
57    cucul_flip(pig);
58    cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
59    cucul_flip(pig);
60    cucul_flop(pig);
61    cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
62    cucul_flop(pig);
63    cucul_rotate_180(pig);
64    cucul_blit(cv, cucul_get_canvas_width(pig),
65                   cucul_get_canvas_height(pig), pig, NULL);
66
67    buffer = cucul_export_memory(cv, "utf8", &len);
68    fwrite(buffer, len, 1, stdout);
69    free(buffer);
70
71    cucul_rotate_left_wide(cv);
72    buffer = cucul_export_memory(cv, "utf8", &len);
73    fwrite(buffer, len, 1, stdout);
74    free(buffer);
75
76    cucul_free_canvas(pig);
77    cucul_free_canvas(cv);
78
79    return 0;
80}
81
Note: See TracBrowser for help on using the repository browser.