No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

frames.c 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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; 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(HAVE_INTTYPES_H)
  16. # include <inttypes.h>
  17. #endif
  18. #include <stdio.h>
  19. #include "cucul.h"
  20. #include "caca.h"
  21. int main(void)
  22. {
  23. cucul_canvas_t *cv;
  24. caca_display_t *dp;
  25. int n, frame;
  26. /* Create a canvas with 200 frames */
  27. cv = cucul_create_canvas(0, 0);
  28. for(frame = 1; frame < 200; frame++)
  29. cucul_create_canvas_frame(cv, frame);
  30. /* Resize it to 150 x 80 (around 19MB) */
  31. cucul_set_canvas_size(cv, 150, 80);
  32. /* Resize it to a more decent size */
  33. cucul_set_canvas_size(cv, 41, 16);
  34. dp = caca_create_display(cv);
  35. caca_set_delay(dp, 50000);
  36. /* Fill the first 16 frames with a different colour */
  37. for(frame = 0; frame < 16; frame++)
  38. {
  39. cucul_set_canvas_frame(cv, frame);
  40. cucul_set_color(cv, CUCUL_COLOR_WHITE, frame);
  41. cucul_clear_canvas(cv);
  42. cucul_set_color(cv, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
  43. cucul_putstr(cv, frame * 5 / 2, frame, "CACA");
  44. }
  45. n = 0;
  46. while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
  47. {
  48. cucul_set_canvas_frame(cv, n % 16);
  49. caca_refresh_display(dp);
  50. n++;
  51. }
  52. caca_free_display(dp);
  53. /* It is possible, though not necessary, to free all additional frames
  54. * separately. */
  55. cucul_free_canvas(cv);
  56. return 0;
  57. }