Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cacainfo.php 2.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
  35. caca_put_str($cv, 8, 0, "Moo!");
  36. caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
  37. caca_put_char($cv, 8, 1, hexdec("2765")); //U+2765
  38. caca_put_char($cv, 10, 1, hexdec("2764")); //U+2764
  39. echo caca_export_string($cv, "utf8");
  40. }
  41. just_for_fun();
  42. //--- Show caca's information ---//
  43. echo "libcaca version: ".caca_get_version()."\n\n";
  44. echo "Available drivers:\n";
  45. $list = caca_get_display_driver_list();
  46. foreach($list as $type => $name)
  47. echo "* $name ($type)\n";
  48. echo "\n";
  49. echo "Available import formats:\n";
  50. $list = caca_get_import_list();
  51. foreach($list as $format => $name)
  52. echo "* $name ($format)\n";
  53. echo "\n";
  54. echo "Available export formats:\n";
  55. $list = caca_get_export_list();
  56. foreach($list as $format => $name)
  57. echo "* $name ($format)\n";
  58. echo "\n";
  59. echo "Available caca fonts:\n";
  60. $list = caca_get_font_list();
  61. foreach($list as $name)
  62. echo "* $name\n";
  63. echo "\n";
  64. ?>