From 7af7565b742cff25b6d34dafe86298fc27ee010b Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 23 Mar 2006 11:03:43 +0000 Subject: [PATCH] * Added a test for the transformation routines. --- test/Makefile.am | 6 ++- test/transform.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 test/transform.c diff --git a/test/Makefile.am b/test/Makefile.am index bdc844b..8a02e38 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 diff --git a/test/transform.c b/test/transform.c new file mode 100644 index 0000000..34d98f7 --- /dev/null +++ b/test/transform.c @@ -0,0 +1,117 @@ +/* + * unicode libcaca Unicode rendering test program + * Copyright (c) 2006 Sam Hocevar + * 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 +#else +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#endif + +#include + +#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; +} +