[3278] | 1 | #!/usr/bin/php5 |
---|
| 2 | <?php |
---|
[562] | 3 | /* |
---|
| 4 | * unicode libcaca Unicode rendering test program |
---|
[3278] | 5 | * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com> |
---|
| 6 | * |
---|
| 7 | * This file is a Php port of "examples/unicode.c" |
---|
| 8 | * which is: |
---|
[562] | 9 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
| 10 | * All Rights Reserved |
---|
| 11 | * |
---|
| 12 | * $Id: unicode.php 3279 2008-11-04 05:22:24Z 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 |
---|
[562] | 18 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 19 | */ |
---|
| 20 | |
---|
[3279] | 21 | if (php_sapi_name() != "cli") { |
---|
| 22 | die("You have to run this program with php-cli!\n"); |
---|
| 23 | } |
---|
| 24 | |
---|
[3278] | 25 | $cv = caca_create_canvas(0, 0); |
---|
| 26 | if(! $cv) |
---|
[562] | 27 | { |
---|
[3278] | 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 | caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); |
---|
| 36 | caca_put_str($cv, 1, 1, "Basic Unicode support"); |
---|
[562] | 37 | |
---|
[3278] | 38 | caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); |
---|
| 39 | caca_put_str($cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |"); |
---|
| 40 | caca_put_str($cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |"); |
---|
| 41 | caca_put_str($cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |"); |
---|
[562] | 42 | |
---|
[3278] | 43 | caca_put_str($cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere."); |
---|
[577] | 44 | |
---|
[3278] | 45 | caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); |
---|
| 46 | caca_put_str($cv, 1, 7, "Gradient glyphs"); |
---|
[562] | 47 | |
---|
[3278] | 48 | caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); |
---|
| 49 | caca_put_str($cv, 31, 8, " 0%"); |
---|
| 50 | caca_put_str($cv, 31, 9, " 25%"); |
---|
| 51 | caca_put_str($cv, 31, 10, " 50%"); |
---|
| 52 | caca_put_str($cv, 31, 11, " 75%"); |
---|
| 53 | caca_put_str($cv, 31, 12, "100%"); |
---|
[577] | 54 | |
---|
[3278] | 55 | caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_LIGHTGREEN); |
---|
| 56 | caca_put_str($cv, 1, 8, " "); |
---|
| 57 | caca_put_str($cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); |
---|
| 58 | caca_put_str($cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); |
---|
| 59 | caca_put_str($cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); |
---|
| 60 | caca_put_str($cv, 1, 12, "█████████████████████████████"); |
---|
[577] | 61 | |
---|
[3278] | 62 | caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_LIGHTRED); |
---|
| 63 | caca_put_str($cv, 36, 8, "█████████████████████████████"); |
---|
| 64 | caca_put_str($cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); |
---|
| 65 | caca_put_str($cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); |
---|
| 66 | caca_put_str($cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); |
---|
| 67 | caca_put_str($cv, 36, 12, " "); |
---|
[577] | 68 | |
---|
[3278] | 69 | caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); |
---|
| 70 | caca_put_str($cv, 1, 14, "Double width characters"); |
---|
[577] | 71 | |
---|
[3278] | 72 | caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_TRANSPARENT); |
---|
| 73 | caca_put_str($cv, 1, 15, "| ドラゴン ボーレ |"); |
---|
| 74 | caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); |
---|
| 75 | caca_put_str($cv, 1, 16, "| ()()()() ()()() |"); |
---|
| 76 | caca_set_color_ansi($cv, CACA_YELLOW, CACA_TRANSPARENT); |
---|
| 77 | caca_put_str($cv, 1, 17, "| ドラゴン"); |
---|
| 78 | caca_put_str($cv, 12, 17, "ボーレ |"); |
---|
[577] | 79 | |
---|
[3278] | 80 | caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); |
---|
| 81 | caca_put_str($cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere."); |
---|
[577] | 82 | |
---|
[3278] | 83 | caca_put_str($cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼"); |
---|
| 84 | caca_put_str($cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■"); |
---|
| 85 | caca_put_str($cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟ ─ │ ┌ ┐ └ ┘ ├ ┤"); |
---|
| 86 | caca_put_str($cv, 1, 23, "more drawing: ┬ ┴ ┼ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬"); |
---|
| 87 | caca_put_str($cv, 1, 24, "misc Unicode: ● ☭ ☮ ☯ ♔ ♛ ♙ ♞ ⚒ ⚓ ⚠"); |
---|
[577] | 88 | |
---|
[3278] | 89 | caca_refresh_display($dp); |
---|
[646] | 90 | |
---|
[3278] | 91 | caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); |
---|
[562] | 92 | |
---|
[3278] | 93 | ?> |
---|