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.
 
 
 
 
 
 

213 rivejä
5.7 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. /**
  79. * The dithering modes to be used with caca_set_dithering().
  80. */
  81. enum caca_dithering
  82. {
  83. CACA_DITHER_NONE,
  84. CACA_DITHER_ORDERED,
  85. CACA_DITHER_RANDOM
  86. };
  87. /**
  88. * The event types returned by caca_get_event().
  89. */
  90. enum caca_event
  91. {
  92. CACA_EVENT_NONE = 0x00000000,
  93. CACA_EVENT_KEY_PRESS = 0x01000000,
  94. CACA_EVENT_KEY_RELEASE = 0x02000000,
  95. CACA_EVENT_MOUSE_CLICK = 0x04000000
  96. };
  97. /**
  98. * The special key values returned by caca_get_event().
  99. */
  100. enum caca_key
  101. {
  102. CACA_KEY_UP = 273,
  103. CACA_KEY_DOWN = 274,
  104. CACA_KEY_LEFT = 275,
  105. CACA_KEY_RIGHT = 276,
  106. CACA_KEY_F1 = 282,
  107. CACA_KEY_F2 = 283,
  108. CACA_KEY_F3 = 284,
  109. CACA_KEY_F4 = 285,
  110. CACA_KEY_F5 = 286,
  111. CACA_KEY_F6 = 287,
  112. CACA_KEY_F7 = 288,
  113. CACA_KEY_F8 = 289,
  114. CACA_KEY_F9 = 290,
  115. CACA_KEY_F10 = 291,
  116. CACA_KEY_F11 = 292,
  117. CACA_KEY_F12 = 293,
  118. CACA_KEY_F13 = 294,
  119. CACA_KEY_F14 = 295,
  120. CACA_KEY_F15 = 296
  121. };
  122. /*
  123. * Basic functions
  124. */
  125. int caca_init(void);
  126. void caca_set_delay(unsigned int);
  127. void caca_set_dithering(enum caca_dithering);
  128. unsigned int caca_get_rendertime(void);
  129. unsigned int caca_get_width(void);
  130. unsigned int caca_get_height(void);
  131. const char *caca_get_color_name(unsigned int);
  132. void caca_refresh(void);
  133. void caca_end(void);
  134. /*
  135. * Events
  136. */
  137. unsigned int caca_get_event(void);
  138. /*
  139. * Character graphics
  140. */
  141. void caca_set_color(enum caca_color);
  142. enum caca_color caca_get_color(void);
  143. void caca_putchar(int, int, char);
  144. void caca_putstr(int, int, const char *);
  145. void caca_printf(int, int, const char *, ...);
  146. void caca_clear(void);
  147. /*
  148. * Graphics primitives
  149. */
  150. void caca_draw_line(int, int, int, int, char);
  151. void caca_draw_polyline(const int[], const int[], int, char);
  152. void caca_draw_thin_line(int, int, int, int);
  153. void caca_draw_thin_polyline(const int[], const int[], int);
  154. void caca_draw_circle(int, int, int, char);
  155. void caca_draw_ellipse(int, int, int, int, char);
  156. void caca_draw_thin_ellipse(int, int, int, int);
  157. void caca_fill_ellipse(int, int, int, int, char);
  158. void caca_draw_box(int, int, int, int, char);
  159. void caca_draw_thin_box(int, int, int, int);
  160. void caca_fill_box(int, int, int, int, char);
  161. void caca_draw_triangle(int, int, int, int, int, int, char);
  162. void caca_draw_thin_triangle(int, int, int, int, int, int);
  163. void caca_fill_triangle(int, int, int, int, int, int, char);
  164. /*
  165. * Maths
  166. */
  167. int caca_rand(int, int);
  168. unsigned int caca_sqrt(unsigned int);
  169. /*
  170. * Sprite handling
  171. */
  172. struct caca_sprite;
  173. struct caca_sprite * caca_load_sprite(const char *);
  174. int caca_get_sprite_frames(struct caca_sprite *);
  175. int caca_get_sprite_width(struct caca_sprite *, int);
  176. int caca_get_sprite_height(struct caca_sprite *, int);
  177. int caca_get_sprite_dx(struct caca_sprite *, int);
  178. int caca_get_sprite_dy(struct caca_sprite *, int);
  179. void caca_draw_sprite(int, int, struct caca_sprite *, int);
  180. void caca_free_sprite(struct caca_sprite *);
  181. /*
  182. * Bitmap handling
  183. */
  184. struct caca_bitmap;
  185. struct caca_bitmap *caca_create_bitmap(int, int, int, int, int, int, int);
  186. void caca_draw_bitmap(int, int, int, int, struct caca_bitmap *, char *);
  187. void caca_free_bitmap(struct caca_bitmap *);
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #endif /* __CACA_H__ */