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

Last change on this file since 1256 was 1256, checked in by Sam Hocevar, 14 years ago
  • Remove cucul_set_color() from the exported API and replaced all calls with cucul_set_attr_ansi(). Old application will still compile (but issue a warning) and run, though.
  • Property svn:keywords set to Id
File size: 3.4 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 1256 2006-10-29 08:35:46Z 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#endif
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(int argc, char *argv[])
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_attr_ansi(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK, 0);
62    for(i = 0; pig[i]; i++)
63        cucul_putstr(normal, 55, i, pig[i]);
64
65    cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK, 0);
66    for(i = 0; duck[i]; i++)
67        cucul_putstr(normal, 30, 1 + i, duck[i]);
68
69    cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK, 0);
70    cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
71    cucul_set_attr_ansi(normal, CUCUL_COLOR_LIGHTRED, CUCUL_COLOR_BLACK, 0);
72    cucul_putchar(normal, 38, 1, '|');
73
74    cucul_set_attr_ansi(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK, 0);
75    cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
76
77    cucul_set_attr_ansi(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED, 0);
78    cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
79    cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
80    cucul_set_attr_ansi(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED, 0);
81    cucul_putstr(normal, 4, 3, "▓▒░");
82    cucul_putstr(normal, 4, 4, "▓▒░");
83    cucul_putstr(normal, 24, 3, "░▒▓");
84    cucul_putstr(normal, 24, 4, "░▒▓");
85
86    /* Flip, flop and rotate our working canvas */
87    cucul_blit(flip, 0, 0, normal, NULL);
88    cucul_flip(flip);
89
90    cucul_blit(flop, 0, 0, normal, NULL);
91    cucul_flop(flop);
92
93    cucul_blit(rotate, 0, 0, normal, NULL);
94    cucul_rotate(rotate);
95
96    /* Blit the transformed canvas onto the main canvas */
97    cucul_set_attr_ansi(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE, 0);
98    cucul_putstr(cv, 0, 0, "normal");
99    cucul_blit(cv, 10, 0, normal, NULL);
100    cucul_putstr(cv, 0, 6, "flip");
101    cucul_blit(cv, 10, 6, flip, NULL);
102    cucul_putstr(cv, 0, 12, "flop");
103    cucul_blit(cv, 10, 12, flop, NULL);
104    cucul_putstr(cv, 0, 18, "rotate");
105    cucul_blit(cv, 10, 18, rotate, NULL);
106
107    caca_refresh_display(dp);
108
109    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
110
111    caca_free_display(dp);
112    cucul_free_canvas(rotate);
113    cucul_free_canvas(flop);
114    cucul_free_canvas(flip);
115    cucul_free_canvas(normal);
116    cucul_free_canvas(cv);
117
118    return 0;
119}
120
Note: See TracBrowser for help on using the repository browser.