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

Last change on this file since 2138 was 2101, checked in by Sam Hocevar, 13 years ago
  • Rename "test" to "examples". The former will become a real testsuite.
  • Autodetect zzuf in the configure step. It might become handy.
  • Property svn:keywords set to Id
File size: 3.5 KB
RevLine 
[675]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 2101 2007-11-30 23:48:39Z sam $
7 *
[1462]8 *  This program is free software. It comes without any warranty, to
[1452]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
[675]12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
[858]16#include "common.h"
[1048]17#if !defined(__KERNEL__)
18#   if defined(HAVE_INTTYPES_H)
19#      include <inttypes.h>
20#   endif
21#   include <stdio.h>
[1344]22#   include <string.h>
[675]23#endif
24
25#include "cucul.h"
26#include "caca.h"
27
[1344]28static char const pig[] =
29    ",--.   ,--.\n"
30    "\\  /-~-\\  /\n"
31    " )' o O `(\n"
32    "(  ,---.  )\n"
33    " `(_o_o_)'\n"
34    "   )`-'(\n";
[675]35
[1344]36static char const duck[] =
37    "                ,~~.\n"
38    "    __     ,   (  O )>\n"
39    "___( o)>   )`~~'   (\n"
40    "\\ <_. )   (  .__)   )\n"
41    " `---'     `-.____,'\n";
[675]42
[1048]43int main(int argc, char *argv[])
[675]44{
[1344]45    cucul_canvas_t *cv, *image, *tmp, *sprite;
[811]46    caca_display_t *dp;
[675]47
[813]48    cv = cucul_create_canvas(0, 0);
[1753]49    if(cv == NULL)
50    {
51        printf("Can't created canvas\n");
52        return -1;
53    }
[819]54    dp = caca_create_display(cv);
[1753]55    if(dp == NULL)
56    {
57        printf("Can't create display\n");
58        return -1;
59    }
[675]60
[1344]61    image = cucul_create_canvas(70, 6);
62    tmp = cucul_create_canvas(70, 6);
63    sprite = cucul_create_canvas(0, 0);
[675]64
[1344]65    cucul_set_color_ansi(sprite, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
66    cucul_import_memory(sprite, pig, strlen(pig), "text");
67    cucul_blit(image, 55, 0, sprite, NULL);
[675]68
[1344]69    cucul_set_color_ansi(sprite, CUCUL_LIGHTGREEN, CUCUL_BLACK);
70    cucul_import_memory(sprite, duck, strlen(duck), "text");
71    cucul_blit(image, 30, 1, sprite, NULL);
[675]72
[1344]73    cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
[1347]74    cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
[1344]75    cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
[1347]76    cucul_put_char(image, 38, 1, '|');
[675]77
[1344]78    cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
[1347]79    cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
[675]80
[1344]81    cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
[1347]82    cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
83    cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
[1344]84    cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
[1347]85    cucul_put_str(image, 4, 3, "▓▒░");
86    cucul_put_str(image, 4, 4, "▓▒░");
87    cucul_put_str(image, 24, 3, "░▒▓");
88    cucul_put_str(image, 24, 4, "░▒▓");
[675]89
90    /* Blit the transformed canvas onto the main canvas */
[1267]91    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
[1347]92    cucul_put_str(cv, 0, 0, "normal");
[1344]93    cucul_blit(cv, 10, 0, image, NULL);
94
[1347]95    cucul_put_str(cv, 0, 6, "flip");
[1344]96    cucul_blit(tmp, 0, 0, image, NULL);
97    cucul_flip(tmp);
98    cucul_blit(cv, 10, 6, tmp, NULL);
99
[1347]100    cucul_put_str(cv, 0, 12, "flop");
[1344]101    cucul_blit(tmp, 0, 0, image, NULL);
102    cucul_flop(tmp);
103    cucul_blit(cv, 10, 12, tmp, NULL);
104
[1347]105    cucul_put_str(cv, 0, 18, "rotate");
[1344]106    cucul_blit(tmp, 0, 0, image, NULL);
[1788]107    cucul_rotate_180(tmp);
[1344]108    cucul_blit(cv, 10, 18, tmp, NULL);
[675]109
[819]110    caca_refresh_display(dp);
[675]111
[849]112    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
[675]113
[819]114    caca_free_display(dp);
[1344]115    cucul_free_canvas(tmp);
[1345]116    cucul_free_canvas(sprite);
[1344]117    cucul_free_canvas(image);
[813]118    cucul_free_canvas(cv);
[675]119
120    return 0;
121}
122
Note: See TracBrowser for help on using the repository browser.