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

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