source: libcaca/trunk/caca-php/examples/fullwidth.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: 1.9 KB
Line 
1#!/usr/bin/php5
2<?php
3/*
4 *  fullwidth     libcaca fullwidth Unicode characters test program
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:
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
23define('CACA', "쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊");
24
25$cv = caca_create_canvas(0, 0);
26if(! $cv)
27{
28    die("Can't created canvas\n");
29}
30$dp = caca_create_display($cv);
31if(! $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 */
40for($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
48caca_blit($cv, 1, 1, $caca);
49
50/* Line of ホ's */
51for($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
59caca_blit($cv, 15, 1, $caca);
60
61/* Line of canvas */
62caca_set_color_ansi($line, CACA_WHITE, CACA_MAGENTA);
63caca_put_str($line, 0, 0, "ほ");
64for($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
71caca_blit($cv, 29, 1, $caca);
72
73caca_refresh_display($dp);
74
75caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
76
77?>
Note: See TracBrowser for help on using the repository browser.