您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  2. <head>
  3. <title>Caca power!</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  5. <style type="text/css">
  6. </style>
  7. </head>
  8. <body>
  9. <?php
  10. /*
  11. * figlet.php sample program for libcaca php binding
  12. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  13. *
  14. * This program is free software. It comes without any warranty, to
  15. * the extent permitted by applicable law. You can redistribute it
  16. * and/or modify it under the terms of the Do What The Fuck You Want
  17. * To Public License, Version 2, as published by Sam Hocevar. See
  18. * http://sam.zoy.org/wtfpl/COPYING for more details.
  19. */
  20. function unistr_to_ords($str, $encoding = 'UTF-8'){
  21. $str = mb_convert_encoding($str, "UCS-4BE", $encoding);
  22. $result = array();
  23. for ($i = 0; $i < mb_strlen($str, "UCS-4BE"); $i++){
  24. $c = mb_substr($str, $i, 1, "UCS-4BE");
  25. $val = unpack("N", $c);
  26. $result[] = $val[1];
  27. }
  28. return $result;
  29. }
  30. function show_figlet($str, $font) {
  31. $cv = caca_create_canvas(0, 0);
  32. if (!caca_canvas_set_figfont($cv, $font)) {
  33. return false;
  34. }
  35. $chars = unistr_to_ords($str);
  36. $color = 0;
  37. foreach ($chars as $c) {
  38. caca_set_color_ansi($cv, 1 + (($color += 4) % 15), CACA_WHITE);
  39. caca_put_figchar($cv, $c);
  40. }
  41. echo caca_export_string($cv, "html3");
  42. }
  43. $path = "/usr/share/figlet/";
  44. if (!is_dir($path)) {
  45. die("can not open directory $path.\n");
  46. }
  47. $dir = opendir($path);
  48. while (($it = readdir($dir)) != false) {
  49. if (is_file($path.$it) and ereg("\.[tf]lf$", $it)) {
  50. echo "<b>font : $it</b>\n<pre>";
  51. show_figlet("Libcaca", $path.$it);
  52. echo "</pre>";
  53. }
  54. }
  55. ?>
  56. </body>
  57. </html>