source: libcaca/branches/0.9/test/hsv.c @ 3273

Last change on this file since 3273 was 316, checked in by Sam Hocevar, 16 years ago
  • src/io.c: + caca_get_event() and caca_wait_event() now accept a mask as an argument

in order to select events.

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/*
2 *  hsv           libcaca HSV rendering test program
3 *  Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: hsv.c 316 2004-01-05 18:17:20Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the GNU Lesser General Public
10 *  License as published by the Free Software Foundation; either
11 *  version 2 of the License, or (at your option) any later version.
12 *
13 *  This program is distributed in the hope that it will be useful,
14 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 *  Lesser General Public License for more details.
17 *
18 *  You should have received a copy of the GNU Lesser General Public
19 *  License along with this program; if not, write to the Free Software
20 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 *  02111-1307  USA
22 */
23
24#include "config.h"
25
26#if defined(HAVE_INTTYPES_H)
27#   include <inttypes.h>
28#else
29typedef unsigned char uint8_t;
30typedef unsigned short uint16_t;
31typedef unsigned int uint32_t;
32#endif
33
34#include "caca.h"
35
36uint32_t buffer[256*256];
37
38int main(void)
39{
40    struct caca_bitmap *bitmap;
41    int x, y;
42
43    caca_init();
44
45    for(y = 0; y < 256; y++)
46        for(x = 0; x < 256; x++)
47    {
48        buffer[y * 256 + x] = ((y * x / 256) << 16) | ((y * x / 256) << 8) | (x<< 0);
49    }
50
51    bitmap = caca_create_bitmap(32, 256, 256, 4 * 256,
52                                0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
53    caca_draw_bitmap(0, 0, caca_get_width() - 1, caca_get_height() - 1,
54                     bitmap, buffer);
55    caca_free_bitmap(bitmap);
56
57    caca_refresh();
58
59    while(!caca_get_event(CACA_EVENT_KEY_PRESS));
60
61    caca_end();
62
63    return 0;
64}
65
Note: See TracBrowser for help on using the repository browser.