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

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 12 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1/*
2 *  truecolor     truecolor canvas features
3 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13#include "config.h"
14
15#if !defined(__KERNEL__)
16#   include <stdio.h>
17#endif
18
19#include "caca.h"
20
21int main(int argc, char *argv[])
22{
23    caca_canvas_t *cv;
24    caca_display_t *dp;
25
26    int x, y;
27
28    cv = caca_create_canvas(32, 16);
29    if(cv == NULL)
30    {
31        printf("Failed to create canvas\n");
32        return 1;
33    }
34
35    dp = caca_create_display(cv);
36    if(dp == NULL)
37    {
38        printf("Failed to create display\n");
39        return 1;
40    }
41
42    for(y = 0; y < 16; y++)
43        for(x = 0; x < 16; x++)
44    {
45        uint16_t bgcolor = 0xff00 | (y << 4) | x;
46        uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);
47
48        caca_set_color_argb(cv, fgcolor, bgcolor);
49        caca_put_str(cv, x * 2, y, "CA");
50    }
51
52    caca_set_color_ansi(cv, CACA_WHITE, CACA_LIGHTBLUE);
53    caca_put_str(cv, 2, 1, " truecolor libcaca ");
54
55    caca_refresh_display(dp);
56
57    caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
58
59    caca_free_display(dp);
60    caca_free_canvas(cv);
61
62    return 0;
63}
64
Note: See TracBrowser for help on using the repository browser.