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

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