source: libcaca/trunk/examples/truecolor.c @ 2101

Last change on this file since 2101 was 2101, checked in by Sam Hocevar, 12 years ago
  • Rename "test" to "examples". The former will become a real testsuite.
  • Autodetect zzuf in the configure step. It might become handy.
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1/*
2 *  truecolor     truecolor canvas features
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: truecolor.c 2101 2007-11-30 23:48:39Z sam $
7 *
8 *  This program is free software. It comes without any warranty, to
9 *  the extent permitted by applicable law. You can redistribute it
10 *  and/or modify it under the terms of the Do What The Fuck You Want
11 *  To Public License, Version 2, as published by Sam Hocevar. See
12 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13 */
14
15#include "config.h"
16#include "common.h"
17
18#if !defined(__KERNEL__)
19#   if defined(HAVE_INTTYPES_H)
20#      include <inttypes.h>
21#   endif
22#   include <stdio.h>
23#endif
24
25#include "cucul.h"
26#include "caca.h"
27
28int main(int argc, char *argv[])
29{
30    cucul_canvas_t *cv;
31    caca_display_t *dp;
32
33    int x, y;
34
35    cv = cucul_create_canvas(32, 16);
36    if(cv == NULL)
37    {
38        printf("Failed to create canvas\n");
39        return 1;
40    }
41
42    dp = caca_create_display(cv);
43    if(dp == NULL)
44    {
45        printf("Failed to create display\n");
46        return 1;
47    }
48
49    for(y = 0; y < 16; y++)
50        for(x = 0; x < 16; x++)
51    {
52        uint16_t bgcolor = 0xff00 | (y << 4) | x;
53        uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);
54
55        cucul_set_color_argb(cv, fgcolor, bgcolor);
56        cucul_put_str(cv, x * 2, y, "CA");
57    }
58
59    cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE);
60    cucul_put_str(cv, 2, 1, " truecolor libcaca ");
61
62    caca_refresh_display(dp);
63
64    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
65
66    caca_free_display(dp);
67    cucul_free_canvas(cv);
68
69    return 0;
70}
71
Note: See TracBrowser for help on using the repository browser.