Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

transform.c 3.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. # include <string.h>
  21. #endif
  22. #include "cucul.h"
  23. #include "caca.h"
  24. static char const pig[] =
  25. ",--. ,--.\n"
  26. "\\ /-~-\\ /\n"
  27. " )' o O `(\n"
  28. "( ,---. )\n"
  29. " `(_o_o_)'\n"
  30. " )`-'(\n";
  31. static char const duck[] =
  32. " ,~~.\n"
  33. " __ , ( O )>\n"
  34. "___( o)> )`~~' (\n"
  35. "\\ <_. ) ( .__) )\n"
  36. " `---' `-.____,'\n";
  37. int main(int argc, char *argv[])
  38. {
  39. cucul_canvas_t *cv, *image, *tmp, *sprite;
  40. caca_display_t *dp;
  41. cv = cucul_create_canvas(0, 0);
  42. dp = caca_create_display(cv);
  43. image = cucul_create_canvas(70, 6);
  44. tmp = cucul_create_canvas(70, 6);
  45. sprite = cucul_create_canvas(0, 0);
  46. cucul_set_color_ansi(sprite, CUCUL_LIGHTMAGENTA, CUCUL_BLACK);
  47. cucul_import_memory(sprite, pig, strlen(pig), "text");
  48. cucul_blit(image, 55, 0, sprite, NULL);
  49. cucul_set_color_ansi(sprite, CUCUL_LIGHTGREEN, CUCUL_BLACK);
  50. cucul_import_memory(sprite, duck, strlen(duck), "text");
  51. cucul_blit(image, 30, 1, sprite, NULL);
  52. cucul_set_color_ansi(image, CUCUL_LIGHTCYAN, CUCUL_BLACK);
  53. cucul_put_str(image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
  54. cucul_set_color_ansi(image, CUCUL_LIGHTRED, CUCUL_BLACK);
  55. cucul_put_char(image, 38, 1, '|');
  56. cucul_set_color_ansi(image, CUCUL_YELLOW, CUCUL_BLACK);
  57. cucul_put_str(image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
  58. cucul_set_color_ansi(image, CUCUL_WHITE, CUCUL_LIGHTRED);
  59. cucul_put_str(image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
  60. cucul_put_str(image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
  61. cucul_set_color_ansi(image, CUCUL_BLACK, CUCUL_LIGHTRED);
  62. cucul_put_str(image, 4, 3, "▓▒░");
  63. cucul_put_str(image, 4, 4, "▓▒░");
  64. cucul_put_str(image, 24, 3, "░▒▓");
  65. cucul_put_str(image, 24, 4, "░▒▓");
  66. /* Blit the transformed canvas onto the main canvas */
  67. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  68. cucul_put_str(cv, 0, 0, "normal");
  69. cucul_blit(cv, 10, 0, image, NULL);
  70. cucul_put_str(cv, 0, 6, "flip");
  71. cucul_blit(tmp, 0, 0, image, NULL);
  72. cucul_flip(tmp);
  73. cucul_blit(cv, 10, 6, tmp, NULL);
  74. cucul_put_str(cv, 0, 12, "flop");
  75. cucul_blit(tmp, 0, 0, image, NULL);
  76. cucul_flop(tmp);
  77. cucul_blit(cv, 10, 12, tmp, NULL);
  78. cucul_put_str(cv, 0, 18, "rotate");
  79. cucul_blit(tmp, 0, 0, image, NULL);
  80. cucul_rotate(tmp);
  81. cucul_blit(cv, 10, 18, tmp, NULL);
  82. caca_refresh_display(dp);
  83. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  84. caca_free_display(dp);
  85. cucul_free_canvas(tmp);
  86. cucul_free_canvas(sprite);
  87. cucul_free_canvas(image);
  88. cucul_free_canvas(cv);
  89. return 0;
  90. }