From 40a1d07570123c0ae329a186bc8bc90dd2ee3edd Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 14 Jan 2004 10:32:04 +0000 Subject: [PATCH] * test/colors.c: + Extracted the colour test from examples/demo.c. --- test/Makefile.am | 6 +++++- test/colors.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 test/colors.c diff --git a/test/Makefile.am b/test/Makefile.am index c69d5d6..db34d31 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,10 @@ # $Id$ -noinst_PROGRAMS = dithering event hsv optipal spritedit +noinst_PROGRAMS = colors dithering event hsv optipal spritedit + +colors_SOURCES = colors.c +colors_LDADD = ../src/libcaca.a @CACA_LIBS@ +colors_CPPFLAGS = -I$(top_srcdir)/src dithering_SOURCES = dithering.c dithering_LDADD = ../src/libcaca.a @CACA_LIBS@ diff --git a/test/colors.c b/test/colors.c new file mode 100644 index 0000000..62ded87 --- /dev/null +++ b/test/colors.c @@ -0,0 +1,56 @@ +/* + * colors display all possible libcaca colour pairs + * Copyright (c) 2003-2004 Sam Hocevar + * All Rights Reserved + * + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +#include "config.h" + +#include + +#include "caca.h" + +int main(int argc, char **argv) +{ + int i, j; + + if(caca_init()) + return 1; + + caca_clear(); + for(i = 0; i < 16; i++) + { + caca_set_color(CACA_COLOR_LIGHTGRAY, CACA_COLOR_BLACK); + caca_printf(4, i + (i >= 8 ? 4 : 3), "'%c': %i (%s)", + 'a' + i, i, caca_get_color_name(i)); + for(j = 0; j < 16; j++) + { + caca_set_color(i, j); + caca_putstr((j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# "); + } + } + + caca_refresh(); + caca_wait_event(CACA_EVENT_KEY_PRESS); + caca_end(); + + return 0; +} +