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
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 2299 2008-04-19 12:42:50Z 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"
[2299]16
[1048]17#if !defined(__KERNEL__)
18#   include <stdio.h>
[1344]19#   include <string.h>
[675]20#endif
21
22#include "cucul.h"
23#include "caca.h"
24
[1344]25static char const pig[] =
26    ",--.   ,--.\n"
27    "\\  /-~-\\  /\n"
28    " )' o O `(\n"
29    "(  ,---.  )\n"
30    " `(_o_o_)'\n"
31    "   )`-'(\n";
[675]32
[1344]33static char const duck[] =
34    "                ,~~.\n"
35    "    __     ,   (  O )>\n"
36    "___( o)>   )`~~'   (\n"
37    "\\ <_. )   (  .__)   )\n"
38    " `---'     `-.____,'\n";
[675]39
[1048]40int main(int argc, char *argv[])
[675]41{
[1344]42    cucul_canvas_t *cv, *image, *tmp, *sprite;
[811]43    caca_display_t *dp;
[675]44
[813]45    cv = cucul_create_canvas(0, 0);
[1753]46    if(cv == NULL)
47    {
48        printf("Can't created canvas\n");
49        return -1;
50    }
[819]51    dp = caca_create_display(cv);
[1753]52    if(dp == NULL)
53    {
54        printf("Can't create display\n");
55        return -1;
56    }
[675]57
[1344]58    image = cucul_create_canvas(70, 6);
59    tmp = cucul_create_canvas(70, 6);
60    sprite = cucul_create_canvas(0, 0);
[675]61
[1344]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);
[675]65
[1344]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);
[675]69
[1344]70    cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
[1347]71    cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
[1344]72    cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
[1347]73    cucul_put_char(image, 38, 1, '|');
[675]74
[1344]75    cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
[1347]76    cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
[675]77
[1344]78    cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
[1347]79    cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
80    cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
[1344]81    cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
[1347]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, "░▒▓");
[675]86
87    /* Blit the transformed canvas onto the main canvas */
[1267]88    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
[1347]89    cucul_put_str(cv, 0, 0, "normal");
[1344]90    cucul_blit(cv, 10, 0, image, NULL);
91
[1347]92    cucul_put_str(cv, 0, 6, "flip");
[1344]93    cucul_blit(tmp, 0, 0, image, NULL);
94    cucul_flip(tmp);
95    cucul_blit(cv, 10, 6, tmp, NULL);
96
[1347]97    cucul_put_str(cv, 0, 12, "flop");
[1344]98    cucul_blit(tmp, 0, 0, image, NULL);
99    cucul_flop(tmp);
100    cucul_blit(cv, 10, 12, tmp, NULL);
101
[1347]102    cucul_put_str(cv, 0, 18, "rotate");
[1344]103    cucul_blit(tmp, 0, 0, image, NULL);
[1788]104    cucul_rotate_180(tmp);
[1344]105    cucul_blit(cv, 10, 18, tmp, NULL);
[675]106
[819]107    caca_refresh_display(dp);
[675]108
[849]109    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
[675]110
[819]111    caca_free_display(dp);
[1344]112    cucul_free_canvas(tmp);
[1345]113    cucul_free_canvas(sprite);
[1344]114    cucul_free_canvas(image);
[813]115    cucul_free_canvas(cv);
[675]116
117    return 0;
118}
119
Note: See TracBrowser for help on using the repository browser.