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

Last change on this file since 3278 was 3278, checked in by bsittler, 12 years ago

phpized

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