Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. # include <string.h>
  18. # include <stdlib.h>
  19. #endif
  20. #include "cucul.h"
  21. #define STRING \
  22. " |_| \n" \
  23. " _,----._ | | \n" \
  24. " (/ @ @ \\) __ \n" \
  25. " | OO | |_ \n" \
  26. " \\ `--' / |__ \n" \
  27. " `----' \n" \
  28. " |_| \n" \
  29. " Hello world! | \n" \
  30. " \n"
  31. int main(int argc, char *argv[])
  32. {
  33. cucul_canvas_t *cv, *pig;
  34. void *buffer;
  35. unsigned long int len;
  36. unsigned int i, j;
  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_180(pig);
  54. cucul_blit(cv, cucul_get_canvas_width(pig),
  55. cucul_get_canvas_height(pig), pig, NULL);
  56. for(j = 0; j < cucul_get_canvas_height(cv); j++)
  57. {
  58. for(i = 0; i < cucul_get_canvas_width(cv); i += 2)
  59. {
  60. unsigned long int a;
  61. cucul_set_color_ansi(cv, CUCUL_LIGHTBLUE + (i + j) % 6,
  62. CUCUL_DEFAULT);
  63. a = cucul_get_attr(cv, -1, -1);
  64. cucul_put_attr(cv, i, j, a);
  65. cucul_put_attr(cv, i + 1, j, a);
  66. }
  67. }
  68. buffer = cucul_export_memory(cv, "utf8", &len);
  69. fwrite(buffer, len, 1, stdout);
  70. free(buffer);
  71. cucul_rotate_left(cv);
  72. buffer = cucul_export_memory(cv, "utf8", &len);
  73. fwrite(buffer, len, 1, stdout);
  74. free(buffer);
  75. cucul_free_canvas(pig);
  76. cucul_free_canvas(cv);
  77. return 0;
  78. }