Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

80 lignes
2.0 KiB

  1. /*
  2. * gamma libcucul gamma test program
  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. uint32_t buffer[256];
  24. int main(void)
  25. {
  26. cucul_t *qq;
  27. caca_t *kk;
  28. struct cucul_bitmap *left, *right;
  29. int x;
  30. qq = cucul_init();
  31. kk = caca_attach(qq);
  32. for(x = 0; x < 256; x++)
  33. buffer[x] = (x << 16) | (x << 8) | (x<< 0);
  34. left = cucul_create_bitmap(qq, 32, 256, 1, 4 * 256,
  35. 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
  36. right = cucul_create_bitmap(qq, 32, 256, 1, 4 * 256,
  37. 0x00ff0000, 0x0000ff00, 0x000000ff, 0x0);
  38. caca_set_delay(kk, 20000);
  39. for(x = 0; ; x = (x + 1) % 256)
  40. {
  41. float g = (x > 128) ? (256.0 + 8.0 - x) / 64.0 : (8.0 + x) / 64.0;
  42. if(caca_get_event(kk, CACA_EVENT_KEY_PRESS))
  43. break;
  44. cucul_draw_bitmap(qq, 0, cucul_get_height(qq) / 2,
  45. cucul_get_width(qq) - 1, cucul_get_height(qq) - 1,
  46. left, buffer);
  47. cucul_set_bitmap_gamma(right, g);
  48. cucul_draw_bitmap(qq, 0, 0,
  49. cucul_get_width(qq) - 1, cucul_get_height(qq) / 2 - 1,
  50. right, buffer);
  51. cucul_set_color(qq, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE);
  52. cucul_printf(qq, 1, 2, "gamma %g", g);
  53. caca_display(kk);
  54. }
  55. cucul_free_bitmap(left);
  56. cucul_free_bitmap(right);
  57. caca_detach(kk);
  58. cucul_end(qq);
  59. return 0;
  60. }