source: libcaca/branches/0.99.beta1/test/transform.c @ 3128

Last change on this file since 3128 was 849, checked in by Sam Hocevar, 16 years ago
  • Allow the caca_event_t *ev argument for caca_get_event() to be NULL.
  • 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 849 2006-04-22 19:46:43Z 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
16#if defined(HAVE_INTTYPES_H)
17#   include <inttypes.h>
18#else
19typedef unsigned char uint8_t;
20typedef unsigned short uint16_t;
21typedef unsigned int uint32_t;
22#endif
23
24#include <stdio.h>
25
26#include "cucul.h"
27#include "caca.h"
28
29static char const *pig[] =
30{
31    ",--.   ,--.",
32    "\\  /-~-\\  /",
33    " )' o O `(",
34    "(  ,---.  )",
35    " `(_o_o_)'",
36    "   )`-'(",
37    NULL
38};
39
40static char const *duck[] =
41{
42    "                ,~~.",
43    "    __     ,   (  O )>",
44    "___( o)>   )`~~'   (",
45    "\\ <_. )   (  .__)   )",
46    " `---'     `-.____,'",
47    NULL
48};
49
50int main(void)
51{
52    cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
53    caca_display_t *dp;
54    int i;
55
56    cv = cucul_create_canvas(0, 0);
57    dp = caca_create_display(cv);
58
59    normal = cucul_create_canvas(70, 6);
60    flip = cucul_create_canvas(70, 6);
61    flop = cucul_create_canvas(70, 6);
62    rotate = cucul_create_canvas(70, 6);
63
64    cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
65    for(i = 0; pig[i]; i++)
66        cucul_putstr(normal, 55, i, pig[i]);
67
68    cucul_set_color(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK);
69    for(i = 0; duck[i]; i++)
70        cucul_putstr(normal, 30, 1 + i, duck[i]);
71
72    cucul_set_color(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK);
73    cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !!");
74
75    cucul_set_color(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
76    cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
77
78    cucul_set_color(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED);
79    cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
80    cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
81    cucul_set_color(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED);
82    cucul_putstr(normal, 4, 3, "▓▒░");
83    cucul_putstr(normal, 4, 4, "▓▒░");
84    cucul_putstr(normal, 24, 3, "░▒▓");
85    cucul_putstr(normal, 24, 4, "░▒▓");
86
87    /* Flip, flop and rotate our working canvas */
88    cucul_blit(flip, 0, 0, normal, NULL);
89    cucul_flip(flip);
90
91    cucul_blit(flop, 0, 0, normal, NULL);
92    cucul_flop(flop);
93
94    cucul_blit(rotate, 0, 0, normal, NULL);
95    cucul_rotate(rotate);
96
97    /* Blit the transformed canvas onto the main canvas */
98    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
99    cucul_putstr(cv, 0, 0, "normal");
100    cucul_blit(cv, 10, 0, normal, NULL);
101    cucul_putstr(cv, 0, 6, "flip");
102    cucul_blit(cv, 10, 6, flip, NULL);
103    cucul_putstr(cv, 0, 12, "flop");
104    cucul_blit(cv, 10, 12, flop, NULL);
105    cucul_putstr(cv, 0, 18, "rotate");
106    cucul_blit(cv, 10, 18, rotate, NULL);
107
108    caca_refresh_display(dp);
109
110    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
111
112    caca_free_display(dp);
113    cucul_free_canvas(rotate);
114    cucul_free_canvas(flop);
115    cucul_free_canvas(flip);
116    cucul_free_canvas(normal);
117    cucul_free_canvas(cv);
118
119    return 0;
120}
121
Note: See TracBrowser for help on using the repository browser.