Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

110 wiersze
2.7 KiB

  1. <?php
  2. header('Content-Type: text/html; charset=UTF-8');
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  5. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  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://www.wtfpl.net/ for more details.
  17. */
  18. ?>
  19. <head>
  20. <title>sample program for libcaca php binding</title>
  21. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  22. </head>
  23. <body text="silver" bgcolor="black">
  24. <?php
  25. //--- Just for fun ---//
  26. function just_for_fun() {
  27. $moo = <<<EOT
  28. (__)
  29. (oo)
  30. /------\/
  31. / | ||
  32. * /\---/\
  33. ~~ ~~
  34. EOT;
  35. $cv = caca_create_canvas(0, 0);
  36. caca_set_color_ansi($cv, CACA_LIGHTBLUE, CACA_DEFAULT);
  37. caca_import_string($cv, $moo, "text");
  38. for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
  39. for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
  40. caca_set_color_ansi($cv, (caca_rand(1, 10) > 5 ? CACA_LIGHTBLUE : CACA_WHITE), CACA_DEFAULT);
  41. $a = caca_get_attr($cv, -1, -1);
  42. caca_put_attr($cv, $i, $j, $a);
  43. caca_put_attr($cv, $i + 1, $j, $a);
  44. }
  45. }
  46. caca_set_canvas_size($cv, 18, 6);
  47. caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_DEFAULT);
  48. caca_put_str($cv, 14, 0, "Moo!");
  49. caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_DEFAULT);
  50. caca_put_char($cv, 14, 1, hexdec("2765")); //U+2765
  51. caca_put_char($cv, 16, 1, hexdec("2764")); //U+2764
  52. echo caca_export_string($cv, "html3");
  53. }
  54. just_for_fun();
  55. ?>
  56. <?php
  57. //--- Show caca's information ---//
  58. ?>
  59. <p>libcaca version: <?php echo htmlspecialchars(caca_get_version()); ?></p>
  60. <p>Available drivers:</p>
  61. <ul>
  62. <?php
  63. $list = caca_get_display_driver_list();
  64. foreach($list as $type => $name)
  65. echo '<li>' . htmlspecialchars("$name ($type)") . '</li>';
  66. ?>
  67. </ul>
  68. <p>Available import formats:</p>
  69. <ul>
  70. <?php
  71. $list = caca_get_import_list();
  72. foreach($list as $format => $name)
  73. echo '<li>' . htmlspecialchars("$name ($format)") . '</li>';
  74. ?>
  75. </ul>
  76. <p>Available export formats:</p>
  77. <ul>
  78. <?php
  79. $list = caca_get_export_list();
  80. foreach($list as $format => $name)
  81. echo '<li>' . htmlspecialchars("$name ($format)") . '</li>';
  82. ?>
  83. </ul>
  84. <p>Available caca fonts:</p>
  85. <ul>
  86. <?php
  87. $list = caca_get_font_list();
  88. foreach($list as $name)
  89. echo '<li>' . htmlspecialchars("$name") . '</li>';
  90. ?>
  91. </ul>
  92. </body>
  93. </html>