source: libcaca/trunk/cucul/cucul.h @ 561

Last change on this file since 561 was 561, checked in by Jean-Yves Lamoureux, 15 years ago
  • Updated documentation a bit
  • Property svn:keywords set to Id
File size: 8.2 KB
Line 
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
12/** \file cucul.h
13 *  \version \$Id: cucul.h 561 2006-03-09 09:52:24Z jylam $
14 *  \author Sam Hocevar <sam@zoy.org>
15 *  \brief The \e libcucul public header.
16 *
17 *  This header contains the public types and functions that applications
18 *  using \e libcucul may use.
19 */
20
21#ifndef __CUCUL_H__
22#define __CUCUL_H__
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif
28
29/** \brief Colour definitions.
30 *
31 *  Colours that can be used with caca_set_color().
32 */
33enum cucul_color
34{
35    CUCUL_COLOR_BLACK = 0, /**< The colour index for black. */
36    CUCUL_COLOR_BLUE = 1, /**< The colour index for blue. */
37    CUCUL_COLOR_GREEN = 2, /**< The colour index for green. */
38    CUCUL_COLOR_CYAN = 3, /**< The colour index for cyan. */
39    CUCUL_COLOR_RED = 4, /**< The colour index for red. */
40    CUCUL_COLOR_MAGENTA = 5, /**< The colour index for magenta. */
41    CUCUL_COLOR_BROWN = 6, /**< The colour index for brown. */
42    CUCUL_COLOR_LIGHTGRAY = 7, /**< The colour index for light gray. */
43    CUCUL_COLOR_DARKGRAY = 8, /**< The colour index for dark gray. */
44    CUCUL_COLOR_LIGHTBLUE = 9, /**< The colour index for blue. */
45    CUCUL_COLOR_LIGHTGREEN = 10, /**< The colour index for light green. */
46    CUCUL_COLOR_LIGHTCYAN = 11, /**< The colour index for light cyan. */
47    CUCUL_COLOR_LIGHTRED = 12, /**< The colour index for light red. */
48    CUCUL_COLOR_LIGHTMAGENTA = 13, /**< The colour index for light magenta. */
49    CUCUL_COLOR_YELLOW = 14, /**< The colour index for yellow. */
50    CUCUL_COLOR_WHITE = 15 /**< The colour index for white. */
51};
52
53/** \brief Internal features.
54 *
55 *  Internal libcaca features such as the rendering method or the dithering
56 *  mode.
57 */
58enum cucul_feature
59{
60    CUCUL_BACKGROUND       = 0x10, /**< Properties of background characters. */
61    CUCUL_BACKGROUND_BLACK = 0x11, /**< Draw only black backgrounds. */
62    CUCUL_BACKGROUND_SOLID = 0x12, /**< Draw coloured solid backgorunds. */
63#define CUCUL_BACKGROUND_MIN 0x11 /**< First background property */
64#define CUCUL_BACKGROUND_MAX 0x12 /**< Last background property */
65
66    CUCUL_ANTIALIASING           = 0x20, /**< Antialiasing features. */
67    CUCUL_ANTIALIASING_NONE      = 0x21, /**< No antialiasing. */
68    CUCUL_ANTIALIASING_PREFILTER = 0x22, /**< Prefilter antialiasing. */
69#define CUCUL_ANTIALIASING_MIN     0x21 /**< First antialiasing feature. */
70#define CUCUL_ANTIALIASING_MAX     0x22 /**< Last antialiasing feature. */
71
72    CUCUL_DITHERING          = 0x30, /**< Dithering methods */
73    CUCUL_DITHERING_NONE     = 0x31, /**< No dithering. */
74    CUCUL_DITHERING_ORDERED2 = 0x32, /**< Ordered 2x2 Bayer dithering. */
75    CUCUL_DITHERING_ORDERED4 = 0x33, /**< Ordered 4x4 Bayer dithering. */
76    CUCUL_DITHERING_ORDERED8 = 0x34, /**< Ordered 8x8 Bayer dithering. */
77    CUCUL_DITHERING_RANDOM   = 0x35, /**< Random dithering. */
78    CUCUL_DITHERING_FSTEIN   = 0x36, /**< Floyd-Steinberg dithering. */
79#define CUCUL_DITHERING_MIN    0x31 /**< First dithering feature. */
80#define CUCUL_DITHERING_MAX    0x36 /**< Last dithering feature. */
81
82    CUCUL_FEATURE_UNKNOWN = 0xffff /**< Unknown feature. */
83};
84
85/*
86 * Backwards compatibility macros
87 */
88#if !defined(_DOXYGEN_SKIP_ME)
89#define caca_dithering cucul_feature
90#define caca_set_dithering caca_set_feature
91#define caca_get_dithering_name caca_get_feature_name
92#define CACA_DITHER_NONE    CUCUL_DITHERING_NONE
93#define CACA_DITHER_ORDERED CUCUL_DITHERING_ORDERED8
94#define CACA_DITHER_RANDOM  CUCUL_DITHERING_RANDOM
95#endif
96
97typedef struct cucul_context cucul_t;
98
99/** \defgroup basic Basic functions
100 *
101 *  These functions provide the basic \e libcaca routines for library
102 *  initialisation, system information retrieval and configuration.
103 *
104 *  @{ */
105cucul_t * cucul_init(void);
106void cucul_set_size(cucul_t *, unsigned int, unsigned int);
107unsigned int cucul_get_width(cucul_t *);
108unsigned int cucul_get_height(cucul_t *);
109enum cucul_feature cucul_get_feature(cucul_t *, enum cucul_feature);
110void cucul_set_feature(cucul_t *, enum cucul_feature);
111char const *cucul_get_feature_name(enum cucul_feature);
112void cucul_end(cucul_t *);
113/*  @} */
114
115/** \defgroup char Character printing
116 *
117 *  These functions provide low-level character printing routines.
118 *
119 *  @{ */
120void cucul_set_color(cucul_t *, enum cucul_color, enum cucul_color);
121enum cucul_color cucul_get_fg_color(cucul_t *);
122enum cucul_color cucul_get_bg_color(cucul_t *);
123char const *cucul_get_color_name(enum cucul_color);
124void cucul_putchar(cucul_t *, int, int, char);
125void cucul_putstr(cucul_t *, int, int, char const *);
126void cucul_printf(cucul_t *, int, int, char const *, ...);
127void cucul_get_screen(cucul_t *, char *);
128void cucul_clear(cucul_t *);
129/*  @} */
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 *  @{ */
137void cucul_draw_line(cucul_t *, int, int, int, int, char);
138void cucul_draw_polyline(cucul_t *, int const x[], int const y[], int, char);
139void cucul_draw_thin_line(cucul_t *, int, int, int, int);
140void cucul_draw_thin_polyline(cucul_t *, int const x[], int const y[], int);
141
142void cucul_draw_circle(cucul_t *, int, int, int, char);
143void cucul_draw_ellipse(cucul_t *, int, int, int, int, char);
144void cucul_draw_thin_ellipse(cucul_t *, int, int, int, int);
145void cucul_fill_ellipse(cucul_t *, int, int, int, int, char);
146
147void cucul_draw_box(cucul_t *, int, int, int, int, char);
148void cucul_draw_thin_box(cucul_t *, int, int, int, int);
149void cucul_fill_box(cucul_t *, int, int, int, int, char);
150
151void cucul_draw_triangle(cucul_t *, int, int, int, int, int, int, char);
152void cucul_draw_thin_triangle(cucul_t *, int, int, int, int, int, int);
153void cucul_fill_triangle(cucul_t *, int, int, int, int, int, int, char);
154/*  @} */
155
156/** \defgroup math Mathematical functions
157 *
158 *  These functions provide a few useful math-related routines.
159 *
160 *  @{ */
161int cucul_rand(int, int);
162unsigned int cucul_sqrt(unsigned int);
163float cucul_powf(float x, float y);
164/*  @} */
165
166/** \defgroup sprite Sprite handling
167 *
168 *  These functions provide high level routines for sprite loading, animation
169 *  and rendering.
170 *
171 *  @{ */
172struct cucul_sprite;
173struct cucul_sprite * cucul_load_sprite(cucul_t *, char const *);
174int cucul_get_sprite_frames(cucul_t *, struct cucul_sprite const *);
175int cucul_get_sprite_width(cucul_t *, struct cucul_sprite const *, int);
176int cucul_get_sprite_height(cucul_t *, struct cucul_sprite const *, int);
177int cucul_get_sprite_dx(cucul_t *, struct cucul_sprite const *, int);
178int cucul_get_sprite_dy(cucul_t *, struct cucul_sprite const *, int);
179void cucul_draw_sprite(cucul_t *, int, int, struct cucul_sprite const *, int);void cucul_free_sprite(cucul_t *, struct cucul_sprite *);
180/*  @} */
181
182/** \defgroup bitmap Bitmap handling
183 *
184 *  These functions provide high level routines for bitmap allocation and
185 *  rendering.
186 *
187 *  @{ */
188struct cucul_bitmap;
189struct cucul_bitmap *cucul_create_bitmap(cucul_t *, unsigned int, unsigned int,
190                                       unsigned int, unsigned int,
191                                       unsigned int, unsigned int,
192                                       unsigned int, unsigned int);
193void cucul_set_bitmap_palette(cucul_t *, struct cucul_bitmap *,
194                             unsigned int r[], unsigned int g[],
195                             unsigned int b[], unsigned int a[]);
196void cucul_set_bitmap_gamma(cucul_t *, struct cucul_bitmap *, float);
197void cucul_draw_bitmap(cucul_t *, int, int, int, int, struct cucul_bitmap const *, void *);
198void cucul_free_bitmap(cucul_t *, struct cucul_bitmap *);
199/*  @} */
200
201/** \defgroup exporter Exporters to various formats
202 *
203 *  These functions exports current image to various text formats
204 *  Returned buffer will be freed() each you'll call the exporter function.
205 *
206 *  @{ */
207char* cucul_get_html(cucul_t *, int *size);
208char* cucul_get_html3(cucul_t *, int *size);
209char* cucul_get_irc(cucul_t *, int *size);
210char* cucul_get_ansi(cucul_t *, int trailing, int *size);
211/*  @} */
212
213#ifdef __cplusplus
214}
215#endif
216
217#endif /* __CUCUL_H__ */
Note: See TracBrowser for help on using the repository browser.