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.

преди 19 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /*
  2. * libcucul Canvas for ultrafast compositing of Unicode letters
  3. * Copyright (c) 2002-2006 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 Do What The Fuck You Want To
  8. * Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. /** \file cucul.h
  12. * \version \$Id$
  13. * \author Sam Hocevar <sam@zoy.org>
  14. * \brief The \e libcucul public header.
  15. *
  16. * This header contains the public types and functions that applications
  17. * using \e libcucul may use.
  18. */
  19. #ifndef __CUCUL_H__
  20. #define __CUCUL_H__
  21. #define CUCUL_API_VERSION_1
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. /** \brief Colour definitions.
  27. *
  28. * Colours that can be used with cucul_set_color().
  29. */
  30. enum cucul_color
  31. {
  32. CUCUL_COLOR_BLACK = 0, /**< The colour index for black. */
  33. CUCUL_COLOR_BLUE = 1, /**< The colour index for blue. */
  34. CUCUL_COLOR_GREEN = 2, /**< The colour index for green. */
  35. CUCUL_COLOR_CYAN = 3, /**< The colour index for cyan. */
  36. CUCUL_COLOR_RED = 4, /**< The colour index for red. */
  37. CUCUL_COLOR_MAGENTA = 5, /**< The colour index for magenta. */
  38. CUCUL_COLOR_BROWN = 6, /**< The colour index for brown. */
  39. CUCUL_COLOR_LIGHTGRAY = 7, /**< The colour index for light gray. */
  40. CUCUL_COLOR_DARKGRAY = 8, /**< The colour index for dark gray. */
  41. CUCUL_COLOR_LIGHTBLUE = 9, /**< The colour index for blue. */
  42. CUCUL_COLOR_LIGHTGREEN = 10, /**< The colour index for light green. */
  43. CUCUL_COLOR_LIGHTCYAN = 11, /**< The colour index for light cyan. */
  44. CUCUL_COLOR_LIGHTRED = 12, /**< The colour index for light red. */
  45. CUCUL_COLOR_LIGHTMAGENTA = 13, /**< The colour index for light magenta. */
  46. CUCUL_COLOR_YELLOW = 14, /**< The colour index for yellow. */
  47. CUCUL_COLOR_WHITE = 15 /**< The colour index for white. */
  48. };
  49. /** \brief Export formats
  50. *
  51. * Export formats understood by libcucul.
  52. */
  53. enum cucul_format
  54. {
  55. CUCUL_FORMAT_ANSI = 0, /**< Export to ANSI format. */
  56. CUCUL_FORMAT_HTML = 1, /**< Export to HTML format. */
  57. CUCUL_FORMAT_HTML3 = 2, /**< Export to old HTMLv3 format. */
  58. CUCUL_FORMAT_IRC = 3, /**< Export to text with mIRC colours. */
  59. CUCUL_FORMAT_PS = 4, /**< Export to PostScript. */
  60. CUCUL_FORMAT_SVG = 5, /**< Export to Scalable Vector Graphics format. */
  61. };
  62. /** \brief Internal features.
  63. *
  64. * Internal libcaca features such as the rendering method or the dithering
  65. * mode.
  66. */
  67. enum cucul_feature
  68. {
  69. CUCUL_BACKGROUND = 0x10, /**< Properties of background characters. */
  70. CUCUL_BACKGROUND_BLACK = 0x11, /**< Draw only black backgrounds. */
  71. CUCUL_BACKGROUND_SOLID = 0x12, /**< Draw coloured solid backgorunds. */
  72. #define CUCUL_BACKGROUND_MIN 0x11 /**< First background property */
  73. #define CUCUL_BACKGROUND_MAX 0x12 /**< Last background property */
  74. CUCUL_ANTIALIASING = 0x20, /**< Antialiasing features. */
  75. CUCUL_ANTIALIASING_NONE = 0x21, /**< No antialiasing. */
  76. CUCUL_ANTIALIASING_PREFILTER = 0x22, /**< Prefilter antialiasing. */
  77. #define CUCUL_ANTIALIASING_MIN 0x21 /**< First antialiasing feature. */
  78. #define CUCUL_ANTIALIASING_MAX 0x22 /**< Last antialiasing feature. */
  79. CUCUL_DITHERING = 0x30, /**< Dithering methods */
  80. CUCUL_DITHERING_NONE = 0x31, /**< No dithering. */
  81. CUCUL_DITHERING_ORDERED2 = 0x32, /**< Ordered 2x2 Bayer dithering. */
  82. CUCUL_DITHERING_ORDERED4 = 0x33, /**< Ordered 4x4 Bayer dithering. */
  83. CUCUL_DITHERING_ORDERED8 = 0x34, /**< Ordered 8x8 Bayer dithering. */
  84. CUCUL_DITHERING_RANDOM = 0x35, /**< Random dithering. */
  85. CUCUL_DITHERING_FSTEIN = 0x36, /**< Floyd-Steinberg dithering. */
  86. #define CUCUL_DITHERING_MIN 0x31 /**< First dithering feature. */
  87. #define CUCUL_DITHERING_MAX 0x36 /**< Last dithering feature. */
  88. CUCUL_FEATURE_UNKNOWN = 0xffff /**< Unknown feature. */
  89. };
  90. /*
  91. * Backwards compatibility macros
  92. */
  93. #if !defined(_DOXYGEN_SKIP_ME)
  94. #define caca_dithering cucul_feature
  95. #define caca_set_dithering caca_set_feature
  96. #define caca_get_dithering_name caca_get_feature_name
  97. #define CACA_DITHER_NONE CUCUL_DITHERING_NONE
  98. #define CACA_DITHER_ORDERED CUCUL_DITHERING_ORDERED8
  99. #define CACA_DITHER_RANDOM CUCUL_DITHERING_RANDOM
  100. #endif
  101. typedef struct cucul_context cucul_t;
  102. /** \defgroup basic Basic functions
  103. *
  104. * These functions provide the basic \e libcaca routines for library
  105. * initialisation, system information retrieval and configuration.
  106. *
  107. * @{ */
  108. cucul_t * cucul_create(unsigned int, unsigned int);
  109. void cucul_set_size(cucul_t *, unsigned int, unsigned int);
  110. unsigned int cucul_get_width(cucul_t *);
  111. unsigned int cucul_get_height(cucul_t *);
  112. enum cucul_feature cucul_get_feature(cucul_t *, enum cucul_feature);
  113. void cucul_set_feature(cucul_t *, enum cucul_feature);
  114. char const *cucul_get_feature_name(enum cucul_feature);
  115. void cucul_free(cucul_t *);
  116. /* @} */
  117. /** \defgroup canvas Canvas drawing
  118. *
  119. * These functions provide low-level character printing routines and
  120. * higher level graphics functions.
  121. *
  122. * @{ */
  123. void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color);
  124. enum cucul_color cucul_get_fg_color(cucul_t const *);
  125. enum cucul_color cucul_get_bg_color(cucul_t const *);
  126. char const *cucul_get_color_name(enum cucul_color);
  127. void cucul_putchar(cucul_t *, int, int, char);
  128. void cucul_putstr(cucul_t *, int, int, char const *);
  129. void cucul_printf(cucul_t *, int, int, char const *, ...);
  130. void cucul_get_screen(cucul_t const *, char *);
  131. void cucul_clear(cucul_t *);
  132. void cucul_blit(cucul_t *, int, int, cucul_t const *, cucul_t const *);
  133. /* @} */
  134. /** \defgroup transform Canvas transformation
  135. *
  136. * These functions perform horizontal and vertical canvas flipping.
  137. *
  138. * @{ */
  139. void cucul_flip(cucul_t *);
  140. void cucul_flop(cucul_t *);
  141. void cucul_rotate(cucul_t *);
  142. /* @} */
  143. /** \defgroup prim Primitives drawing
  144. *
  145. * These functions provide routines for primitive drawing, such as lines,
  146. * boxes, triangles and ellipses.
  147. *
  148. * @{ */
  149. void cucul_draw_line(cucul_t *, int, int, int, int, char const *);
  150. void cucul_draw_polyline(cucul_t *, int const x[], int const y[], int, char const *);
  151. void cucul_draw_thin_line(cucul_t *, int, int, int, int);
  152. void cucul_draw_thin_polyline(cucul_t *, int const x[], int const y[], int);
  153. void cucul_draw_circle(cucul_t *, int, int, int, char const *);
  154. void cucul_draw_ellipse(cucul_t *, int, int, int, int, char const *);
  155. void cucul_draw_thin_ellipse(cucul_t *, int, int, int, int);
  156. void cucul_fill_ellipse(cucul_t *, int, int, int, int, char const *);
  157. void cucul_draw_box(cucul_t *, int, int, int, int, char const *);
  158. void cucul_draw_thin_box(cucul_t *, int, int, int, int);
  159. void cucul_fill_box(cucul_t *, int, int, int, int, char const *);
  160. void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char const *);
  161. void cucul_draw_thin_triangle(cucul_t *, int, int, int, int, int, int);
  162. void cucul_fill_triangle(cucul_t *, int, int, int, int, int, int, char const *);
  163. /* @} */
  164. /** \defgroup math Mathematical functions
  165. *
  166. * These functions provide a few useful math-related routines.
  167. *
  168. * @{ */
  169. int cucul_rand(int, int);
  170. unsigned int cucul_sqrt(unsigned int);
  171. /* @} */
  172. /** \defgroup sprite Sprite handling
  173. *
  174. * These functions provide high level routines for sprite loading, animation
  175. * and rendering.
  176. *
  177. * @{ */
  178. struct cucul_sprite;
  179. struct cucul_sprite * cucul_load_sprite(cucul_t *, char const *);
  180. int cucul_get_sprite_frames(cucul_t *, struct cucul_sprite const *);
  181. int cucul_get_sprite_width(cucul_t *, struct cucul_sprite const *, int);
  182. int cucul_get_sprite_height(cucul_t *, struct cucul_sprite const *, int);
  183. int cucul_get_sprite_dx(cucul_t *, struct cucul_sprite const *, int);
  184. int cucul_get_sprite_dy(cucul_t *, struct cucul_sprite const *, int);
  185. void cucul_draw_sprite(cucul_t *, int, int, struct cucul_sprite const *, int);
  186. void cucul_free_sprite(struct cucul_sprite *);
  187. /* @} */
  188. /** \defgroup bitmap Bitmap handling
  189. *
  190. * These functions provide high level routines for bitmap allocation and
  191. * rendering.
  192. *
  193. * @{ */
  194. struct cucul_bitmap;
  195. struct cucul_bitmap *cucul_create_bitmap(unsigned int, unsigned int,
  196. unsigned int, unsigned int,
  197. unsigned int, unsigned int,
  198. unsigned int, unsigned int);
  199. void cucul_set_bitmap_palette(struct cucul_bitmap *,
  200. unsigned int r[], unsigned int g[],
  201. unsigned int b[], unsigned int a[]);
  202. void cucul_set_bitmap_gamma(struct cucul_bitmap *, float);
  203. void cucul_draw_bitmap(cucul_t *, int, int, int, int, struct cucul_bitmap const *, void *);
  204. void cucul_free_bitmap(struct cucul_bitmap *);
  205. /* @} */
  206. /** \defgroup exporter Exporters to various formats
  207. *
  208. * These functions export the current canvas to various text formats. It
  209. * is necessary to call cucul_free_export() to dispose of the data.
  210. *
  211. * @{ */
  212. struct cucul_export
  213. {
  214. unsigned int size;
  215. char *buffer;
  216. };
  217. struct cucul_export * cucul_create_export(cucul_t *, enum cucul_format);
  218. void cucul_free_export(struct cucul_export *);
  219. /* @} */
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223. #endif /* __CUCUL_H__ */