| 1 |
#!/usr/bin/php5 |
| 2 |
<?php |
| 3 |
/* |
| 4 |
* colors display all possible libcaca colour pairs |
| 5 |
* Copyright (c) 2008 Benjamin C. Wiley Sittler <[email protected]> |
| 6 |
* |
| 7 |
* This file is a Php port of "examples/colors.c" |
| 8 |
* Copyright (c) 2003-2004 Sam Hocevar <[email protected]> |
| 9 |
* All Rights Reserved |
| 10 |
* |
| 11 |
* This program is free software. It comes without any warranty, to |
| 12 |
* the extent permitted by applicable law. You can redistribute it |
| 13 |
* and/or modify it under the terms of the Do What the Fuck You Want |
| 14 |
* to Public License, Version 2, as published by Sam Hocevar. See |
| 15 |
* http://www.wtfpl.net/ for more details. |
| 16 |
*/ |
| 17 |
|
| 18 |
if (php_sapi_name() != "cli") { |
| 19 |
die("You have to run this program with php-cli!\n"); |
| 20 |
} |
| 21 |
|
| 22 |
$cv = caca_create_canvas(80, 24); |
| 23 |
if(!$cv) |
| 24 |
{ |
| 25 |
die("Failed to create canvas\n"); |
| 26 |
} |
| 27 |
|
| 28 |
$dp = caca_create_display($cv); |
| 29 |
if(!$dp) |
| 30 |
{ |
| 31 |
die("Failed to create display\n"); |
| 32 |
} |
| 33 |
|
| 34 |
caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
| 35 |
caca_clear_canvas($cv); |
| 36 |
for($i = 0; $i < 16; $i++) |
| 37 |
{ |
| 38 |
caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
| 39 |
caca_put_str($cv, 3, $i + ($i >= 8 ? 3 : 2), "ANSI " . $i); |
| 40 |
for($j = 0; $j < 16; $j++) |
| 41 |
{ |
| 42 |
caca_set_color_ansi($cv, $i, $j); |
| 43 |
caca_put_str($cv, ($j >= 8 ? 13 : 12) + $j * 4, $i + ($i >= 8 ? 3 : 2), |
| 44 |
"Aaホ"); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
caca_set_color_ansi($cv, CACA_LIGHTGRAY, CACA_BLACK); |
| 49 |
caca_put_str($cv, 3, 20, "This is bold This is blink This is italics This is underline"); |
| 50 |
caca_set_attr($cv, CACA_BOLD); |
| 51 |
caca_put_str($cv, 3 + 8, 20, "bold"); |
| 52 |
caca_set_attr($cv, CACA_BLINK); |
| 53 |
caca_put_str($cv, 3 + 24, 20, "blink"); |
| 54 |
caca_set_attr($cv, CACA_ITALICS); |
| 55 |
caca_put_str($cv, 3 + 41, 20, "italics"); |
| 56 |
caca_set_attr($cv, CACA_UNDERLINE); |
| 57 |
caca_put_str($cv, 3 + 60, 20, "underline"); |
| 58 |
|
| 59 |
caca_refresh_display($dp); |
| 60 |
caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
| 61 |
|
| 62 |
?> |