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

117 行
3.4 KiB

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