25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

transform.c 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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(HAVE_INTTYPES_H)
  16. # include <inttypes.h>
  17. #endif
  18. #include <stdio.h>
  19. #include "cucul.h"
  20. #include "caca.h"
  21. static char const *pig[] =
  22. {
  23. ",--. ,--.",
  24. "\\ /-~-\\ /",
  25. " )' o O `(",
  26. "( ,---. )",
  27. " `(_o_o_)'",
  28. " )`-'(",
  29. NULL
  30. };
  31. static char const *duck[] =
  32. {
  33. " ,~~.",
  34. " __ , ( O )>",
  35. "___( o)> )`~~' (",
  36. "\\ <_. ) ( .__) )",
  37. " `---' `-.____,'",
  38. NULL
  39. };
  40. int main(void)
  41. {
  42. cucul_canvas_t *cv, *normal, *flip, *flop, *rotate;
  43. caca_display_t *dp;
  44. int i;
  45. cv = cucul_create_canvas(0, 0);
  46. dp = caca_create_display(cv);
  47. normal = cucul_create_canvas(70, 6);
  48. flip = cucul_create_canvas(70, 6);
  49. flop = cucul_create_canvas(70, 6);
  50. rotate = cucul_create_canvas(70, 6);
  51. cucul_set_color(normal, CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
  52. for(i = 0; pig[i]; i++)
  53. cucul_putstr(normal, 55, i, pig[i]);
  54. cucul_set_color(normal, CUCUL_COLOR_LIGHTGREEN, CUCUL_COLOR_BLACK);
  55. for(i = 0; duck[i]; i++)
  56. cucul_putstr(normal, 30, 1 + i, duck[i]);
  57. cucul_set_color(normal, CUCUL_COLOR_LIGHTCYAN, CUCUL_COLOR_BLACK);
  58. cucul_putstr(normal, 1, 1, "hahaha mais vieux porc immonde !!");
  59. cucul_set_color(normal, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK);
  60. cucul_putstr(normal, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  61. cucul_set_color(normal, CUCUL_COLOR_WHITE, CUCUL_COLOR_LIGHTRED);
  62. cucul_putstr(normal, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  63. cucul_putstr(normal, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  64. cucul_set_color(normal, CUCUL_COLOR_BLACK, CUCUL_COLOR_LIGHTRED);
  65. cucul_putstr(normal, 4, 3, "▓▒░");
  66. cucul_putstr(normal, 4, 4, "▓▒░");
  67. cucul_putstr(normal, 24, 3, "░▒▓");
  68. cucul_putstr(normal, 24, 4, "░▒▓");
  69. /* Flip, flop and rotate our working canvas */
  70. cucul_blit(flip, 0, 0, normal, NULL);
  71. cucul_flip(flip);
  72. cucul_blit(flop, 0, 0, normal, NULL);
  73. cucul_flop(flop);
  74. cucul_blit(rotate, 0, 0, normal, NULL);
  75. cucul_rotate(rotate);
  76. /* Blit the transformed canvas onto the main canvas */
  77. cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
  78. cucul_putstr(cv, 0, 0, "normal");
  79. cucul_blit(cv, 10, 0, normal, NULL);
  80. cucul_putstr(cv, 0, 6, "flip");
  81. cucul_blit(cv, 10, 6, flip, NULL);
  82. cucul_putstr(cv, 0, 12, "flop");
  83. cucul_blit(cv, 10, 12, flop, NULL);
  84. cucul_putstr(cv, 0, 18, "rotate");
  85. cucul_blit(cv, 10, 18, rotate, NULL);
  86. caca_refresh_display(dp);
  87. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  88. caca_free_display(dp);
  89. cucul_free_canvas(rotate);
  90. cucul_free_canvas(flop);
  91. cucul_free_canvas(flip);
  92. cucul_free_canvas(normal);
  93. cucul_free_canvas(cv);
  94. return 0;
  95. }