Sfoglia il codice sorgente

* Change test for php-cli mode in sample programs

tags/v0.99.beta17
Nicolas Vion nico 16 anni fa
parent
commit
cc238fd633
6 ha cambiato i file con 18 aggiunte e 9 eliminazioni
  1. +2
    -1
      caca-php/examples/cacainfo.php
  2. +2
    -1
      caca-php/examples/demo.php
  3. +8
    -4
      caca-php/examples/dithering.php
  4. +2
    -1
      caca-php/examples/figfont.php
  5. +2
    -1
      caca-php/examples/polyline.php
  6. +2
    -1
      caca-php/examples/text.php

+ 2
- 1
caca-php/examples/cacainfo.php Vedi File

@@ -46,8 +46,9 @@ EOT;
} }


if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


just_for_fun(); just_for_fun();




+ 2
- 1
caca-php/examples/demo.php Vedi File

@@ -361,8 +361,9 @@ function demo_render($cv, $bounds, $outline) {
} }




if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


main(); main();




+ 8
- 4
caca-php/examples/dithering.php Vedi File

@@ -11,21 +11,25 @@
* http://sam.zoy.org/wtfpl/COPYING for more details. * http://sam.zoy.org/wtfpl/COPYING for more details.
*/ */


if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


$img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png"); $img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png");
if (!$img) if (!$img) {
die("Can not open image.\n"); die("Can not open image.\n");
}


$dither = caca_create_dither($img); $dither = caca_create_dither($img);
if (!$dither) if (!$dither) {
die("Can not create dither. Maybe you compiled caca-php without gd support.\n"); die("Can not create dither. Maybe you compiled caca-php without gd support.\n");
}


$canvas = caca_create_canvas(0, 0); $canvas = caca_create_canvas(0, 0);
$display = caca_create_display($canvas); $display = caca_create_display($canvas);
if (!$display) if (!$display) {
die("Can not create display.\n"); die("Can not create display.\n");
}


caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img);
caca_refresh_display($display); caca_refresh_display($display);


+ 2
- 1
caca-php/examples/figfont.php Vedi File

@@ -23,8 +23,9 @@ function unistr_to_ords($str, $encoding = 'UTF-8'){
return $result; return $result;
} }


if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


if ($argc < 3) { if ($argc < 3) {
die("Too few arguments.\nUsage: cmd <path of font> <utf8 string>\n"); die("Too few arguments.\nUsage: cmd <path of font> <utf8 string>\n");


+ 2
- 1
caca-php/examples/polyline.php Vedi File

@@ -18,8 +18,9 @@ function transform($tbl, $tx, $ty, $sx, $sy) {
return $result; return $result;
} }


if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


$canvas = caca_create_canvas(0, 0); $canvas = caca_create_canvas(0, 0);
$display = caca_create_display($canvas); $display = caca_create_display($canvas);


+ 2
- 1
caca-php/examples/text.php Vedi File

@@ -15,8 +15,9 @@
* http://sam.zoy.org/wtfpl/COPYING for more details. * http://sam.zoy.org/wtfpl/COPYING for more details.
*/ */


if (!posix_isatty(STDOUT)) if (php_sapi_name() != "cli") {
die("You have to run this program with php-cli!\n"); die("You have to run this program with php-cli!\n");
}


$string = <<<EOT $string = <<<EOT
|_| |_|


||||||
x
 
000:0
Caricamento…
Annulla
Salva