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.
 
 
 
 
 
 

96 linhas
2.5 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. unsigned int i, j;
  41. pig = cucul_create_canvas(0, 0);
  42. cucul_import_memory(pig, STRING, strlen(STRING), "text");
  43. cv = cucul_create_canvas(cucul_get_canvas_width(pig) * 2,
  44. cucul_get_canvas_height(pig) * 2);
  45. if(cv == NULL || pig == NULL)
  46. {
  47. printf("Can't created canvas\n");
  48. return -1;
  49. }
  50. cucul_blit(cv, 0, 0, pig, NULL);
  51. cucul_flip(pig);
  52. cucul_blit(cv, cucul_get_canvas_width(pig), 0, pig, NULL);
  53. cucul_flip(pig);
  54. cucul_flop(pig);
  55. cucul_blit(cv, 0, cucul_get_canvas_height(pig), pig, NULL);
  56. cucul_flop(pig);
  57. cucul_rotate_180(pig);
  58. cucul_blit(cv, cucul_get_canvas_width(pig),
  59. cucul_get_canvas_height(pig), pig, NULL);
  60. for(j = 0; j < cucul_get_canvas_height(cv); j++)
  61. {
  62. for(i = 0; i < cucul_get_canvas_width(cv); i += 2)
  63. {
  64. unsigned long int a;
  65. cucul_set_color_ansi(cv, CUCUL_LIGHTBLUE + (i + j) % 6,
  66. CUCUL_DEFAULT);
  67. a = cucul_get_attr(cv, -1, -1);
  68. cucul_put_attr(cv, i, j, a);
  69. cucul_put_attr(cv, i + 1, j, a);
  70. }
  71. }
  72. buffer = cucul_export_memory(cv, "utf8", &len);
  73. fwrite(buffer, len, 1, stdout);
  74. free(buffer);
  75. cucul_rotate_left(cv);
  76. buffer = cucul_export_memory(cv, "utf8", &len);
  77. fwrite(buffer, len, 1, stdout);
  78. free(buffer);
  79. cucul_free_canvas(pig);
  80. cucul_free_canvas(cv);
  81. return 0;
  82. }