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.

преди 15 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
преди 18 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * frames canvas frame switching features
  3. * Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
  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 "caca.h"
  19. int main(int argc, char *argv[])
  20. {
  21. caca_canvas_t *cv;
  22. caca_display_t *dp;
  23. int n, frame;
  24. /* Create a canvas with 200 frames */
  25. cv = caca_create_canvas(0, 0);
  26. if(cv == NULL)
  27. {
  28. printf("Can't create canvas\n");
  29. return -1;
  30. }
  31. for(frame = 1; frame < 200; frame++)
  32. caca_create_frame(cv, frame);
  33. fprintf(stderr, "canvas created, size is %ix%i\n",
  34. caca_get_canvas_width(cv), caca_get_canvas_height(cv));
  35. /* Resize it to 150 x 80 (around 19MB) */
  36. caca_set_canvas_size(cv, 150, 80);
  37. fprintf(stderr, "canvas expanded, size is %ix%i\n",
  38. caca_get_canvas_width(cv), caca_get_canvas_height(cv));
  39. /* Fill the first 16 frames with a different colour */
  40. for(frame = 0; frame < 16; frame++)
  41. {
  42. caca_set_frame(cv, frame);
  43. caca_set_color_ansi(cv, CACA_WHITE, frame);
  44. caca_fill_box(cv, 0, 0, 40, 15, ':');
  45. caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE);
  46. caca_put_str(cv, frame * 5 / 2, frame, "カカ");
  47. caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT);
  48. }
  49. /* Resize it to a more decent size */
  50. caca_set_canvas_size(cv, 41, 16);
  51. fprintf(stderr, "canvas shrinked, size is %ix%i\n",
  52. caca_get_canvas_width(cv), caca_get_canvas_height(cv));
  53. dp = caca_create_display(cv);
  54. caca_set_display_time(dp, 50000);
  55. fprintf(stderr, "display attached, size is %ix%i\n",
  56. caca_get_canvas_width(cv), caca_get_canvas_height(cv));
  57. n = 0;
  58. while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
  59. {
  60. caca_set_frame(cv, n % 16);
  61. caca_refresh_display(dp);
  62. n++;
  63. }
  64. caca_free_display(dp);
  65. /* It is possible, though not necessary, to free all additional frames
  66. * separately. */
  67. caca_free_canvas(cv);
  68. return 0;
  69. }