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