Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

80 rader
2.0 KiB

  1. /*
  2. * blit libcaca blit test program
  3. * Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * This program is free software. It comes without any warranty, to
  7. * the extent permitted by applicable law. You can redistribute it
  8. * and/or modify it under the terms of the Do What The Fuck You Want
  9. * To Public License, Version 2, as published by Sam Hocevar. See
  10. * http://sam.zoy.org/wtfpl/COPYING for more details.
  11. */
  12. #include "config.h"
  13. #if !defined(__KERNEL__)
  14. # include <stdio.h>
  15. # include <string.h>
  16. #endif
  17. #include "caca.h"
  18. static char const pig[] =
  19. " ,__ __,\n"
  20. " \\)`\\_..._/`(/\n"
  21. " .' _ _ '.\n"
  22. " / o\\ /o \\\n"
  23. " | .-.-. | _\n"
  24. " | /() ()\\ | (,`)\n"
  25. " / \\ '-----' / \\ .'\n"
  26. "| '-..___..-' |\n"
  27. "| |\n"
  28. "| |\n"
  29. "; ;\n"
  30. " \\ / \\ /\n"
  31. " \\-..-/'-'\\-..-/\n"
  32. "jgs\\/\\/ \\/\\/\n";
  33. int main(int argc, char *argv[])
  34. {
  35. caca_canvas_t *cv, *sprite;
  36. caca_display_t *dp;
  37. cv = caca_create_canvas(80, 24);
  38. if(cv == NULL)
  39. {
  40. printf("Failed to create canvas\n");
  41. return 1;
  42. }
  43. dp = caca_create_display(cv);
  44. if(dp == NULL)
  45. {
  46. printf("Failed to create display\n");
  47. return 1;
  48. }
  49. sprite = caca_create_canvas(0, 0);
  50. caca_set_color_ansi(sprite, CACA_LIGHTRED, CACA_BLACK);
  51. caca_import_canvas_from_memory(sprite, pig, strlen(pig), "text");
  52. caca_set_canvas_handle(sprite, caca_get_canvas_width(sprite) / 2,
  53. caca_get_canvas_height(sprite) / 2);
  54. caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
  55. caca_put_str(cv, 0, 0, "Centered sprite");
  56. caca_blit(cv, caca_get_canvas_width(cv) / 2,
  57. caca_get_canvas_height(cv) / 2, sprite, NULL);
  58. caca_refresh_display(dp);
  59. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  60. caca_free_display(dp);
  61. caca_free_canvas(sprite);
  62. caca_free_canvas(cv);
  63. return 0;
  64. }