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.

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