source: libcaca/trunk/test/transform.c @ 1347

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