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.
 
 
 
 
 
 

91 linhas
2.4 KiB

  1. /*
  2. * frames canvas frame switching features
  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. #endif
  18. #include "cucul.h"
  19. #include "caca.h"
  20. int main(int argc, char *argv[])
  21. {
  22. cucul_canvas_t *cv;
  23. caca_display_t *dp;
  24. int n, frame;
  25. /* Create a canvas with 200 frames */
  26. cv = cucul_create_canvas(0, 0);
  27. if(cv == NULL)
  28. {
  29. printf("Can't create canvas\n");
  30. return -1;
  31. }
  32. for(frame = 1; frame < 200; frame++)
  33. cucul_create_frame(cv, frame);
  34. fprintf(stderr, "canvas created, size is %ix%i\n",
  35. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  36. /* Resize it to 150 x 80 (around 19MB) */
  37. cucul_set_canvas_size(cv, 150, 80);
  38. fprintf(stderr, "canvas expanded, size is %ix%i\n",
  39. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  40. /* Fill the first 16 frames with a different colour */
  41. for(frame = 0; frame < 16; frame++)
  42. {
  43. cucul_set_frame(cv, frame);
  44. cucul_set_color_ansi(cv, CUCUL_WHITE, frame);
  45. cucul_fill_box(cv, 0, 0, 40, 15, ':');
  46. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  47. cucul_put_str(cv, frame * 5 / 2, frame, "カカ");
  48. cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
  49. }
  50. /* Resize it to a more decent size */
  51. cucul_set_canvas_size(cv, 41, 16);
  52. fprintf(stderr, "canvas shrinked, size is %ix%i\n",
  53. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  54. dp = caca_create_display(cv);
  55. caca_set_display_time(dp, 50000);
  56. fprintf(stderr, "display attached, size is %ix%i\n",
  57. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  58. n = 0;
  59. while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
  60. {
  61. cucul_set_frame(cv, n % 16);
  62. caca_refresh_display(dp);
  63. n++;
  64. }
  65. caca_free_display(dp);
  66. /* It is possible, though not necessary, to free all additional frames
  67. * separately. */
  68. cucul_free_canvas(cv);
  69. return 0;
  70. }