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.
 
 
 
 
 
 

74 lines
2.0 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. * demo.php demo for libcaca php binding
  7. * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
  8. *
  9. * This file is a Php port of the official libcaca's sample program "demo.c"
  10. * which is:
  11. * Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
  12. *
  13. * This program is free software. It comes without any warranty, to
  14. * the extent permitted by applicable law. You can redistribute it
  15. * and/or modify it under the terms of the Do What The Fuck You Want
  16. * To Public License, Version 2, as published by Sam Hocevar. See
  17. * http://sam.zoy.org/wtfpl/COPYING for more details.
  18. */
  19. ?>
  20. <head>
  21. <title>demo for libcaca php binding</title>
  22. <link rel="StyleSheet" href="caca-php.css" type="text/css" />
  23. </head>
  24. <body text="silver" bgcolor="black">
  25. <?php
  26. $string = <<<EOT
  27. |_|
  28. _,----._ | |
  29. (/ @ @ \) __
  30. | OO | |_
  31. \ `--' / |__
  32. `----'
  33. |_|
  34. Hello world! |
  35. EOT;
  36. $pig = caca_create_canvas(0, 0);
  37. caca_import_string($pig, $string, "text");
  38. $cv = caca_create_canvas(caca_get_canvas_width($pig) * 2, caca_get_canvas_height($pig) * 2);
  39. if (!$cv or !$pig) {
  40. die("Can't created canvas\n");
  41. }
  42. caca_blit($cv, 0, 0, $pig);
  43. caca_flip($pig);
  44. caca_blit($cv, caca_get_canvas_width($pig), 0, $pig);
  45. caca_flip($pig);
  46. caca_flop($pig);
  47. caca_blit($cv, 0, caca_get_canvas_height($pig), $pig);
  48. caca_flop($pig);
  49. caca_rotate_180($pig);
  50. caca_blit($cv, caca_get_canvas_width($pig), caca_get_canvas_height($pig), $pig);
  51. for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
  52. for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
  53. caca_set_color_ansi($cv, CACA_LIGHTBLUE + ($i + $j) % 6, CACA_DEFAULT);
  54. $a = caca_get_attr($cv, -1, -1);
  55. caca_put_attr($cv, $i, $j, $a);
  56. caca_put_attr($cv, $i + 1, $j, $a);
  57. }
  58. }
  59. echo caca_export_string($cv, "html3");
  60. caca_rotate_left($cv);
  61. echo caca_export_string($cv, "html3");
  62. ?>
  63. </body>
  64. </html>