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.
 
 
 
 
 
 

82 linhas
2.0 KiB

  1. /*
  2. * text canvas text import/export
  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. # if defined(HAVE_INTTYPES_H)
  18. # include <inttypes.h>
  19. # endif
  20. # include <stdio.h>
  21. # include <string.h>
  22. # include <stdlib.h>
  23. #endif
  24. #include "cucul.h"
  25. #define STRING \
  26. " \n" \
  27. " _,----._ \n" \
  28. " (/ @ @ \\) \n" \
  29. " | OO | \n" \
  30. " \\ `--' / \n" \
  31. " `----' \n" \
  32. " \n" \
  33. " Hello world! \n" \
  34. " \n"
  35. int main(int argc, char *argv[])
  36. {
  37. cucul_canvas_t *cv, *pig;
  38. void *buffer;
  39. unsigned long int len;
  40. pig = cucul_create_canvas(0, 0);
  41. cucul_import_memory(pig, STRING, strlen(STRING), "text");
  42. cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
  43. cucul_get_canvas_height(pig) * 2);
  44. if(cv == NULL || pig == NULL)
  45. {
  46. printf("Can't created canvas\n");
  47. return -1;
  48. }
  49. cucul_blit(cv, 0, 0, pig, NULL);
  50. cucul_flip(pig);
  51. cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
  52. cucul_flip(pig);
  53. cucul_flop(pig);
  54. cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
  55. cucul_flop(pig);
  56. cucul_rotate(pig);
  57. cucul_blit(cv, cucul_get_canvas_width(pig),
  58. cucul_get_canvas_height(pig), pig, NULL);
  59. buffer = cucul_export_memory(cv, "utf8", &len);
  60. fwrite(buffer, len, 1, stdout);
  61. free(buffer);
  62. cucul_left(cv);
  63. buffer = cucul_export_memory(cv, "utf8", &len);
  64. fwrite(buffer, len, 1, stdout);
  65. free(buffer);
  66. cucul_free_canvas(pig);
  67. cucul_free_canvas(cv);
  68. return 0;
  69. }