No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

105 líneas
2.5 KiB

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