source: libcaca/trunk/caca-php/examples/www/cacainfo.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.6 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 *  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</head>
24<body text="silver" bgcolor="black">
25<?php
26
27//--- Just for fun ---//
28
29function just_for_fun() {
30
31$moo = <<<EOT
32         (__) 
33         (oo)
34   /------\/
35  / |    ||   
36 *  /\---/\
37    ~~   ~~   
38EOT;
39
40        $cv = caca_create_canvas(0, 0);
41        caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT);
42        caca_import_string($cv, $moo, "text");
43
44        for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
45                for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
46                        caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE  : CACA_WHITE), CACA_DEFAULT);
47                        $a = caca_get_attr($cv, -1, -1);
48                        caca_put_attr($cv, $i, $j, $a);
49                        caca_put_attr($cv, $i + 1, $j, $a);
50                }
51        }
52        caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
53        caca_put_str($cv, 8, 0, "Moo!");
54        caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
55        caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765
56        caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764
57        echo caca_export_string($cv, "html3");
58}
59       
60
61just_for_fun();
62
63?>
64<?php
65
66//--- Show caca's information ---//
67
68?>
69<p>libcaca version: <?php echo htmlspecialchars(caca_get_version()); ?></p>
70
71<p>Available drivers:</p>
72<ul>
73<?php
74$list = caca_get_display_driver_list();
75foreach($list as $type => $name)
76        echo '<li>' . htmlspecialchars("$name ($type)") . '</li>';
77?>
78</ul>
79
80<p>Available import formats:</p>
81<ul>
82<?php
83$list = caca_get_import_list();
84foreach($list as $format => $name)
85        echo '<li>' . htmlspecialchars("$name ($format)") . '</li>';
86?>
87</ul>
88
89<p>Available export formats:</p>
90<ul>
91<?php
92$list = caca_get_export_list();
93foreach($list as $format => $name)
94        echo '<li>' . htmlspecialchars("$name ($format)") . '</li>';
95?>
96</ul>
97
98<p>Available caca fonts:</p>
99<ul>
100<?php
101$list = caca_get_font_list();
102foreach($list as $name)
103        echo '<li>' . htmlspecialchars("$name") . '</li>';
104?>
105</ul>
106
107</body>
108</html>
Note: See TracBrowser for help on using the repository browser.