source: libcaca/trunk/caca-php/examples/drivers.php @ 3122

Last change on this file since 3122 was 3114, checked in by nico, 14 years ago
  • Add binding for 7 new functions
  • Add just_for_fun() function in sample program drivers.php
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/php5
2<?
3
4
5//--- Just for fun ---//
6
7function just_for_fun() {
8
9$moo = <<<EOT
10         (__) 
11         (oo)
12   /------\/
13  / |    ||   
14 *  /\---/\
15    ~~   ~~   
16EOT;
17
18        $cv = caca_create_canvas(0, 0);
19        caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT);
20        caca_import_string($cv, $moo, "text");
21
22        for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
23                for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
24                        caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE  : CACA_WHITE), CACA_DEFAULT);
25                        $a = caca_get_attr($cv, -1, -1);
26                        caca_put_attr($cv, $i, $j, $a);
27                        caca_put_attr($cv, $i + 1, $j, $a);
28                }
29        }
30        caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
31        caca_put_str($cv, 8, 0, "Moo!");
32        echo caca_export_string($cv, "utf8");
33}
34       
35
36just_for_fun();
37
38//--- Show caca's information ---//
39
40echo "libcaca version: ".caca_get_version()."\n\n";
41echo "Available drivers:\n";
42$list = caca_get_display_driver_list();
43foreach($list as $type => $name)
44        echo "* $name ($type)\n";
45echo "\n";
46
47echo "Available export modules:\n";
48$list = caca_get_export_list();
49foreach($list as $type => $name)
50        echo "* $name ($type)\n";
51echo "\n";
52
53echo "Available caca fonts:\n";
54$list = caca_get_font_list();
55foreach($list as $name)
56        echo "* $name\n";
57echo "\n";
Note: See TracBrowser for help on using the repository browser.