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