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 2.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. fprintf(stderr, "canvas created, size is %ix%i\n",
  33. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  34. /* Resize it to 150 x 80 (around 19MB) */
  35. cucul_set_canvas_size(cv, 150, 80);
  36. fprintf(stderr, "canvas expanded, size is %ix%i\n",
  37. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  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_ansi(cv, CUCUL_WHITE, frame);
  43. cucul_fill_box(cv, 0, 0, 40, 15, ':');
  44. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);
  45. cucul_put_str(cv, frame * 5 / 2, frame, "カカ");
  46. cucul_set_color_ansi(cv, CUCUL_DEFAULT, CUCUL_TRANSPARENT);
  47. }
  48. /* Resize it to a more decent size */
  49. cucul_set_canvas_size(cv, 41, 16);
  50. fprintf(stderr, "canvas shrinked, size is %ix%i\n",
  51. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  52. dp = caca_create_display(cv);
  53. caca_set_display_time(dp, 50000);
  54. fprintf(stderr, "display attached, size is %ix%i\n",
  55. cucul_get_canvas_width(cv), cucul_get_canvas_height(cv));
  56. n = 0;
  57. while(!caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 0))
  58. {
  59. cucul_set_canvas_frame(cv, n % 16);
  60. caca_refresh_display(dp);
  61. n++;
  62. }
  63. caca_free_display(dp);
  64. /* It is possible, though not necessary, to free all additional frames
  65. * separately. */
  66. cucul_free_canvas(cv);
  67. return 0;
  68. }