source: libcaca/trunk/test/hsv.c @ 524

Last change on this file since 524 was 524, checked in by Sam Hocevar, 16 years ago

A new low-level text management library (canvas for ultrafast compositing

of unicode letters) is now separated from the higher level rendering and I/O
(that is, libcaca). This commit totally breaks the API, but once everything
is polished I will think about source-level backward compatibility. Most
drivers are broken, but X11 still sorta works.

The new design is much more object-oriented and allows having several

active renderers at the same time, changing renderers on the fly, and more
important, having no renderer at all (useful for converters, or when you
want to do your own renderer).

And in case you are still wondering, the libcucul acronym has "Unicode"

because I want to support at least a subset of Unicode. There are awesome
glyphs in it, including the ones inherited from Codepage 437 such as
"gray 25%" that are used in DOS and Win32 ANSI art.

  • Property svn:keywords set to Id
File size: 1.4 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 524 2006-03-05 18:43:13Z 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(HAVE_INTTYPES_H)
17#   include <inttypes.h>
18#else
19typedef unsigned char uint8_t;
20typedef unsigned short uint16_t;
21typedef unsigned int uint32_t;
22#endif
23
24#include "cucul.h"
25#include "caca.h"
26
27uint32_t buffer[256*256];
28
29int main(void)
30{
31    cucul_t *qq;
32    caca_t *kk;
33
34    struct cucul_bitmap *bitmap;
35    int x, y;
36
37    qq = cucul_init();
38    kk = caca_attach(qq);
39
40    for(y = 0; y < 256; y++)
41        for(x = 0; x < 256; x++)
42    {
43        buffer[y * 256 + x] = ((y * x / 256) << 16) | ((y * x / 256) << 8) | (x<< 0);
44    }
45
46    bitmap = cucul_create_bitmap(qq, 32, 256, 256, 4 * 256,
47                                 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
48    cucul_draw_bitmap(qq, 0, 0,
49                      cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
50                      bitmap, buffer);
51    cucul_free_bitmap(qq, bitmap);
52
53    caca_refresh(kk);
54
55    while(!caca_get_event(kk, CACA_EVENT_KEY_PRESS));
56
57    caca_detach(kk);
58    cucul_end(qq);
59
60    return 0;
61}
62
Note: See TracBrowser for help on using the repository browser.