You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

86 lines
2.1 KiB

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