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.

transform.php 2.9 KiB

16 lat temu
16 lat temu
16 lat temu
16 lat temu
16 lat temu
16 lat temu
16 lat temu
16 lat temu
16 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/php5
  2. <?php
  3. /*
  4. * transform transformation test program
  5. * Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
  6. *
  7. * This file is a Php port of "examples/transform.c"
  8. * which is:
  9. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  10. * All Rights Reserved
  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. if (php_sapi_name() != "cli") {
  19. die("You have to run this program with php-cli!\n");
  20. }
  21. $pig = (
  22. ",--. ,--.\n" .
  23. "\\ /-~-\\ /\n" .
  24. " )' o O `(\n" .
  25. "( ,---. )\n" .
  26. " `(_o_o_)'\n" .
  27. " )`-'(\n");
  28. $duck = (
  29. " ,~~.\n" .
  30. " __ , ( O )>\n" .
  31. "___( o)> )`~~' (\n" .
  32. "\\ <_. ) ( .__) )\n" .
  33. " `---' `-.____,'\n");
  34. $cv = caca_create_canvas(0, 0);
  35. if(! $cv)
  36. {
  37. die("Can't created canvas\n");
  38. }
  39. $dp = caca_create_display($cv);
  40. if(! $dp)
  41. {
  42. die("Can't create display\n");
  43. }
  44. $image = caca_create_canvas(70, 6);
  45. $tmp = caca_create_canvas(70, 6);
  46. $sprite = caca_create_canvas(0, 0);
  47. caca_set_color_ansi($sprite, CACA_LIGHTMAGENTA, CACA_BLACK);
  48. caca_import_string($sprite, $pig, "text");
  49. caca_blit($image, 55, 0, $sprite);
  50. caca_set_color_ansi($sprite, CACA_LIGHTGREEN, CACA_BLACK);
  51. caca_import_string($sprite, $duck, "text");
  52. caca_blit($image, 30, 1, $sprite);
  53. caca_set_color_ansi($image, CACA_LIGHTCYAN, CACA_BLACK);
  54. caca_put_str($image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
  55. caca_set_color_ansi($image, CACA_LIGHTRED, CACA_BLACK);
  56. caca_put_char($image, 38, 1, ord('|'));
  57. caca_set_color_ansi($image, CACA_YELLOW, CACA_BLACK);
  58. caca_put_str($image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  59. caca_set_color_ansi($image, CACA_WHITE, CACA_LIGHTRED);
  60. caca_put_str($image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  61. caca_put_str($image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  62. caca_set_color_ansi($image, CACA_BLACK, CACA_LIGHTRED);
  63. caca_put_str($image, 4, 3, "▓▒░");
  64. caca_put_str($image, 4, 4, "▓▒░");
  65. caca_put_str($image, 24, 3, "░▒▓");
  66. caca_put_str($image, 24, 4, "░▒▓");
  67. /* Blit the transformed canvas onto the main canvas */
  68. caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE);
  69. caca_put_str($cv, 0, 0, "normal");
  70. caca_blit($cv, 10, 0, $image);
  71. caca_put_str($cv, 0, 6, "flip");
  72. caca_blit($tmp, 0, 0, $image);
  73. caca_flip($tmp);
  74. caca_blit($cv, 10, 6, $tmp);
  75. caca_put_str($cv, 0, 12, "flop");
  76. caca_blit($tmp, 0, 0, $image);
  77. caca_flop($tmp);
  78. caca_blit($cv, 10, 12, $tmp);
  79. caca_put_str($cv, 0, 18, "rotate");
  80. caca_blit($tmp, 0, 0, $image);
  81. caca_rotate_180($tmp);
  82. caca_blit($cv, 10, 18, $tmp);
  83. caca_refresh_display($dp);
  84. caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
  85. ?>