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

Last change on this file since 814 was 814, checked in by Sam Hocevar, 15 years ago
  • Renamed cucul_clear() to cucul_clear_canvas() and added an argument to choose the background colour.
  • Property svn:keywords set to Id
File size: 1.4 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 814 2006-04-18 16:04:01Z 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_canvas_t *cv;
26    caca_display_t *dp;
27    caca_event_t ev;
28    int i, j;
29
30    cv = cucul_create_canvas(0, 0);
31    if(!cv)
32        return 1;
33
34    dp = caca_attach(cv);
35    if(!dp)
36        return 1;
37
38    cucul_clear_canvas(cv, CUCUL_COLOR_BLACK);
39    for(i = 0; i < 16; i++)
40    {
41        cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK);
42        cucul_printf(cv, 4, i + (i >= 8 ? 4 : 3), "'%cv': %i (%s)",
43                     'a' + i, i, cucul_get_color_name(i));
44        for(j = 0; j < 16; j++)
45        {
46            cucul_set_color(cv, i, j);
47            cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3),
48                         "# ");
49        }
50    }
51
52    caca_display(dp);
53    caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
54
55    caca_detach(dp);
56    cucul_free_canvas(cv);
57
58    return 0;
59}
60
Note: See TracBrowser for help on using the repository browser.