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.
 
 
 
 
 
 

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