Debian Codegraph @

caca-php/examples/www/text.php

raw
1 <?php
2 header('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 <[email protected]>
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 <[email protected]>
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://www.wtfpl.net/ 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! |
40 EOT;
41
42 $pig = caca_create_canvas(0, 0);
43 caca_import_string($pig, $string, "text");
44
45 $cv = caca_create_canvas(caca_get_canvas_width($pig) * 2, caca_get_canvas_height($pig) * 2);
46
47 if (!$cv or !$pig) {
48 die("Can't created canvas\n");
49 }
50
51 caca_blit($cv, 0, 0, $pig);
52 caca_flip($pig);
53 caca_blit($cv, caca_get_canvas_width($pig), 0, $pig);
54 caca_flip($pig);
55 caca_flop($pig);
56 caca_blit($cv, 0, caca_get_canvas_height($pig), $pig);
57 caca_flop($pig);
58 caca_rotate_180($pig);
59 caca_blit($cv, caca_get_canvas_width($pig), caca_get_canvas_height($pig), $pig);
60
61 for($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
70 echo caca_export_string($cv, "html3");
71 caca_rotate_left($cv);
72 echo caca_export_string($cv, "html3");
73
74 ?>
75 </body>
76 </html>