| @@ -1,7 +1,13 @@ | |||
| #!/usr/bin/php5 | |||
| <?php | |||
| /* | |||
| * truecolor truecolor canvas features | |||
| * truecolor truecolor canvas features | |||
| * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com> | |||
| * | |||
| * This file is a Php port of "examples/truecolor.c" | |||
| * which is: | |||
| * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * All Rights Reserved | |||
| * | |||
| * $Id$ | |||
| * | |||
| @@ -12,55 +18,31 @@ | |||
| * http://sam.zoy.org/wtfpl/COPYING for more details. | |||
| */ | |||
| #include "config.h" | |||
| #if !defined(__KERNEL__) | |||
| # include <stdio.h> | |||
| #endif | |||
| #include "caca.h" | |||
| int main(int argc, char *argv[]) | |||
| { | |||
| caca_canvas_t *cv; | |||
| caca_display_t *dp; | |||
| int x, y; | |||
| cv = caca_create_canvas(32, 16); | |||
| if(cv == NULL) | |||
| { | |||
| printf("Failed to create canvas\n"); | |||
| return 1; | |||
| } | |||
| dp = caca_create_display(cv); | |||
| if(dp == NULL) | |||
| { | |||
| printf("Failed to create display\n"); | |||
| return 1; | |||
| } | |||
| for(y = 0; y < 16; y++) | |||
| for(x = 0; x < 16; x++) | |||
| { | |||
| uint16_t bgcolor = 0xff00 | (y << 4) | x; | |||
| uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8); | |||
| caca_set_color_argb(cv, fgcolor, bgcolor); | |||
| caca_put_str(cv, x * 2, y, "CA"); | |||
| } | |||
| $cv = caca_create_canvas(32, 16); | |||
| if(!$cv) { | |||
| die("Failed to create canvas\n"); | |||
| } | |||
| caca_set_color_ansi(cv, CACA_WHITE, CACA_LIGHTBLUE); | |||
| caca_put_str(cv, 2, 1, " truecolor libcaca "); | |||
| $dp = caca_create_display($cv); | |||
| if(!$dp) { | |||
| die("Failed to create display\n"); | |||
| } | |||
| caca_refresh_display(dp); | |||
| for($y = 0; $y < 16; $y++) | |||
| for($x = 0; $x < 16; $x++) | |||
| { | |||
| $bgcolor = 0xff00 | ($y << 4) | $x; | |||
| $fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8); | |||
| caca_set_color_argb($cv, $fgcolor, $bgcolor); | |||
| caca_put_str($cv, $x * 2, $y, "CA"); | |||
| } | |||
| caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); | |||
| caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE); | |||
| caca_put_str($cv, 2, 1, " truecolor libcaca "); | |||
| caca_free_display(dp); | |||
| caca_free_canvas(cv); | |||
| caca_refresh_display($dp); | |||
| return 0; | |||
| } | |||
| caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); | |||
| ?> | |||