source: libcaca/trunk/test/colors.c @ 665

Last change on this file since 665 was 665, checked in by Sam Hocevar, 15 years ago
  • Changed the cucul_init parameter so that it now directly accepts a canvas size (use cucul_init(0, 0) for the old behaviour).
  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1/*
2 *  colors        display all possible libcaca colour pairs
3 *  Copyright (c) 2003-2004 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: colors.c 665 2006-03-22 17:46:11Z 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(__KERNEL__)
17#   include <stdio.h>
18#endif
19
20#include "cucul.h"
21#include "caca.h"
22
23int main(int argc, char **argv)
24{
25    cucul_t *qq;
26    caca_t *kk;
27    int i, j;
28
29    qq = cucul_init(0, 0);
30    if(!qq)
31        return 1;
32
33    kk = caca_attach(qq);
34    if(!kk)
35        return 1;
36
37    cucul_clear(qq);
38    for(i = 0; i < 16; i++)
39    {
40        cucul_set_color(qq, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
41        cucul_printf(qq, 4, i + (i >= 8 ? 4 : 3), "'%c': %i (%s)",
42                     'a' + i, i, cucul_get_color_name(i));
43        for(j = 0; j < 16; j++)
44        {
45            cucul_set_color(qq, i, j);
46            cucul_putstr(qq, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3),
47                         "# ");
48        }
49    }
50
51    caca_display(kk);
52    caca_wait_event(kk, CACA_EVENT_KEY_PRESS);
53
54    caca_detach(kk);
55    cucul_end(qq);
56
57    return 0;
58}
59
Note: See TracBrowser for help on using the repository browser.