source: libcaca/trunk/examples/transform.c @ 2299

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 3.4 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: transform.c 2299 2008-04-19 12:42:50Z 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
17#if !defined(__KERNEL__)
18#   include <stdio.h>
19#   include <string.h>
20#endif
21
22#include "cucul.h"
23#include "caca.h"
24
25static char const pig[] =
26    ",--.   ,--.\n"
27    "\\  /-~-\\  /\n"
28    " )' o O `(\n"
29    "(  ,---.  )\n"
30    " `(_o_o_)'\n"
31    "   )`-'(\n";
32
33static char const duck[] =
34    "                ,~~.\n"
35    "    __     ,   (  O )>\n"
36    "___( o)>   )`~~'   (\n"
37    "\\ <_. )   (  .__)   )\n"
38    " `---'     `-.____,'\n";
39
40int main(int argc, char *argv[])
41{
42    cucul_canvas_t *cv, *image, *tmp, *sprite;
43    caca_display_t *dp;
44
45    cv = cucul_create_canvas(0, 0);
46    if(cv == NULL)
47    {
48        printf("Can't created canvas\n");
49        return -1;
50    }
51    dp = caca_create_display(cv);
52    if(dp == NULL)
53    {
54        printf("Can't create display\n");
55        return -1;
56    }
57
58    image = cucul_create_canvas(70, 6);
59    tmp = cucul_create_canvas(70, 6);
60    sprite = cucul_create_canvas(0, 0);
61
62    cucul_set_color_ansi(sprite, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
63    cucul_import_memory(sprite, pig, strlen(pig), "text");
64    cucul_blit(image, 55, 0, sprite, NULL);
65
66    cucul_set_color_ansi(sprite, CUCUL_LIGHTGREEN, CUCUL_BLACK);
67    cucul_import_memory(sprite, duck, strlen(duck), "text");
68    cucul_blit(image, 30, 1, sprite, NULL);
69
70    cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
71    cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
72    cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
73    cucul_put_char(image, 38, 1, '|');
74
75    cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
76    cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
77
78    cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
79    cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
80    cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
81    cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
82    cucul_put_str(image, 4, 3, "▓▒░");
83    cucul_put_str(image, 4, 4, "▓▒░");
84    cucul_put_str(image, 24, 3, "░▒▓");
85    cucul_put_str(image, 24, 4, "░▒▓");
86
87    /* Blit the transformed canvas onto the main canvas */
88    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
89    cucul_put_str(cv, 0, 0, "normal");
90    cucul_blit(cv, 10, 0, image, NULL);
91
92    cucul_put_str(cv, 0, 6, "flip");
93    cucul_blit(tmp, 0, 0, image, NULL);
94    cucul_flip(tmp);
95    cucul_blit(cv, 10, 6, tmp, NULL);
96
97    cucul_put_str(cv, 0, 12, "flop");
98    cucul_blit(tmp, 0, 0, image, NULL);
99    cucul_flop(tmp);
100    cucul_blit(cv, 10, 12, tmp, NULL);
101
102    cucul_put_str(cv, 0, 18, "rotate");
103    cucul_blit(tmp, 0, 0, image, NULL);
104    cucul_rotate_180(tmp);
105    cucul_blit(cv, 10, 18, tmp, NULL);
106
107    caca_refresh_display(dp);
108
109    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
110
111    caca_free_display(dp);
112    cucul_free_canvas(tmp);
113    cucul_free_canvas(sprite);
114    cucul_free_canvas(image);
115    cucul_free_canvas(cv);
116
117    return 0;
118}
119
Note: See TracBrowser for help on using the repository browser.