source: libcaca/trunk/caca-php/examples/fullwidth.php @ 3268

Last change on this file since 3268 was 3268, checked in by bsittler, 11 years ago

force cli on remaining examples so that apache doesn't pop up a window
(this actually happens with the cocoa driver!)

  • 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@zoy.org>
10 *                All Rights Reserved
11 *
12 *  $Id: fullwidth.php 3268 2008-11-04 03:56:18Z bsittler $
13 *
14 *  This program is free software. It comes without any warranty, to
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
18 *  http://sam.zoy.org/wtfpl/COPYING for more details.
19 */
20
21if (php_sapi_name() != "cli") {
22        die("You have to run this program with php-cli!\n");
23}
24
25define('CACA', "쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊쫊");
26
27$cv = caca_create_canvas(0, 0);
28if(! $cv)
29{
30        die("Can't created canvas\n");
31}
32$dp = caca_create_display($cv);
33if(! $dp)
34{
35        die("Can't create display\n");
36}
37
38$caca = caca_create_canvas(6, 10);
39$line = caca_create_canvas(2, 1);
40
41/* Line of x's */
42for($i = 0; $i < 10; $i++)
43{
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}
49
50caca_blit($cv, 1, 1, $caca);
51
52/* Line of ホ's */
53for($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}
60
61caca_blit($cv, 15, 1, $caca);
62
63/* Line of canvas */
64caca_set_color_ansi($line, CACA_WHITE, CACA_MAGENTA);
65caca_put_str($line, 0, 0, "ほ");
66for($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}
72
73caca_blit($cv, 29, 1, $caca);
74
75caca_refresh_display($dp);
76
77caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
78
79?>
Note: See TracBrowser for help on using the repository browser.