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

Last change on this file since 813 was 813, checked in by Sam Hocevar, 15 years ago
  • Renamed main canvas-related functions so that they have "canvas" in their name, eg. cucul_create() -> cucul_create_canvas() etc.
  • Moved buffer-related functions to cucul/buffer.c.
  • 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 813 2006-04-18 15:54:33Z 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    caca_event_t ev;
53    cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
54    caca_display_t *dp;
55    int i;
56
57    cv = cucul_create_canvas(0, 0);
58    dp = caca_attach(cv);
59
60    normal = cucul_create_canvas(70, 6);
61    flip = cucul_create_canvas(70, 6);
62    flop = cucul_create_canvas(70, 6);
63    rotate = cucul_create_canvas(70, 6);
64
65    cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
66    for(i = 0; pig[i]; i++)
67        cucul_putstr(normal, 55, i, pig[i]);
68
69    cucul_set_color(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK);
70    for(i = 0; duck[i]; i++)
71        cucul_putstr(normal, 30, 1 + i, duck[i]);
72
73    cucul_set_color(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK);
74    cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !!");
75
76    cucul_set_color(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
77    cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
78
79    cucul_set_color(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED);
80    cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
81    cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
82    cucul_set_color(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED);
83    cucul_putstr(normal, 4, 3, "▓▒░");
84    cucul_putstr(normal, 4, 4, "▓▒░");
85    cucul_putstr(normal, 24, 3, "░▒▓");
86    cucul_putstr(normal, 24, 4, "░▒▓");
87
88    /* Flip, flop and rotate our working canvas */
89    cucul_blit(flip, 0, 0, normal, NULL);
90    cucul_flip(flip);
91
92    cucul_blit(flop, 0, 0, normal, NULL);
93    cucul_flop(flop);
94
95    cucul_blit(rotate, 0, 0, normal, NULL);
96    cucul_rotate(rotate);
97
98    /* Blit the transformed canvas onto the main canvas */
99    cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
100    cucul_putstr(cv, 0, 0, "normal");
101    cucul_blit(cv, 10, 0, normal, NULL);
102    cucul_putstr(cv, 0, 6, "flip");
103    cucul_blit(cv, 10, 6, flip, NULL);
104    cucul_putstr(cv, 0, 12, "flop");
105    cucul_blit(cv, 10, 12, flop, NULL);
106    cucul_putstr(cv, 0, 18, "rotate");
107    cucul_blit(cv, 10, 18, rotate, NULL);
108
109    caca_display(dp);
110
111    caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
112
113    caca_detach(dp);
114    cucul_free_canvas(rotate);
115    cucul_free_canvas(flop);
116    cucul_free_canvas(flip);
117    cucul_free_canvas(normal);
118    cucul_free_canvas(cv);
119
120    return 0;
121}
122
Note: See TracBrowser for help on using the repository browser.