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 | * cacainfo.php sample program for libcaca php binding |
---|
11 | * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu> |
---|
12 | * |
---|
13 | * This program is free software. It comes without any warranty, to |
---|
14 | * the extent permitted by applicable law. You can redistribute it |
---|
15 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
16 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
17 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
18 | */ |
---|
19 | ?> |
---|
20 | <head> |
---|
21 | <title>sample program for libcaca php binding</title> |
---|
22 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
---|
23 | <link rel="StyleSheet" href="caca-php.css" type="text/css" /> |
---|
24 | </head> |
---|
25 | <body text="silver" bgcolor="black"> |
---|
26 | <?php |
---|
27 | |
---|
28 | //--- Just for fun ---// |
---|
29 | |
---|
30 | function just_for_fun() { |
---|
31 | |
---|
32 | $moo = <<<EOT |
---|
33 | (__) |
---|
34 | (oo) |
---|
35 | /------\/ |
---|
36 | / | || |
---|
37 | * /\---/\ |
---|
38 | ~~ ~~ |
---|
39 | EOT; |
---|
40 | |
---|
41 | $cv = caca_create_canvas(0, 0); |
---|
42 | caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT); |
---|
43 | caca_import_string($cv, $moo, "text"); |
---|
44 | |
---|
45 | for($j = 0; $j < caca_get_canvas_height($cv); $j++) { |
---|
46 | for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) { |
---|
47 | caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE : CACA_WHITE), CACA_DEFAULT); |
---|
48 | $a = caca_get_attr($cv, -1, -1); |
---|
49 | caca_put_attr($cv, $i, $j, $a); |
---|
50 | caca_put_attr($cv, $i + 1, $j, $a); |
---|
51 | } |
---|
52 | } |
---|
53 | caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT); |
---|
54 | caca_put_str($cv, 8, 0, "Moo!"); |
---|
55 | caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT); |
---|
56 | caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765 |
---|
57 | caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764 |
---|
58 | echo caca_export_string($cv, "html3"); |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | just_for_fun(); |
---|
63 | |
---|
64 | ?> |
---|
65 | <?php |
---|
66 | |
---|
67 | //--- Show caca's information ---// |
---|
68 | |
---|
69 | ?> |
---|
70 | <p>libcaca version: <?php echo htmlspecialchars(caca_get_version()); ?></p> |
---|
71 | |
---|
72 | <p>Available drivers:</p> |
---|
73 | <ul> |
---|
74 | <?php |
---|
75 | $list = caca_get_display_driver_list(); |
---|
76 | foreach($list as $type => $name) |
---|
77 | echo '<li>' . htmlspecialchars("$name ($type)") . '</li>'; |
---|
78 | ?> |
---|
79 | </ul> |
---|
80 | |
---|
81 | <p>Available import formats:</p> |
---|
82 | <ul> |
---|
83 | <?php |
---|
84 | $list = caca_get_import_list(); |
---|
85 | foreach($list as $format => $name) |
---|
86 | echo '<li>' . htmlspecialchars("$name ($format)") . '</li>'; |
---|
87 | ?> |
---|
88 | </ul> |
---|
89 | |
---|
90 | <p>Available export formats:</p> |
---|
91 | <ul> |
---|
92 | <?php |
---|
93 | $list = caca_get_export_list(); |
---|
94 | foreach($list as $format => $name) |
---|
95 | echo '<li>' . htmlspecialchars("$name ($format)") . '</li>'; |
---|
96 | ?> |
---|
97 | </ul> |
---|
98 | |
---|
99 | <p>Available caca fonts:</p> |
---|
100 | <ul> |
---|
101 | <?php |
---|
102 | $list = caca_get_font_list(); |
---|
103 | foreach($list as $name) |
---|
104 | echo '<li>' . htmlspecialchars("$name") . '</li>'; |
---|
105 | ?> |
---|
106 | </ul> |
---|
107 | |
---|
108 | </body> |
---|
109 | </html> |
---|