[307] | 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 813 2006-04-18 15:54:33Z sam $ |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
[522] | 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. |
---|
[307] | 12 | */ |
---|
| 13 | |
---|
| 14 | #include "config.h" |
---|
| 15 | |
---|
| 16 | #if defined(HAVE_INTTYPES_H) |
---|
| 17 | # include <inttypes.h> |
---|
| 18 | #else |
---|
| 19 | typedef unsigned char uint8_t; |
---|
| 20 | typedef unsigned short uint16_t; |
---|
| 21 | typedef unsigned int uint32_t; |
---|
| 22 | #endif |
---|
| 23 | |
---|
[524] | 24 | #include "cucul.h" |
---|
[307] | 25 | #include "caca.h" |
---|
| 26 | |
---|
| 27 | uint32_t buffer[256*256]; |
---|
| 28 | |
---|
| 29 | int main(void) |
---|
| 30 | { |
---|
[777] | 31 | caca_event_t ev; |
---|
[811] | 32 | cucul_canvas_t *cv; |
---|
| 33 | caca_display_t *dp; |
---|
[524] | 34 | |
---|
[777] | 35 | cucul_dither_t *dither; |
---|
[307] | 36 | int x, y; |
---|
| 37 | |
---|
[813] | 38 | cv = cucul_create_canvas(0, 0); |
---|
[811] | 39 | dp = caca_attach(cv); |
---|
[307] | 40 | |
---|
| 41 | for(y = 0; y < 256; y++) |
---|
| 42 | for(x = 0; x < 256; x++) |
---|
| 43 | { |
---|
| 44 | buffer[y * 256 + x] = ((y * x / 256) << 16) | ((y * x / 256) << 8) | (x<< 0); |
---|
| 45 | } |
---|
| 46 | |
---|
[734] | 47 | dither = cucul_create_dither(32, 256, 256, 4 * 256, |
---|
[524] | 48 | 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0); |
---|
[813] | 49 | cucul_dither_bitmap(cv, 0, 0, cucul_get_canvas_width(cv) - 1, |
---|
| 50 | cucul_get_canvas_height(cv) - 1, dither, buffer); |
---|
[734] | 51 | cucul_free_dither(dither); |
---|
[307] | 52 | |
---|
[811] | 53 | caca_display(dp); |
---|
[307] | 54 | |
---|
[811] | 55 | caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1); |
---|
[307] | 56 | |
---|
[811] | 57 | caca_detach(dp); |
---|
[813] | 58 | cucul_free_canvas(cv); |
---|
[307] | 59 | |
---|
| 60 | return 0; |
---|
| 61 | } |
---|
| 62 | |
---|