Ignore:
Timestamp:
Oct 28, 2008, 8:30:10 PM (12 years ago)
Author:
nico
Message:
  • Change type of the last argument of drawing function (from string to long)
  • Adapt sample programs
Location:
libcaca/trunk/caca-php/examples
Files:
3 edited

Legend:

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

    r3129 r3132  
    2929        caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
    3030        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
    3134        echo caca_export_string($cv, "utf8");
    3235}
  • libcaca/trunk/caca-php/examples/demo.php

    r3127 r3132  
    161161        $j = 15 + sin(0.03 * $i) * 8;
    162162        caca_set_color_ansi($cv, CACA_WHITE, CACA_BLACK);
    163         caca_fill_ellipse($cv, $xo, $yo, $j, $j / 2, '#');
    164         caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK);
    165         caca_draw_ellipse($cv, $xo, $yo, $j, $j / 2, '#');
     163        caca_fill_ellipse($cv, $xo, $yo, $j, $j / 2, ord('#'));
     164        caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK);
     165        caca_draw_ellipse($cv, $xo, $yo, $j, $j / 2, ord('#'));
    166166
    167167        /* Draw the pyramid */
     
    179179
    180180        caca_set_color_ansi($cv, CACA_GREEN, CACA_BLACK);
    181         caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya, '%');
     181        caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya, ord('%'));
    182182        caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK);
    183183        caca_draw_thin_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya);
    184184
    185185        caca_set_color_ansi($cv, CACA_RED, CACA_BLACK);
    186         caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#');
     186        caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#'));
    187187        caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK);
    188188        caca_draw_thin_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc);
    189189
    190190        caca_set_color_ansi($cv, CACA_BLUE, CACA_BLACK);
    191         caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc, '%');
     191        caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc, ord('%'));
    192192        caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK);
    193193        caca_draw_thin_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc);
     
    220220                        caca_get_canvas_width($cv) / 2 + cos(0.02 * $j) * ($delta + caca_get_canvas_width($cv) / 4),
    221221                        caca_get_canvas_height($cv) / 2 + sin(0.02 * $j) * ($delta + caca_get_canvas_height($cv) / 3),
    222                         '#');
     222                        ord('#'));
    223223        }
    224224}
     
    265265                /* Putpixel */
    266266                caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    267                 caca_put_char($cv, caca_rand(0, $xmax), caca_rand(0, $ymax), $chars[caca_rand(0, 9)]);
     267                caca_put_char($cv, caca_rand(0, $xmax), caca_rand(0, $ymax), ord($chars[caca_rand(0, 9)]));
    268268        }
    269269}
     
    286286                caca_draw_thin_line($cv, $xa, $ya, $xb, $yb);
    287287        else
    288                 caca_draw_line($cv, $xa, $ya, $xb, $yb, '#');
     288                caca_draw_line($cv, $xa, $ya, $xb, $yb, ord('#'));
    289289}
    290290
     
    303303
    304304        caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    305         caca_fill_box($cv, $xa, $ya, $xb, $yb, '#');
     305        caca_fill_box($cv, $xa, $ya, $xb, $yb, ord('#'));
    306306
    307307        caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK);
     
    309309                caca_draw_thin_box($cv, $xa, $ya, $xb, $yb);
    310310        else if($outline == 1)
    311                 caca_draw_box($cv, $xa, $ya, $xb, $yb, '#');
     311                caca_draw_box($cv, $xa, $ya, $xb, $yb, ord('#'));
    312312}
    313313
     
    328328
    329329        caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    330         caca_fill_ellipse($cv, $x, $y, $a, $b, '#');
     330        caca_fill_ellipse($cv, $x, $y, $a, $b, ord('#'));
    331331
    332332        caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK);
     
    334334                caca_draw_thin_ellipse($cv, $x, $y, $a, $b);
    335335        else if ($outline == 1)
    336                 caca_draw_ellipse($cv, $x, $y, $a, $b, '#');
     336                caca_draw_ellipse($cv, $x, $y, $a, $b, ord('#'));
    337337}
    338338
     
    353353
    354354        caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16));
    355         caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#');
     355        caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#'));
    356356
    357357        caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK);
     
    359359                caca_draw_thin_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc);
    360360        else if ($outline == 1)
    361                 caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#');
     361                caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#'));
    362362}
    363363
  • libcaca/trunk/caca-php/examples/polyline.php

    r3131 r3132  
    11#!/usr/bin/php5
    22<?php
     3
     4function transform($tbl, $tx, $ty, $sx, $sy) {
     5        $result = array();
     6        foreach($tbl as $pt)
     7                $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty);
     8        return $result;
     9}
    310
    411$canvas = caca_create_canvas(0, 0);
     
    2229);
    2330
    24 function transform($tbl, $tx, $ty, $sx, $sy) {
    25         $result = array();
    26         foreach($tbl as $pt)
    27                 $result[] = array($pt[0] * $sx + $tx, $pt[1] * $sy + $ty);
    28         return $result;
    29 }
    30 
    3131for ($i = 0; $i < 10; $i++) {
    3232        caca_set_color_ansi($canvas, 1 + (($color += 4) % 15), CACA_TRANSPARENT);
    3333        $scale = caca_rand(4, 10) / 10;
    34         $translate = array(caca_rand(-10, 60), caca_rand(-5, 20));
     34        $translate = array(caca_rand(-5, 55), caca_rand(-2, 25));
    3535        $pts = transform($tbl, $translate[0], $translate[1], $scale, $scale);
    3636        caca_draw_thin_polyline($canvas, $pts);
     
    4040caca_refresh_display($display);
    4141sleep(5);
     42
Note: See TracChangeset for help on using the changeset viewer.