source: libcaca/trunk/test/transform.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: 3.3 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 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#endif
24
25#include "cucul.h"
26#include "caca.h"
27
28static char const pig[] =
29    ",--.   ,--.\n"
30    "\\  /-~-\\  /\n"
31    " )' o O `(\n"
32    "(  ,---.  )\n"
33    " `(_o_o_)'\n"
34    "   )`-'(\n";
35
36static char const duck[] =
37    "                ,~~.\n"
38    "    __     ,   (  O )>\n"
39    "___( o)>   )`~~'   (\n"
40    "\\ <_. )   (  .__)   )\n"
41    " `---'     `-.____,'\n";
42
43int main(int argc, char *argv[])
44{
45    cucul_canvas_t *cv, *image, *tmp, *sprite;
46    caca_display_t *dp;
47
48    cv = cucul_create_canvas(0, 0);
49    dp = caca_create_display(cv);
50
51    image = cucul_create_canvas(70, 6);
52    tmp = cucul_create_canvas(70, 6);
53    sprite = cucul_create_canvas(0, 0);
54
55    cucul_set_color_ansi(sprite, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
56    cucul_import_memory(sprite, pig, strlen(pig), "text");
57    cucul_blit(image, 55, 0, sprite, NULL);
58
59    cucul_set_color_ansi(sprite, CUCUL_LIGHTGREEN, CUCUL_BLACK);
60    cucul_import_memory(sprite, duck, strlen(duck), "text");
61    cucul_blit(image, 30, 1, sprite, NULL);
62
63    cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
64    cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
65    cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
66    cucul_put_char(image, 38, 1, '|');
67
68    cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
69    cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
70
71    cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
72    cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
73    cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
74    cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
75    cucul_put_str(image, 4, 3, "▓▒░");
76    cucul_put_str(image, 4, 4, "▓▒░");
77    cucul_put_str(image, 24, 3, "░▒▓");
78    cucul_put_str(image, 24, 4, "░▒▓");
79
80    /* Blit the transformed canvas onto the main canvas */
81    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
82    cucul_put_str(cv, 0, 0, "normal");
83    cucul_blit(cv, 10, 0, image, NULL);
84
85    cucul_put_str(cv, 0, 6, "flip");
86    cucul_blit(tmp, 0, 0, image, NULL);
87    cucul_flip(tmp);
88    cucul_blit(cv, 10, 6, tmp, NULL);
89
90    cucul_put_str(cv, 0, 12, "flop");
91    cucul_blit(tmp, 0, 0, image, NULL);
92    cucul_flop(tmp);
93    cucul_blit(cv, 10, 12, tmp, NULL);
94
95    cucul_put_str(cv, 0, 18, "rotate");
96    cucul_blit(tmp, 0, 0, image, NULL);
97    cucul_rotate(tmp);
98    cucul_blit(cv, 10, 18, tmp, NULL);
99
100    caca_refresh_display(dp);
101
102    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
103
104    caca_free_display(dp);
105    cucul_free_canvas(tmp);
106    cucul_free_canvas(sprite);
107    cucul_free_canvas(image);
108    cucul_free_canvas(cv);
109
110    return 0;
111}
112
Note: See TracBrowser for help on using the repository browser.