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

123 行
3.2 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; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. #include "config.h"
  14. #if defined(HAVE_INTTYPES_H)
  15. # include <inttypes.h>
  16. #else
  17. typedef unsigned char uint8_t;
  18. typedef unsigned short uint16_t;
  19. typedef unsigned int uint32_t;
  20. #endif
  21. #include <stdio.h>
  22. #include "cucul.h"
  23. #include "caca.h"
  24. static char const *pig[] =
  25. {
  26. ",--. ,--.",
  27. "\\ /-~-\\ /",
  28. " )' o O `(",
  29. "( ,---. )",
  30. " `(_o_o_)'",
  31. " )`-'(",
  32. NULL
  33. };
  34. static char const *duck[] =
  35. {
  36. " ,~~.",
  37. " __ , ( O )>",
  38. "___( o)> )`~~' (",
  39. "\\ <_. ) ( .__) )",
  40. " `---' `-.____,'",
  41. NULL
  42. };
  43. int main(void)
  44. {
  45. struct caca_event ev;
  46. cucul_t *qq, *normal, *flip, *flop, *rotate;
  47. caca_t *kk;
  48. int i;
  49. qq = cucul_create(0, 0);
  50. kk = caca_attach(qq);
  51. normal = cucul_create(70, 6);
  52. flip = cucul_create(70, 6);
  53. flop = cucul_create(70, 6);
  54. rotate = cucul_create(70, 6);
  55. cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
  56. for(i = 0; pig[i]; i++)
  57. cucul_putstr(normal, 55, i, pig[i]);
  58. cucul_set_color(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK);
  59. for(i = 0; duck[i]; i++)
  60. cucul_putstr(normal, 30, 1 + i, duck[i]);
  61. cucul_set_color(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK);
  62. cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !!");
  63. cucul_set_color(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  64. cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  65. cucul_set_color(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED);
  66. cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  67. cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  68. cucul_set_color(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED);
  69. cucul_putstr(normal, 4, 3, "▓▒░");
  70. cucul_putstr(normal, 4, 4, "▓▒░");
  71. cucul_putstr(normal, 24, 3, "░▒▓");
  72. cucul_putstr(normal, 24, 4, "░▒▓");
  73. /* Flip, flop and rotate our working canvas */
  74. cucul_blit(flip, 0, 0, normal, NULL);
  75. cucul_flip(flip);
  76. cucul_blit(flop, 0, 0, normal, NULL);
  77. cucul_flop(flop);
  78. cucul_blit(rotate, 0, 0, normal, NULL);
  79. cucul_rotate(rotate);
  80. /* Blit the transformed canvas onto the main canvas */
  81. cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
  82. cucul_putstr(qq, 0, 0, "normal");
  83. cucul_blit(qq, 10, 0, normal, NULL);
  84. cucul_putstr(qq, 0, 6, "flip");
  85. cucul_blit(qq, 10, 6, flip, NULL);
  86. cucul_putstr(qq, 0, 12, "flop");
  87. cucul_blit(qq, 10, 12, flop, NULL);
  88. cucul_putstr(qq, 0, 18, "rotate");
  89. cucul_blit(qq, 10, 18, rotate, NULL);
  90. caca_display(kk);
  91. caca_wait_event(kk, CACA_EVENT_KEY_PRESS, &ev);
  92. caca_detach(kk);
  93. cucul_free(rotate);
  94. cucul_free(flop);
  95. cucul_free(flip);
  96. cucul_free(normal);
  97. cucul_free(qq);
  98. return 0;
  99. }