Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

226 строки
6.2 KiB

  1. /*
  2. * libcaca ASCII-Art library
  3. * Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19. * 02111-1307 USA
  20. */
  21. /** \file caca.h
  22. * \version \$Id$
  23. * \author Sam Hocevar <sam@zoy.org>
  24. * \brief The \e libcaca public header.
  25. *
  26. * This header contains the public types and functions that applications
  27. * using \e libcaca may use.
  28. */
  29. /** \mainpage libcaca developer documentation
  30. *
  31. * \section intro Introduction
  32. *
  33. * \e libcaca is a graphics library that outputs text instead of pixels,
  34. * so that it can work on older video cards or text terminals. It is not
  35. * unlike the famous AAlib library. libcaca needs a terminal to work,
  36. * thus it should work on all Unix systems (including Mac OS X) using
  37. * either the slang library or the ncurses library, on DOS using the conio
  38. * library, and on Windows systems using either slang or ncurses (through
  39. * Cygwin emulation) or conio.
  40. *
  41. * \e libcaca is free software, released under the GNU Lesser General
  42. * Public License. This ensures that \e libcaca will always remain free
  43. * software.
  44. *
  45. * \section api The libcaca API
  46. *
  47. * The complete \e libcaca programming interface is available from the
  48. * caca.h file.
  49. */
  50. #ifndef __CACA_H__
  51. #define __CACA_H__
  52. #ifdef __cplusplus
  53. extern "C"
  54. {
  55. #endif
  56. /**
  57. * The colour definitions to be used with caca_set_color().
  58. */
  59. enum caca_color
  60. {
  61. CACA_COLOR_BLACK = 0,
  62. CACA_COLOR_BLUE = 1,
  63. CACA_COLOR_GREEN = 2,
  64. CACA_COLOR_CYAN = 3,
  65. CACA_COLOR_RED = 4,
  66. CACA_COLOR_MAGENTA = 5,
  67. CACA_COLOR_BROWN = 6,
  68. CACA_COLOR_LIGHTGRAY = 7,
  69. CACA_COLOR_DARKGRAY = 8,
  70. CACA_COLOR_LIGHTBLUE = 9,
  71. CACA_COLOR_LIGHTGREEN = 10,
  72. CACA_COLOR_LIGHTCYAN = 11,
  73. CACA_COLOR_LIGHTRED = 12,
  74. CACA_COLOR_LIGHTMAGENTA = 13,
  75. CACA_COLOR_YELLOW = 14,
  76. CACA_COLOR_WHITE = 15
  77. };
  78. const char *caca_get_color_name(enum caca_color);
  79. /**
  80. * The dithering modes to be used with caca_set_dithering().
  81. */
  82. enum caca_dithering
  83. {
  84. CACA_DITHERING_NONE = 0,
  85. CACA_DITHERING_ORDERED2 = 1,
  86. CACA_DITHERING_ORDERED4 = 2,
  87. CACA_DITHERING_ORDERED8 = 3,
  88. CACA_DITHERING_RANDOM = 4
  89. };
  90. const char *caca_get_dithering_name(enum caca_dithering);
  91. /* Backwards compatibility */
  92. #define CACA_DITHER_NONE CACA_DITHERING_NONE
  93. #define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
  94. #define CACA_DITHER_RANDOM CACA_DITHERING_RANDOM
  95. /**
  96. * The event types returned by caca_get_event().
  97. */
  98. enum caca_event
  99. {
  100. CACA_EVENT_NONE = 0x00000000,
  101. CACA_EVENT_KEY_PRESS = 0x01000000,
  102. CACA_EVENT_KEY_RELEASE = 0x02000000,
  103. CACA_EVENT_MOUSE_CLICK = 0x04000000
  104. };
  105. /**
  106. * The special key values returned by caca_get_event().
  107. */
  108. enum caca_key
  109. {
  110. CACA_KEY_UP = 273,
  111. CACA_KEY_DOWN = 274,
  112. CACA_KEY_LEFT = 275,
  113. CACA_KEY_RIGHT = 276,
  114. CACA_KEY_F1 = 282,
  115. CACA_KEY_F2 = 283,
  116. CACA_KEY_F3 = 284,
  117. CACA_KEY_F4 = 285,
  118. CACA_KEY_F5 = 286,
  119. CACA_KEY_F6 = 287,
  120. CACA_KEY_F7 = 288,
  121. CACA_KEY_F8 = 289,
  122. CACA_KEY_F9 = 290,
  123. CACA_KEY_F10 = 291,
  124. CACA_KEY_F11 = 292,
  125. CACA_KEY_F12 = 293,
  126. CACA_KEY_F13 = 294,
  127. CACA_KEY_F14 = 295,
  128. CACA_KEY_F15 = 296
  129. };
  130. /*
  131. * Basic functions
  132. */
  133. int caca_init(void);
  134. void caca_set_delay(unsigned int);
  135. void caca_set_dithering(enum caca_dithering);
  136. unsigned int caca_get_rendertime(void);
  137. unsigned int caca_get_width(void);
  138. unsigned int caca_get_height(void);
  139. void caca_refresh(void);
  140. void caca_end(void);
  141. /*
  142. * Events
  143. */
  144. unsigned int caca_get_event(void);
  145. /*
  146. * Character graphics
  147. */
  148. void caca_set_color(enum caca_color, enum caca_color);
  149. enum caca_color caca_get_fg_color(void);
  150. enum caca_color caca_get_bg_color(void);
  151. void caca_putchar(int, int, char);
  152. void caca_putstr(int, int, const char *);
  153. void caca_printf(int, int, const char *, ...);
  154. void caca_clear(void);
  155. /*
  156. * Graphics primitives
  157. */
  158. void caca_draw_line(int, int, int, int, char);
  159. void caca_draw_polyline(const int[], const int[], int, char);
  160. void caca_draw_thin_line(int, int, int, int);
  161. void caca_draw_thin_polyline(const int[], const int[], int);
  162. void caca_draw_circle(int, int, int, char);
  163. void caca_draw_ellipse(int, int, int, int, char);
  164. void caca_draw_thin_ellipse(int, int, int, int);
  165. void caca_fill_ellipse(int, int, int, int, char);
  166. void caca_draw_box(int, int, int, int, char);
  167. void caca_draw_thin_box(int, int, int, int);
  168. void caca_fill_box(int, int, int, int, char);
  169. void caca_draw_triangle(int, int, int, int, int, int, char);
  170. void caca_draw_thin_triangle(int, int, int, int, int, int);
  171. void caca_fill_triangle(int, int, int, int, int, int, char);
  172. /*
  173. * Maths
  174. */
  175. int caca_rand(int, int);
  176. unsigned int caca_sqrt(unsigned int);
  177. /*
  178. * Sprite handling
  179. */
  180. struct caca_sprite;
  181. struct caca_sprite * caca_load_sprite(const char *);
  182. int caca_get_sprite_frames(const struct caca_sprite *);
  183. int caca_get_sprite_width(const struct caca_sprite *, int);
  184. int caca_get_sprite_height(const struct caca_sprite *, int);
  185. int caca_get_sprite_dx(const struct caca_sprite *, int);
  186. int caca_get_sprite_dy(const struct caca_sprite *, int);
  187. void caca_draw_sprite(int, int, const struct caca_sprite *, int);
  188. void caca_free_sprite(struct caca_sprite *);
  189. /*
  190. * Bitmap handling
  191. */
  192. struct caca_bitmap;
  193. struct caca_bitmap *caca_create_bitmap(int, int, int, int, int, int, int, int);
  194. void caca_set_bitmap_palette(struct caca_bitmap *, unsigned int[],
  195. unsigned int[], unsigned int[], unsigned int[]);
  196. void caca_draw_bitmap(int, int, int, int, const struct caca_bitmap *, char *);
  197. void caca_free_bitmap(struct caca_bitmap *);
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201. #endif /* __CACA_H__ */