| [779] | 1 | /* |
|---|
| 2 | * truecolor truecolor canvas features |
|---|
| 3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * $Id$ |
|---|
| 7 | * |
|---|
| [1462] | 8 | * This program is free software. It comes without any warranty, to |
|---|
| [1452] | 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 |
|---|
| [779] | 12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
|---|
| 13 | */ |
|---|
| 14 | |
|---|
| 15 | #include "config.h" |
|---|
| 16 | |
|---|
| [1048] | 17 | #if !defined(__KERNEL__) |
|---|
| 18 | # include <stdio.h> |
|---|
| [779] | 19 | #endif |
|---|
| 20 | |
|---|
| 21 | #include "cucul.h" |
|---|
| 22 | #include "caca.h" |
|---|
| 23 | |
|---|
| [1048] | 24 | int main(int argc, char *argv[]) |
|---|
| [779] | 25 | { |
|---|
| [811] | 26 | cucul_canvas_t *cv; |
|---|
| 27 | caca_display_t *dp; |
|---|
| [779] | 28 | |
|---|
| 29 | int x, y; |
|---|
| 30 | |
|---|
| [813] | 31 | cv = cucul_create_canvas(32, 16); |
|---|
| [1752] | 32 | if(cv == NULL) |
|---|
| 33 | { |
|---|
| 34 | printf("Failed to create canvas\n"); |
|---|
| 35 | return 1; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| [819] | 38 | dp = caca_create_display(cv); |
|---|
| [1752] | 39 | if(dp == NULL) |
|---|
| 40 | { |
|---|
| 41 | printf("Failed to create display\n"); |
|---|
| 42 | return 1; |
|---|
| 43 | } |
|---|
| [779] | 44 | |
|---|
| 45 | for(y = 0; y < 16; y++) |
|---|
| 46 | for(x = 0; x < 16; x++) |
|---|
| 47 | { |
|---|
| 48 | uint16_t bgcolor = 0xff00 | (y << 4) | x; |
|---|
| 49 | uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8); |
|---|
| 50 | |
|---|
| [1267] | 51 | cucul_set_color_argb(cv, fgcolor, bgcolor); |
|---|
| [1347] | 52 | cucul_put_str(cv, x * 2, y, "CA"); |
|---|
| [779] | 53 | } |
|---|
| 54 | |
|---|
| [1267] | 55 | cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_LIGHTBLUE); |
|---|
| [1347] | 56 | cucul_put_str(cv, 2, 1, " truecolor libcaca "); |
|---|
| [792] | 57 | |
|---|
| [819] | 58 | caca_refresh_display(dp); |
|---|
| [779] | 59 | |
|---|
| [849] | 60 | caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); |
|---|
| [779] | 61 | |
|---|
| [819] | 62 | caca_free_display(dp); |
|---|
| [813] | 63 | cucul_free_canvas(cv); |
|---|
| [779] | 64 | |
|---|
| 65 | return 0; |
|---|
| 66 | } |
|---|
| 67 | |
|---|