You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 line
2.1 KiB

  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. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. # include <string.h>
  18. #endif
  19. #include "cucul.h"
  20. #include "caca.h"
  21. static char const pig[] =
  22. " ,__ __,\n"
  23. " \\)`\\_..._/`(/\n"
  24. " .' _ _ '.\n"
  25. " / o\\ /o \\\n"
  26. " | .-.-. | _\n"
  27. " | /() ()\\ | (,`)\n"
  28. " / \\ '-----' / \\ .'\n"
  29. "| '-..___..-' |\n"
  30. "| |\n"
  31. "| |\n"
  32. "; ;\n"
  33. " \\ / \\ /\n"
  34. " \\-..-/'-'\\-..-/\n"
  35. "jgs\\/\\/ \\/\\/\n";
  36. int main(int argc, char *argv[])
  37. {
  38. cucul_canvas_t *cv, *sprite;
  39. caca_display_t *dp;
  40. cv = cucul_create_canvas(80, 24);
  41. if(cv == NULL)
  42. {
  43. printf("Failed to create canvas\n");
  44. return 1;
  45. }
  46. dp = caca_create_display(cv);
  47. if(dp == NULL)
  48. {
  49. printf("Failed to create display\n");
  50. return 1;
  51. }
  52. sprite = cucul_create_canvas(0, 0);
  53. cucul_set_color_ansi(sprite, CUCUL_LIGHTRED, CUCUL_BLACK);
  54. cucul_import_memory(sprite, pig, strlen(pig), "text");
  55. cucul_set_canvas_handle(sprite, cucul_get_canvas_width(sprite) / 2,
  56. cucul_get_canvas_height(sprite) / 2);
  57. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  58. cucul_put_str(cv, 0, 0, "Centered sprite");
  59. cucul_blit(cv, cucul_get_canvas_width(cv) / 2,
  60. cucul_get_canvas_height(cv) / 2, sprite, NULL);
  61. caca_refresh_display(dp);
  62. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  63. caca_free_display(dp);
  64. cucul_free_canvas(sprite);
  65. cucul_free_canvas(cv);
  66. return 0;
  67. }