Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * blit libcaca blit 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. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #include "common.h"
  16. #if !defined(__KERNEL__)
  17. # include <stdio.h>
  18. # include <string.h>
  19. #endif
  20. #include "cucul.h"
  21. #include "caca.h"
  22. static char const pig[] =
  23. " ,__ __,\n"
  24. " \\)`\\_..._/`(/\n"
  25. " .' _ _ '.\n"
  26. " / o\\ /o \\\n"
  27. " | .-.-. | _\n"
  28. " | /() ()\\ | (,`)\n"
  29. " / \\ '-----' / \\ .'\n"
  30. "| '-..___..-' |\n"
  31. "| |\n"
  32. "| |\n"
  33. "; ;\n"
  34. " \\ / \\ /\n"
  35. " \\-..-/'-'\\-..-/\n"
  36. "jgs\\/\\/ \\/\\/\n";
  37. int main(int argc, char *argv[])
  38. {
  39. cucul_canvas_t *cv, *sprite;
  40. caca_display_t *dp;
  41. cv = cucul_create_canvas(80, 24);
  42. if(cv == NULL)
  43. {
  44. printf("Failed to create canvas\n");
  45. return 1;
  46. }
  47. dp = caca_create_display(cv);
  48. if(dp == NULL)
  49. {
  50. printf("Failed to create display\n");
  51. return 1;
  52. }
  53. sprite = cucul_create_canvas(0, 0);
  54. cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK);
  55. cucul_import_memory(sprite, pig, strlen(pig), "text");
  56. cucul_set_canvas_handle(sprite, cucul_get_canvas_width(sprite) / 2,
  57. cucul_get_canvas_height(sprite) / 2);
  58. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  59. cucul_put_str(cv, 0, 0, "Centered sprite");
  60. cucul_blit(cv, cucul_get_canvas_width(cv) / 2,
  61. cucul_get_canvas_height(cv) / 2, sprite, NULL);
  62. caca_refresh_display(dp);
  63. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  64. caca_free_display(dp);
  65. cucul_free_canvas(sprite);
  66. cucul_free_canvas(cv);
  67. return 0;
  68. }