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.
 
 
 
 
 
 

67 rivejä
1.6 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; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. #include "config.h"
  14. #include "common.h"
  15. #if !defined(__KERNEL__)
  16. # if defined(HAVE_INTTYPES_H)
  17. # include <inttypes.h>
  18. # endif
  19. # include <stdio.h>
  20. # include <string.h>
  21. # include <stdlib.h>
  22. #endif
  23. #include "cucul.h"
  24. #define STRING \
  25. " _,----._ \n" \
  26. " (/ @ @ \\) \n" \
  27. " | OO | \n" \
  28. " \\ `--' / \n" \
  29. " `----' \n" \
  30. "Hello world!\n"
  31. int main(int argc, char *argv[])
  32. {
  33. cucul_canvas_t *cv, *pig;
  34. void *buffer;
  35. unsigned long int len;
  36. pig = cucul_create_canvas(0, 0);
  37. cucul_import_memory(pig, STRING, strlen(STRING), "text");
  38. cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
  39. cucul_get_canvas_height(pig) * 2);
  40. cucul_blit(cv, 0, 0, pig, NULL);
  41. cucul_flip(pig);
  42. cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
  43. cucul_flip(pig);
  44. cucul_flop(pig);
  45. cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
  46. cucul_flop(pig);
  47. cucul_rotate(pig);
  48. cucul_blit(cv, cucul_get_canvas_width(pig),
  49. cucul_get_canvas_height(pig), pig, NULL);
  50. buffer = cucul_export_memory(cv, "utf8", &len);
  51. fwrite(buffer, len, 1, stdout);
  52. free(buffer);
  53. cucul_free_canvas(pig);
  54. cucul_free_canvas(cv);
  55. return 0;
  56. }