Ignore:
Timestamp:
Oct 25, 2008, 5:41:39 PM (14 years ago)
Author:
nico
Message:
  • Add binding for 6 new caca's functions
  • Add a nice php sample file examples/example1.php that shows a smart pink ping
File:
1 edited

Legend:

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

    r3101 r3104  
    22<?
    33
    4 echo caca_put_str()."\n";
     4$pig_str = <<<EOT
     5                                   
     6    _._ _..._ .-',     _.._(`))   
     7   '-. `     '  /-._.-'    ',/     
     8      )         \            '.   
     9     / _    _    |             \   
     10    |  a    a    /   PHP        | 
     11    \   .-.                     ;
     12     '-('' ).-'       ,'       ;   
     13        '-;           |      .'   
     14           \           \    /   
     15           | 7  .__  _.-\   \   
     16           | |  |  ``/  /`  /     
     17      jgs /,_|  |   /,_/   /       
     18             /,_/      '`-'       
     19EOT;
     20
     21$canvas = caca_create_canvas(0, 0);
     22if (!$canvas) {
     23        die("Error while creating main canvas\n");
     24}
     25
     26$pig = caca_create_canvas(0, 0);
     27if (!$pig) {
     28        die("Error while creating canvas pig\n");
     29}
     30
     31$display = caca_create_display($canvas);
     32if (!$display) {
     33        die("Error while attaching canvas to display\n");
     34}
     35
     36
     37caca_set_color_ansi($pig, CACA_LIGHTRED, CACA_WHITE);
     38caca_import_memory($pig, $pig_str, "text");
     39caca_blit($canvas, caca_get_canvas_width($canvas) / 2 - 20, caca_get_canvas_height($canvas) /2 - 7, $pig);
     40caca_refresh_display($display);
     41
     42sleep(5);
     43
     44
Note: See TracChangeset for help on using the changeset viewer.