| 1 |
#!/usr/bin/php5 |
| 2 |
<?php |
| 3 |
/* |
| 4 |
* fullwidth libcaca fullwidth Unicode characters test program |
| 5 |
* Copyright (c) 2008 Benjamin C. Wiley Sittler <[email protected]> |
| 6 |
* |
| 7 |
* This file is a Php port of "examples/fullwidth.c" |
| 8 |
* which is: |
| 9 |
* Copyright (c) 2006 Sam Hocevar <[email protected]> |
| 10 |
* All Rights Reserved |
| 11 |
* |
| 12 |
* This program is free software. It comes without any warranty, to |
| 13 |
* the extent permitted by applicable law. You can redistribute it |
| 14 |
* and/or modify it under the terms of the Do What the Fuck You Want |
| 15 |
* to Public License, Version 2, as published by Sam Hocevar. See |
| 16 |
* http://www.wtfpl.net/ for more details. |
| 17 |
*/ |
| 18 |
|
| 19 |
if (php_sapi_name() != "cli") { |
| 20 |
die("You have to run this program with php-cli!\n"); |
| 21 |
} |
| 22 |
|
| 23 |
define('CACA', "쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊"); |
| 24 |
|
| 25 |
$cv = caca_create_canvas(0, 0); |
| 26 |
if(! $cv) |
| 27 |
{ |
| 28 |
die("Can't created canvas\n"); |
| 29 |
} |
| 30 |
$dp = caca_create_display($cv); |
| 31 |
if(! $dp) |
| 32 |
{ |
| 33 |
die("Can't create display\n"); |
| 34 |
} |
| 35 |
|
| 36 |
$caca = caca_create_canvas(6, 10); |
| 37 |
$line = caca_create_canvas(2, 1); |
| 38 |
|
| 39 |
/* Line of x's */ |
| 40 |
for($i = 0; $i < 10; $i++) |
| 41 |
{ |
| 42 |
caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE); |
| 43 |
caca_put_str($caca, 0, $i, CACA); |
| 44 |
caca_set_color_ansi($caca, CACA_WHITE, CACA_RED); |
| 45 |
caca_put_char($caca, $i - 2, $i, ord('x')); |
| 46 |
} |
| 47 |
|
| 48 |
caca_blit($cv, 1, 1, $caca); |
| 49 |
|
| 50 |
/* Line of ホ's */ |
| 51 |
for($i = 0; $i < 10; $i++) |
| 52 |
{ |
| 53 |
caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE); |
| 54 |
caca_put_str($caca, 0, $i, CACA); |
| 55 |
caca_set_color_ansi($caca, CACA_WHITE, CACA_GREEN); |
| 56 |
caca_put_str($caca, $i - 2, $i, "ホ"); |
| 57 |
} |
| 58 |
|
| 59 |
caca_blit($cv, 15, 1, $caca); |
| 60 |
|
| 61 |
/* Line of canvas */ |
| 62 |
caca_set_color_ansi($line, CACA_WHITE, CACA_MAGENTA); |
| 63 |
caca_put_str($line, 0, 0, "ほ"); |
| 64 |
for($i = 0; $i < 10; $i++) |
| 65 |
{ |
| 66 |
caca_set_color_ansi($caca, CACA_WHITE, CACA_BLUE); |
| 67 |
caca_put_str($caca, 0, $i, CACA); |
| 68 |
caca_blit($caca, $i - 2, $i, $line); |
| 69 |
} |
| 70 |
|
| 71 |
caca_blit($cv, 29, 1, $caca); |
| 72 |
|
| 73 |
caca_refresh_display($dp); |
| 74 |
|
| 75 |
caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
| 76 |
|
| 77 |
?> |