Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

119 řádky
3.3 KiB

  1. /*
  2. * unicode libcaca Unicode rendering test program
  3. * Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. # include <string.h>
  18. #endif
  19. #include "caca.h"
  20. static char const pig[] =
  21. ",--. ,--.\n"
  22. "\\ /-~-\\ /\n"
  23. " )' o O `(\n"
  24. "( ,---. )\n"
  25. " `(_o_o_)'\n"
  26. " )`-'(\n";
  27. static char const duck[] =
  28. " ,~~.\n"
  29. " __ , ( O )>\n"
  30. "___( o)> )`~~' (\n"
  31. "\\ <_. ) ( .__) )\n"
  32. " `---' `-.____,'\n";
  33. int main(int argc, char *argv[])
  34. {
  35. caca_canvas_t *cv, *image, *tmp, *sprite;
  36. caca_display_t *dp;
  37. cv = caca_create_canvas(0, 0);
  38. if(cv == NULL)
  39. {
  40. printf("Can't created canvas\n");
  41. return -1;
  42. }
  43. dp = caca_create_display(cv);
  44. if(dp == NULL)
  45. {
  46. printf("Can't create display\n");
  47. return -1;
  48. }
  49. image = caca_create_canvas(70, 6);
  50. tmp = caca_create_canvas(70, 6);
  51. sprite = caca_create_canvas(0, 0);
  52. caca_set_color_ansi(sprite, CACA_LIGHTMAGENTA, CACA_BLACK);
  53. caca_import_memory(sprite, pig, strlen(pig), "text");
  54. caca_blit(image, 55, 0, sprite, NULL);
  55. caca_set_color_ansi(sprite, CACA_LIGHTGREEN, CACA_BLACK);
  56. caca_import_memory(sprite, duck, strlen(duck), "text");
  57. caca_blit(image, 30, 1, sprite, NULL);
  58. caca_set_color_ansi(image, CACA_LIGHTCYAN, CACA_BLACK);
  59. caca_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
  60. caca_set_color_ansi(image, CACA_LIGHTRED, CACA_BLACK);
  61. caca_put_char(image, 38, 1, '|');
  62. caca_set_color_ansi(image, CACA_YELLOW, CACA_BLACK);
  63. caca_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  64. caca_set_color_ansi(image, CACA_WHITE, CACA_LIGHTRED);
  65. caca_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  66. caca_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  67. caca_set_color_ansi(image, CACA_BLACK, CACA_LIGHTRED);
  68. caca_put_str(image, 4, 3, "▓▒░");
  69. caca_put_str(image, 4, 4, "▓▒░");
  70. caca_put_str(image, 24, 3, "░▒▓");
  71. caca_put_str(image, 24, 4, "░▒▓");
  72. /* Blit the transformed canvas onto the main canvas */
  73. caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
  74. caca_put_str(cv, 0, 0, "normal");
  75. caca_blit(cv, 10, 0, image, NULL);
  76. caca_put_str(cv, 0, 6, "flip");
  77. caca_blit(tmp, 0, 0, image, NULL);
  78. caca_flip(tmp);
  79. caca_blit(cv, 10, 6, tmp, NULL);
  80. caca_put_str(cv, 0, 12, "flop");
  81. caca_blit(tmp, 0, 0, image, NULL);
  82. caca_flop(tmp);
  83. caca_blit(cv, 10, 12, tmp, NULL);
  84. caca_put_str(cv, 0, 18, "rotate");
  85. caca_blit(tmp, 0, 0, image, NULL);
  86. caca_rotate_180(tmp);
  87. caca_blit(cv, 10, 18, tmp, NULL);
  88. caca_refresh_display(dp);
  89. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  90. caca_free_display(dp);
  91. caca_free_canvas(tmp);
  92. caca_free_canvas(sprite);
  93. caca_free_canvas(image);
  94. caca_free_canvas(cv);
  95. return 0;
  96. }