source: libcaca/trunk/caca-php/examples/unicode.php @ 4333

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

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