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

transform.c 3.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #include "common.h"
  15. #if !defined(__KERNEL__)
  16. # if defined(HAVE_INTTYPES_H)
  17. # include <inttypes.h>
  18. # endif
  19. # include <stdio.h>
  20. #endif
  21. #include "cucul.h"
  22. #include "caca.h"
  23. static char const *pig[] =
  24. {
  25. ",--. ,--.",
  26. "\\ /-~-\\ /",
  27. " )' o O `(",
  28. "( ,---. )",
  29. " `(_o_o_)'",
  30. " )`-'(",
  31. NULL
  32. };
  33. static char const *duck[] =
  34. {
  35. " ,~~.",
  36. " __ , ( O )>",
  37. "___( o)> )`~~' (",
  38. "\\ <_. ) ( .__) )",
  39. " `---' `-.____,'",
  40. NULL
  41. };
  42. int main(int argc, char *argv[])
  43. {
  44. cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
  45. caca_display_t *dp;
  46. int i;
  47. cv = cucul_create_canvas(0, 0);
  48. dp = caca_create_display(cv);
  49. normal = cucul_create_canvas(70, 6);
  50. flip = cucul_create_canvas(70, 6);
  51. flop = cucul_create_canvas(70, 6);
  52. rotate = cucul_create_canvas(70, 6);
  53. cucul_set_color_ansi(normal, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
  54. for(i = 0; pig[i]; i++)
  55. cucul_putstr(normal, 55, i, pig[i]);
  56. cucul_set_color_ansi(normal, CUCUL_LIGHTGREEN, CUCUL_BLACK);
  57. for(i = 0; duck[i]; i++)
  58. cucul_putstr(normal, 30, 1 + i, duck[i]);
  59. cucul_set_color_ansi(normal, CUCUL_LIGHTCYAN, CUCUL_BLACK);
  60. cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
  61. cucul_set_color_ansi(normal, CUCUL_LIGHTRED, CUCUL_BLACK);
  62. cucul_putchar(normal, 38, 1, '|');
  63. cucul_set_color_ansi(normal, CUCUL_YELLOW, CUCUL_BLACK);
  64. cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  65. cucul_set_color_ansi(normal, CUCUL_WHITE, CUCUL_LIGHTRED);
  66. cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  67. cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  68. cucul_set_color_ansi(normal, CUCUL_BLACK, CUCUL_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_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  82. cucul_putstr(cv, 0, 0, "normal");
  83. cucul_blit(cv, 10, 0, normal, NULL);
  84. cucul_putstr(cv, 0, 6, "flip");
  85. cucul_blit(cv, 10, 6, flip, NULL);
  86. cucul_putstr(cv, 0, 12, "flop");
  87. cucul_blit(cv, 10, 12, flop, NULL);
  88. cucul_putstr(cv, 0, 18, "rotate");
  89. cucul_blit(cv, 10, 18, rotate, NULL);
  90. caca_refresh_display(dp);
  91. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  92. caca_free_display(dp);
  93. cucul_free_canvas(rotate);
  94. cucul_free_canvas(flop);
  95. cucul_free_canvas(flip);
  96. cucul_free_canvas(normal);
  97. cucul_free_canvas(cv);
  98. return 0;
  99. }