Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cacainfo.php 2.2 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/php5
  2. <?php
  3. /*
  4. * cacainfo.php sample program for libcaca php binding
  5. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  6. *
  7. * This program is free software. It comes without any warranty, to
  8. * the extent permitted by applicable law. You can redistribute it
  9. * and/or modify it under the terms of the Do What The Fuck You Want
  10. * To Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. //--- Just for fun ---//
  14. function just_for_fun() {
  15. $moo = <<<EOT
  16. (__)
  17. (oo)
  18. /------\/
  19. / | ||
  20. * /\---/\
  21. ~~ ~~
  22. EOT;
  23. $cv = caca_create_canvas(0, 0);
  24. caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT);
  25. caca_import_string($cv, $moo, "text");
  26. for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
  27. for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
  28. caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE : CACA_WHITE), CACA_DEFAULT);
  29. $a = caca_get_attr($cv, -1, -1);
  30. caca_put_attr($cv, $i, $j, $a);
  31. caca_put_attr($cv, $i + 1, $j, $a);
  32. }
  33. }
  34. caca_set_canvas_size($cv, 18, 6);
  35. caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
  36. caca_put_str($cv, 14, 0, "Moo!");
  37. caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
  38. caca_put_char($cv, 14, 1, hexdec("2765")); //U+2765
  39. caca_put_char($cv, 16, 1, hexdec("2764")); //U+2764
  40. echo caca_export_string($cv, "utf8");
  41. }
  42. if (php_sapi_name() != "cli") {
  43. die("You have to run this program with php-cli!\n");
  44. }
  45. just_for_fun();
  46. //--- Show caca's information ---//
  47. echo "libcaca version: ".caca_get_version()."\n\n";
  48. echo "Available drivers:\n";
  49. $list = caca_get_display_driver_list();
  50. foreach($list as $type => $name)
  51. echo "* $name ($type)\n";
  52. echo "\n";
  53. echo "Available import formats:\n";
  54. $list = caca_get_import_list();
  55. foreach($list as $format => $name)
  56. echo "* $name ($format)\n";
  57. echo "\n";
  58. echo "Available export formats:\n";
  59. $list = caca_get_export_list();
  60. foreach($list as $format => $name)
  61. echo "* $name ($format)\n";
  62. echo "\n";
  63. echo "Available caca fonts:\n";
  64. $list = caca_get_font_list();
  65. foreach($list as $name)
  66. echo "* $name\n";
  67. echo "\n";
  68. ?>