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

Last change on this file since 3135 was 3135, checked in by nico, 12 years ago
  • Close php blocks in samples programs (add "?>")
  • Property svn:executable set to *
File size: 1.5 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        caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
32        caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765
33        caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764
34        echo caca_export_string($cv, "utf8");
35}
36       
37
38just_for_fun();
39
40//--- Show caca's information ---//
41
42echo "libcaca version: ".caca_get_version()."\n\n";
43echo "Available drivers:\n";
44$list = caca_get_display_driver_list();
45foreach($list as $type => $name)
46        echo "* $name ($type)\n";
47echo "\n";
48
49echo "Available import formats:\n";
50$list = caca_get_import_list();
51foreach($list as $format => $name)
52        echo "* $name ($format)\n";
53echo "\n";
54
55echo "Available export formats:\n";
56$list = caca_get_export_list();
57foreach($list as $format => $name)
58        echo "* $name ($format)\n";
59echo "\n";
60
61echo "Available caca fonts:\n";
62$list = caca_get_font_list();
63foreach($list as $name)
64        echo "* $name\n";
65echo "\n";
66
67?>
Note: See TracBrowser for help on using the repository browser.