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.

cucul.h 7.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 = 0x0, /**< The colour index for black. */
  33. CUCUL_COLOR_BLUE = 0x1, /**< The colour index for blue. */
  34. CUCUL_COLOR_GREEN = 0x2, /**< The colour index for green. */
  35. CUCUL_COLOR_CYAN = 0x3, /**< The colour index for cyan. */
  36. CUCUL_COLOR_RED = 0x4, /**< The colour index for red. */
  37. CUCUL_COLOR_MAGENTA = 0x5, /**< The colour index for magenta. */
  38. CUCUL_COLOR_BROWN = 0x6, /**< The colour index for brown. */
  39. CUCUL_COLOR_LIGHTGRAY = 0x7, /**< The colour index for light gray. */
  40. CUCUL_COLOR_DARKGRAY = 0x8, /**< The colour index for dark gray. */
  41. CUCUL_COLOR_LIGHTBLUE = 0x9, /**< The colour index for blue. */
  42. CUCUL_COLOR_LIGHTGREEN = 0xa, /**< The colour index for light green. */
  43. CUCUL_COLOR_LIGHTCYAN = 0xb, /**< The colour index for light cyan. */
  44. CUCUL_COLOR_LIGHTRED = 0xc, /**< The colour index for light red. */
  45. CUCUL_COLOR_LIGHTMAGENTA = 0xd, /**< The colour index for light magenta. */
  46. CUCUL_COLOR_YELLOW = 0xe, /**< The colour index for yellow. */
  47. CUCUL_COLOR_WHITE = 0xf, /**< The colour index for white. */
  48. CUCUL_COLOR_TRANSPARENT = 0xfe, /**< The transparent colour. */
  49. CUCUL_COLOR_DEFAULT = 0xff, /**< The output driver's default colour. */
  50. };
  51. typedef struct cucul_context cucul_t;
  52. /** \defgroup basic Basic functions
  53. *
  54. * These functions provide the basic \e libcaca routines for library
  55. * initialisation, system information retrieval and configuration.
  56. *
  57. * @{ */
  58. cucul_t * cucul_create(unsigned int, unsigned int);
  59. cucul_t * cucul_load(void *, unsigned int);
  60. void cucul_set_size(cucul_t *, unsigned int, unsigned int);
  61. unsigned int cucul_get_width(cucul_t *);
  62. unsigned int cucul_get_height(cucul_t *);
  63. void cucul_free(cucul_t *);
  64. /* @} */
  65. /** \defgroup canvas Canvas drawing
  66. *
  67. * These functions provide low-level character printing routines and
  68. * higher level graphics functions.
  69. *
  70. * @{ */
  71. void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color);
  72. char const *cucul_get_color_name(enum cucul_color);
  73. void cucul_putchar(cucul_t *, int, int, char);
  74. void cucul_putstr(cucul_t *, int, int, char const *);
  75. void cucul_printf(cucul_t *, int, int, char const *, ...);
  76. void cucul_clear(cucul_t *);
  77. void cucul_blit(cucul_t *, int, int, cucul_t const *, cucul_t const *);
  78. /* @} */
  79. /** \defgroup transform Canvas transformation
  80. *
  81. * These functions perform horizontal and vertical canvas flipping.
  82. *
  83. * @{ */
  84. void cucul_invert(cucul_t *);
  85. void cucul_flip(cucul_t *);
  86. void cucul_flop(cucul_t *);
  87. void cucul_rotate(cucul_t *);
  88. /* @} */
  89. /** \defgroup prim Primitives drawing
  90. *
  91. * These functions provide routines for primitive drawing, such as lines,
  92. * boxes, triangles and ellipses.
  93. *
  94. * @{ */
  95. void cucul_draw_line(cucul_t *, int, int, int, int, char const *);
  96. void cucul_draw_polyline(cucul_t *, int const x[], int const y[], int, char const *);
  97. void cucul_draw_thin_line(cucul_t *, int, int, int, int);
  98. void cucul_draw_thin_polyline(cucul_t *, int const x[], int const y[], int);
  99. void cucul_draw_circle(cucul_t *, int, int, int, char const *);
  100. void cucul_draw_ellipse(cucul_t *, int, int, int, int, char const *);
  101. void cucul_draw_thin_ellipse(cucul_t *, int, int, int, int);
  102. void cucul_fill_ellipse(cucul_t *, int, int, int, int, char const *);
  103. void cucul_draw_box(cucul_t *, int, int, int, int, char const *);
  104. void cucul_draw_thin_box(cucul_t *, int, int, int, int);
  105. void cucul_fill_box(cucul_t *, int, int, int, int, char const *);
  106. void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char const *);
  107. void cucul_draw_thin_triangle(cucul_t *, int, int, int, int, int, int);
  108. void cucul_fill_triangle(cucul_t *, int, int, int, int, int, int, char const *);
  109. /* @} */
  110. /** \defgroup math Mathematical functions
  111. *
  112. * These functions provide a few useful math-related routines.
  113. *
  114. * @{ */
  115. int cucul_rand(int, int);
  116. unsigned int cucul_sqrt(unsigned int);
  117. /* @} */
  118. /** \defgroup sprite Sprite handling
  119. *
  120. * These functions provide high level routines for sprite loading, animation
  121. * and rendering.
  122. *
  123. * @{ */
  124. struct cucul_sprite;
  125. struct cucul_sprite * cucul_load_sprite(cucul_t *, char const *);
  126. int cucul_get_sprite_frames(cucul_t *, struct cucul_sprite const *);
  127. int cucul_get_sprite_width(cucul_t *, struct cucul_sprite const *, int);
  128. int cucul_get_sprite_height(cucul_t *, struct cucul_sprite const *, int);
  129. int cucul_get_sprite_dx(cucul_t *, struct cucul_sprite const *, int);
  130. int cucul_get_sprite_dy(cucul_t *, struct cucul_sprite const *, int);
  131. void cucul_draw_sprite(cucul_t *, int, int, struct cucul_sprite const *, int);
  132. void cucul_free_sprite(struct cucul_sprite *);
  133. /* @} */
  134. /** \defgroup bitmap Bitmap handling
  135. *
  136. * These functions provide high level routines for bitmap allocation and
  137. * rendering.
  138. *
  139. * @{ */
  140. struct cucul_bitmap;
  141. struct cucul_bitmap *cucul_create_bitmap(unsigned int, unsigned int,
  142. unsigned int, unsigned int,
  143. unsigned int, unsigned int,
  144. unsigned int, unsigned int);
  145. void cucul_set_bitmap_palette(struct cucul_bitmap *,
  146. unsigned int r[], unsigned int g[],
  147. unsigned int b[], unsigned int a[]);
  148. void cucul_set_bitmap_brightness(struct cucul_bitmap *, float);
  149. void cucul_set_bitmap_gamma(struct cucul_bitmap *, float);
  150. void cucul_set_bitmap_contrast(struct cucul_bitmap *, float);
  151. void cucul_set_bitmap_invert(struct cucul_bitmap *, int);
  152. void cucul_set_bitmap_antialias(struct cucul_bitmap *, char const *);
  153. char const * const * cucul_get_bitmap_antialias_list(struct cucul_bitmap const *);
  154. void cucul_set_bitmap_color(struct cucul_bitmap *, char const *);
  155. char const * const * cucul_get_bitmap_color_list(struct cucul_bitmap const *);
  156. void cucul_set_bitmap_charset(struct cucul_bitmap *, char const *);
  157. char const * const * cucul_get_bitmap_charset_list(struct cucul_bitmap
  158. const *);
  159. void cucul_set_bitmap_dithering(struct cucul_bitmap *, char const *);
  160. char const * const * cucul_get_bitmap_dithering_list(struct cucul_bitmap
  161. const *);
  162. void cucul_draw_bitmap(cucul_t *, int, int, int, int,
  163. struct cucul_bitmap const *, void *);
  164. void cucul_free_bitmap(struct cucul_bitmap *);
  165. /* @} */
  166. /** \defgroup exporter Exporters to various formats
  167. *
  168. * These functions export the current canvas to various text formats. It
  169. * is necessary to call cucul_free_export() to dispose of the data.
  170. *
  171. * @{ */
  172. struct cucul_export
  173. {
  174. unsigned int size;
  175. char *buffer;
  176. };
  177. struct cucul_export * cucul_create_export(cucul_t *, char const *);
  178. char const * const * cucul_get_export_list(void);
  179. void cucul_free_export(struct cucul_export *);
  180. /* @} */
  181. #ifdef __cplusplus
  182. }
  183. #endif
  184. #endif /* __CUCUL_H__ */