| 1 |
/* |
| 2 |
* truecolor truecolor canvas features |
| 3 |
* Copyright (c) 2006-2012 Sam Hocevar <[email protected]> |
| 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://www.wtfpl.net/ 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 |
|
| 21 |
int 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 |
|