Ignore:
Timestamp:
Oct 26, 2008, 10:27:32 PM (12 years ago)
Author:
nico
Message:
  • Add binding for 7 new functions
  • Add just_for_fun() function in sample program drivers.php
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca-php/examples/drivers.php

    r3113 r3114  
    22<?
    33
    4 echo "libcaca version: ".caca_get_version()."\n";
     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";
    541echo "Available drivers:\n";
    642$list = caca_get_display_driver_list();
    743foreach($list as $type => $name)
    844        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 TracChangeset for help on using the changeset viewer.