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.
 
 
 
 
 
 

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