Browse Source

* Added a test for the transformation routines.

tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
7af7565b74
2 changed files with 122 additions and 1 deletions
  1. +5
    -1
      test/Makefile.am
  2. +117
    -0
      test/transform.c

+ 5
- 1
test/Makefile.am View File

@@ -1,6 +1,6 @@
# $Id$

noinst_PROGRAMS = colors demo dithering event export gamma hsv optipal spritedit unicode
noinst_PROGRAMS = colors demo dithering event export gamma hsv optipal spritedit transform unicode

colors_SOURCES = colors.c
colors_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
@@ -38,6 +38,10 @@ spritedit_SOURCES = spritedit.c
spritedit_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
spritedit_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca

transform_SOURCES = transform.c
transform_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
transform_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca

unicode_SOURCES = unicode.c
unicode_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@
unicode_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca


+ 117
- 0
test/transform.c View File

@@ -0,0 +1,117 @@
/*
* unicode libcaca Unicode rendering test program
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
* All Rights Reserved
*
* $Id$
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Do What The Fuck You Want To
* Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include "config.h"

#if defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#else
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
#endif

#include <stdio.h>

#include "cucul.h"
#include "caca.h"

static char const *pig[] =
{
",--. ,--.",
"\\ /-~-\\ /",
" )' o O `(",
"( ,---. )",
" `(_o_o_)'",
" )`-'(",
NULL
};

static char const *duck[] =
{
" ,~~.",
" __ , ( O )>",
"___( o)> )`~~' (",
"\\ <_. ) ( .__) )",
" `---' `-.____,'",
NULL
};

int main(void)
{
cucul_t *qq, *normal, *flip, *flop, *rotate;
caca_t *kk;
int i;

qq = cucul_init(0, 0);
kk = caca_attach(qq);

normal = cucul_init(70, 6);
flip = cucul_init(70, 6);
flop = cucul_init(70, 6);
rotate = cucul_init(70, 6);

cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
for(i = 0; pig[i]; i++)
cucul_putstr(normal, 55, i, pig[i]);

cucul_set_color(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK);
for(i = 0; duck[i]; i++)
cucul_putstr(normal, 30, 1 + i, duck[i]);

cucul_set_color(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK);
cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !!");

cucul_set_color(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");

cucul_set_color(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED);
cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
cucul_set_color(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED);
cucul_putstr(normal, 4, 3, "▓▒░");
cucul_putstr(normal, 4, 4, "▓▒░");
cucul_putstr(normal, 24, 3, "░▒▓");
cucul_putstr(normal, 24, 4, "░▒▓");

/* Flip, flop and rotate our working canvas */
cucul_blit(flip, 0, 0, normal, NULL);
cucul_flip(flip);

cucul_blit(flop, 0, 0, normal, NULL);
cucul_flop(flop);

cucul_blit(rotate, 0, 0, normal, NULL);
cucul_rotate(rotate);

/* Blit the transformed canvas onto the main canvas */
cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
cucul_putstr(qq, 0, 0, "normal");
cucul_blit(qq, 10, 0, normal, NULL);
cucul_putstr(qq, 0, 6, "flip");
cucul_blit(qq, 10, 6, flip, NULL);
cucul_putstr(qq, 0, 12, "flop");
cucul_blit(qq, 10, 12, flop, NULL);
cucul_putstr(qq, 0, 18, "rotate");
cucul_blit(qq, 10, 18, rotate, NULL);

caca_display(kk);

while(!caca_get_event(kk, CACA_EVENT_KEY_PRESS));

caca_detach(kk);
cucul_end(qq);

return 0;
}


Loading…
Cancel
Save