Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

237 řádky
8.7 KiB

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