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

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