您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

65 行
1.4 KiB

  1. /*
  2. * truecolor truecolor canvas features
  3. * Copyright (c) 2006-2012 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * This program is free software. It comes without any warranty, to
  7. * the extent permitted by applicable law. You can redistribute it
  8. * and/or modify it under the terms of the Do What the Fuck You Want
  9. * to Public License, Version 2, as published by Sam Hocevar. See
  10. * http://www.wtfpl.net/ for more details.
  11. */
  12. #include "config.h"
  13. #if !defined(__KERNEL__)
  14. # include <stdio.h>
  15. #endif
  16. #include "caca.h"
  17. int main(int argc, char *argv[])
  18. {
  19. caca_canvas_t *cv;
  20. caca_display_t *dp;
  21. int x, y;
  22. cv = caca_create_canvas(32, 16);
  23. if(cv == NULL)
  24. {
  25. printf("Failed to create canvas\n");
  26. return 1;
  27. }
  28. dp = caca_create_display(cv);
  29. if(dp == NULL)
  30. {
  31. printf("Failed to create display\n");
  32. return 1;
  33. }
  34. for(y = 0; y < 16; y++)
  35. for(x = 0; x < 16; x++)
  36. {
  37. uint16_t bgcolor = 0xff00 | (y << 4) | x;
  38. uint16_t fgcolor = 0xf000 | ((15 - y) << 4) | ((15 - x) << 8);
  39. caca_set_color_argb(cv, fgcolor, bgcolor);
  40. caca_put_str(cv, x * 2, y, "CA");
  41. }
  42. caca_set_color_ansi(cv, CACA_WHITE, CACA_LIGHTBLUE);
  43. caca_put_str(cv, 2, 1, " truecolor libcaca ");
  44. caca_refresh_display(dp);
  45. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  46. caca_free_display(dp);
  47. caca_free_canvas(cv);
  48. return 0;
  49. }