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.

cacainfo.php 2.4 KiB

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