Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

74 рядки
1.8 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. " | OO | \n" \
  29. " \\ `--' / \n" \
  30. " `----' \n" \
  31. "Hello world!\n"
  32. int main(int argc, char *argv[])
  33. {
  34. cucul_canvas_t *cv, *pig;
  35. void *buffer;
  36. unsigned long int len;
  37. pig = cucul_create_canvas(0, 0);
  38. cucul_import_memory(pig, STRING, strlen(STRING), "text");
  39. cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
  40. cucul_get_canvas_height(pig) * 2);
  41. if(cv == NULL || pig == NULL)
  42. {
  43. printf("Can't created canvas\n");
  44. return -1;
  45. }
  46. cucul_blit(cv, 0, 0, pig, NULL);
  47. cucul_flip(pig);
  48. cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
  49. cucul_flip(pig);
  50. cucul_flop(pig);
  51. cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
  52. cucul_flop(pig);
  53. cucul_rotate(pig);
  54. cucul_blit(cv, cucul_get_canvas_width(pig),
  55. cucul_get_canvas_height(pig), pig, NULL);
  56. buffer = cucul_export_memory(cv, "utf8", &len);
  57. fwrite(buffer, len, 1, stdout);
  58. free(buffer);
  59. cucul_free_canvas(pig);
  60. cucul_free_canvas(cv);
  61. return 0;
  62. }