source: libcaca/trunk/caca-php/examples/www/cacainfo.php @ 3181

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

font for windows, too

File size: 2.3 KB
Line 
1<html>
2<head>
3<title>sample program for libcaca php binding</title>
4<style type="text/css">
5<!--
6table, tr
7{
8    display: block;
9}
10td
11{
12    display: inline;
13    padding: 0px;
14}
15-->
16</style>
17<basefont face="Monaco, Liberation Mono, Courier New, monospace" />
18</head>
19<body text="white" bgcolor="black">
20<pre>
21<?php
22/*
23 *  cacainfo.php      sample program for libcaca php binding
24 *  Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
25 *
26 *  This program is free software. It comes without any warranty, to
27 *  the extent permitted by applicable law. You can redistribute it
28 *  and/or modify it under the terms of the Do What The Fuck You Want
29 *  To Public License, Version 2, as published by Sam Hocevar. See
30 *  http://sam.zoy.org/wtfpl/COPYING for more details.
31 */
32
33
34//--- Just for fun ---//
35
36function just_for_fun() {
37
38$moo = <<<EOT
39         (__) 
40         (oo)
41   /------\/
42  / |    ||   
43 *  /\---/\
44    ~~   ~~   
45EOT;
46
47        $cv = caca_create_canvas(0, 0);
48        caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT);
49        caca_import_string($cv, $moo, "text");
50
51        for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
52                for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
53                        caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE  : CACA_WHITE), CACA_DEFAULT);
54                        $a = caca_get_attr($cv, -1, -1);
55                        caca_put_attr($cv, $i, $j, $a);
56                        caca_put_attr($cv, $i + 1, $j, $a);
57                }
58        }
59        caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
60        caca_put_str($cv, 8, 0, "Moo!");
61        caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
62        caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765
63        caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764
64        echo caca_export_string($cv, "html3");
65}
66       
67
68just_for_fun();
69
70//--- Show caca's information ---//
71
72echo "libcaca version: ".caca_get_version()."\n\n";
73echo "Available drivers:\n";
74$list = caca_get_display_driver_list();
75foreach($list as $type => $name)
76        echo "* $name ($type)\n";
77echo "\n";
78
79echo "Available import formats:\n";
80$list = caca_get_import_list();
81foreach($list as $format => $name)
82        echo "* $name ($format)\n";
83echo "\n";
84
85echo "Available export formats:\n";
86$list = caca_get_export_list();
87foreach($list as $format => $name)
88        echo "* $name ($format)\n";
89echo "\n";
90
91echo "Available caca fonts:\n";
92$list = caca_get_font_list();
93foreach($list as $name)
94        echo "* $name\n";
95echo "\n";
96
97?>
98</pre>
99</body>
100</html>
Note: See TracBrowser for help on using the repository browser.