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.
 
 
 
 
 
 

55 lines
1.5 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. * truecolor truecolor canvas features
  10. * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
  11. *
  12. * This file is a Php port of "examples/truecolor.c"
  13. * which is:
  14. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  15. * All Rights Reserved
  16. *
  17. * This program is free software. It comes without any warranty, to
  18. * the extent permitted by applicable law. You can redistribute it
  19. * and/or modify it under the terms of the Do What The Fuck You Want
  20. * To Public License, Version 2, as published by Sam Hocevar. See
  21. * http://sam.zoy.org/wtfpl/COPYING for more details.
  22. */
  23. ?>
  24. <head>
  25. <title>truecolor canvas features</title>
  26. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  27. </head>
  28. <body text="silver" bgcolor="black">
  29. <?php
  30. $cv = caca_create_canvas(32, 16);
  31. if(!$cv) {
  32. die("Failed to create canvas\n");
  33. }
  34. for($y = 0; $y < 16; $y++)
  35. for($x = 0; $x < 16; $x++)
  36. {
  37. $bgcolor = 0xff00 | ($y << 4) | $x;
  38. $fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8);
  39. caca_set_color_argb($cv, $fgcolor, $bgcolor);
  40. caca_put_str($cv, $x * 2, $y, "CA");
  41. }
  42. caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
  43. caca_put_str($cv, 2, 1, " truecolor libcaca ");
  44. echo caca_export_string($cv, "html3");
  45. ?>
  46. </body>
  47. </html>