From cb9f4d661c1b07ba72f36b7d23f557cc7d44ed23 Mon Sep 17 00:00:00 2001 From: Nicolas Vion Date: Tue, 28 Oct 2008 19:30:10 +0000 Subject: [PATCH] * Change type of the last argument of drawing function (from string to long) * Adapt sample programs --- caca-php/examples/cacainfo.php | 3 + caca-php/examples/demo.php | 28 ++++----- caca-php/examples/polyline.php | 17 +++--- caca-php/php_caca.c | 103 ++++++++++----------------------- 4 files changed, 57 insertions(+), 94 deletions(-) diff --git a/caca-php/examples/cacainfo.php b/caca-php/examples/cacainfo.php index a04ed4d..54025b0 100755 --- a/caca-php/examples/cacainfo.php +++ b/caca-php/examples/cacainfo.php @@ -28,6 +28,9 @@ EOT; } caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT); caca_put_str($cv, 8, 0, "Moo!"); + caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT); + caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765 + caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764 echo caca_export_string($cv, "utf8"); } diff --git a/caca-php/examples/demo.php b/caca-php/examples/demo.php index d0ec75d..d9756a4 100644 --- a/caca-php/examples/demo.php +++ b/caca-php/examples/demo.php @@ -160,9 +160,9 @@ function demo_all($cv, $dp, $bounds, $outline) { $j = 15 + sin(0.03 * $i) * 8; caca_set_color_ansi($cv, CACA_WHITE, CACA_BLACK); - caca_fill_ellipse($cv, $xo, $yo, $j, $j / 2, '#'); + caca_fill_ellipse($cv, $xo, $yo, $j, $j / 2, ord('#')); caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK); - caca_draw_ellipse($cv, $xo, $yo, $j, $j / 2, '#'); + caca_draw_ellipse($cv, $xo, $yo, $j, $j / 2, ord('#')); /* Draw the pyramid */ $xo = caca_get_canvas_width($cv) * 5 / 8; @@ -178,17 +178,17 @@ function demo_all($cv, $dp, $bounds, $outline) { $yc = caca_get_canvas_height($cv) * 3 / 4 + cos(0.02 * $i) * 5; caca_set_color_ansi($cv, CACA_GREEN, CACA_BLACK); - caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya, '%'); + caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya, ord('%')); caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK); caca_draw_thin_triangle($cv, $xo, $yo, $xb, $yb, $xa, $ya); caca_set_color_ansi($cv, CACA_RED, CACA_BLACK); - caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#'); + caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#')); caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK); caca_draw_thin_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc); caca_set_color_ansi($cv, CACA_BLUE, CACA_BLACK); - caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc, '%'); + caca_fill_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc, ord('%')); caca_set_color_ansi($cv, CACA_YELLOW, CACA_BLACK); caca_draw_thin_triangle($cv, $xo, $yo, $xb, $yb, $xc, $yc); @@ -219,7 +219,7 @@ function demo_all($cv, $dp, $bounds, $outline) { caca_put_char($cv, caca_get_canvas_width($cv) / 2 + cos(0.02 * $j) * ($delta + caca_get_canvas_width($cv) / 4), caca_get_canvas_height($cv) / 2 + sin(0.02 * $j) * ($delta + caca_get_canvas_height($cv) / 3), - '#'); + ord('#')); } } @@ -264,7 +264,7 @@ function demo_dots($cv, $bounds, $outline, $dithering) { for ($i = 1000; $i--;) { /* Putpixel */ caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16)); - caca_put_char($cv, caca_rand(0, $xmax), caca_rand(0, $ymax), $chars[caca_rand(0, 9)]); + caca_put_char($cv, caca_rand(0, $xmax), caca_rand(0, $ymax), ord($chars[caca_rand(0, 9)])); } } @@ -285,7 +285,7 @@ function demo_lines($cv, $bounds, $outline, $dithering) { if ($outline > 1) caca_draw_thin_line($cv, $xa, $ya, $xb, $yb); else - caca_draw_line($cv, $xa, $ya, $xb, $yb, '#'); + caca_draw_line($cv, $xa, $ya, $xb, $yb, ord('#')); } function demo_boxes($cv, $bounds, $outline, $dithering) { @@ -302,13 +302,13 @@ function demo_boxes($cv, $bounds, $outline, $dithering) { } caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16)); - caca_fill_box($cv, $xa, $ya, $xb, $yb, '#'); + caca_fill_box($cv, $xa, $ya, $xb, $yb, ord('#')); caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK); if($outline == 2) caca_draw_thin_box($cv, $xa, $ya, $xb, $yb); else if($outline == 1) - caca_draw_box($cv, $xa, $ya, $xb, $yb, '#'); + caca_draw_box($cv, $xa, $ya, $xb, $yb, ord('#')); } function demo_ellipses($cv, $bounds, $outline, $dithering) { @@ -327,13 +327,13 @@ function demo_ellipses($cv, $bounds, $outline, $dithering) { } caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16)); - caca_fill_ellipse($cv, $x, $y, $a, $b, '#'); + caca_fill_ellipse($cv, $x, $y, $a, $b, ord('#')); caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK); if ($outline == 2) caca_draw_thin_ellipse($cv, $x, $y, $a, $b); else if ($outline == 1) - caca_draw_ellipse($cv, $x, $y, $a, $b, '#'); + caca_draw_ellipse($cv, $x, $y, $a, $b, ord('#')); } function demo_triangles($cv, $bounds, $outline, $dithering) { @@ -352,13 +352,13 @@ function demo_triangles($cv, $bounds, $outline, $dithering) { } caca_set_color_ansi($cv, caca_rand(0, 16), caca_rand(0, 16)); - caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#'); + caca_fill_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#')); caca_set_color_ansi($cv, caca_rand(0, 16), CACA_BLACK); if ($outline == 2) caca_draw_thin_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc); else if ($outline == 1) - caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, '#'); + caca_draw_triangle($cv, $xa, $ya, $xb, $yb, $xc, $yc, ord('#')); } function demo_render($cv, $bounds, $outline, $dithering) { diff --git a/caca-php/examples/polyline.php b/caca-php/examples/polyline.php index 14a9438..def096b 100755 --- a/caca-php/examples/polyline.php +++ b/caca-php/examples/polyline.php @@ -1,6 +1,13 @@ #!/usr/bin/php5