source: libcaca/trunk/caca-php/examples/www/text.php @ 3210

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

remove the stylesheet, as it does not seem to help at the moment. also remove the <pre></pre> in figlet.php since it does not seem to make a difference since the table markup includes <tt></tt> inside each cell.

File size: 2.1 KB
Line 
1<?php
2header('Content-Type: text/html; charset=UTF-8');
3?>
4<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
7<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8<?php
9/*
10 *  demo.php      demo for libcaca php binding
11 *  Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
12 *
13 *  This file is a Php port of the official libcaca's sample program "demo.c"
14 *  which is:
15 *  Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
16 *
17 *  This program is free software. It comes without any warranty, to
18 *  the extent permitted by applicable law. You can redistribute it
19 *  and/or modify it under the terms of the Do What The Fuck You Want
20 *  To Public License, Version 2, as published by Sam Hocevar. See
21 *  http://sam.zoy.org/wtfpl/COPYING for more details.
22 */
23?>
24<head>
25<title>demo for libcaca php binding</title>
26<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
27</head>
28<body text="silver" bgcolor="black">
29<?php
30
31$string =  <<<EOT
32              |_|
33   _,----._   | |
34  (/ @  @ \)   __
35   |  OO  |   |_ 
36   \ `--' /   |__
37    `----'       
38              |_|
39 Hello world!  | 
40EOT;
41       
42$pig = caca_create_canvas(0, 0);
43caca_import_string($pig, $string, "text");
44
45$cv = caca_create_canvas(caca_get_canvas_width($pig) * 2, caca_get_canvas_height($pig) * 2);
46
47if (!$cv or !$pig) {
48        die("Can't created canvas\n");
49}
50
51caca_blit($cv, 0, 0, $pig);
52caca_flip($pig);
53caca_blit($cv, caca_get_canvas_width($pig), 0, $pig);
54caca_flip($pig);
55caca_flop($pig);
56caca_blit($cv, 0, caca_get_canvas_height($pig), $pig);
57caca_flop($pig);
58caca_rotate_180($pig);
59caca_blit($cv, caca_get_canvas_width($pig), caca_get_canvas_height($pig), $pig);
60
61for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
62        for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
63                caca_set_color_ansi($cv, CACA_LIGHTBLUE + ($i + $j) % 6, CACA_DEFAULT);
64                $a = caca_get_attr($cv, -1, -1);
65                caca_put_attr($cv, $i, $j, $a);
66                caca_put_attr($cv, $i + 1, $j, $a);
67        }
68}
69
70echo caca_export_string($cv, "html3");
71caca_rotate_left($cv);
72echo caca_export_string($cv, "html3");
73
74?>
75</body>
76</html>
Note: See TracBrowser for help on using the repository browser.