source: libcaca/trunk/src/caca.h @ 249

Last change on this file since 249 was 249, checked in by Sam Hocevar, 19 years ago
  • src/bitmap.c: + Added antialiasing support. + Dithering, antialiasing and background mode can now be selected at

runtime.

  • src/caca.c src/caca.h: + Renamed caca_dithering into caca_feature and extended the type to

express background colour and antialiasing mode.

  • examples/demo.c: + Fixed a bug that disabled the sprite demo. + Draw solid flares.
  • examples/view.c: + Select antialiasing and background mode at runtime.
  • Property svn:keywords set to Id
File size: 7.2 KB
Line 
1/*
2 *   libcaca       ASCII-Art library
3 *   Copyright (c) 2002, 2003 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 GNU Lesser General Public
8 *   License as published by the Free Software Foundation; either
9 *   version 2 of the License, or (at your option) any later version.
10 *
11 *   This library is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *   Lesser General Public License for more details.
15 *
16 *   You should have received a copy of the GNU Lesser General Public
17 *   License along with this library; if not, write to the Free Software
18 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 *   02111-1307  USA
20 */
21
22/**  \file caca.h
23 *   \version \$Id: caca.h 249 2003-12-12 14:49:41Z sam $
24 *   \author Sam Hocevar <sam@zoy.org>
25 *   \brief The \e libcaca public header.
26 *
27 *   This header contains the public types and functions that applications
28 *   using \e libcaca may use.
29 */
30
31/**  \mainpage libcaca developer documentation
32 *
33 *   \section intro Introduction
34 *
35 *   \e libcaca is a graphics library that outputs text instead of pixels,
36 *   so that it can work on older video cards or text terminals. It is not
37 *   unlike the famous AAlib library. libcaca needs a terminal to work,
38 *   thus it should work on all Unix systems (including Mac OS X) using
39 *   either the slang library or the ncurses library, on DOS using the conio
40 *   library, and on Windows systems using either slang or ncurses (through
41 *   Cygwin emulation) or conio.
42 *
43 *   \e libcaca is free software, released under the GNU Lesser General
44 *   Public License. This ensures that \e libcaca will always remain free
45 *   software.
46 *
47 *   \section api The libcaca API
48 *
49 *   The complete \e libcaca programming interface is available from the
50 *   caca.h file.
51 */
52
53#ifndef __CACA_H__
54#define __CACA_H__
55
56#ifdef __cplusplus
57extern "C"
58{
59#endif
60
61/**
62 * The colour definitions to be used with caca_set_color().
63 */
64enum caca_color
65{
66    CACA_COLOR_BLACK = 0,
67    CACA_COLOR_BLUE = 1,
68    CACA_COLOR_GREEN = 2,
69    CACA_COLOR_CYAN = 3,
70    CACA_COLOR_RED = 4,
71    CACA_COLOR_MAGENTA = 5,
72    CACA_COLOR_BROWN = 6,
73    CACA_COLOR_LIGHTGRAY = 7,
74    CACA_COLOR_DARKGRAY = 8,
75    CACA_COLOR_LIGHTBLUE = 9,
76    CACA_COLOR_LIGHTGREEN = 10,
77    CACA_COLOR_LIGHTCYAN = 11,
78    CACA_COLOR_LIGHTRED = 12,
79    CACA_COLOR_LIGHTMAGENTA = 13,
80    CACA_COLOR_YELLOW = 14,
81    CACA_COLOR_WHITE = 15
82};
83
84const char *caca_get_color_name(enum caca_color);
85
86/**
87 * The internal libcaca features.
88 */
89enum caca_feature
90{
91    /* Properties of background characters */
92    CACA_BACKGROUND       = 0x10,
93    CACA_BACKGROUND_BLACK = 0x11,
94    CACA_BACKGROUND_SOLID = 0x12,
95#define CACA_BACKGROUND_MIN 0x11
96#define CACA_BACKGROUND_MAX 0x12
97
98    /* Antialiasing features */
99    CACA_ANTIALIASING           = 0x20,
100    CACA_ANTIALIASING_NONE      = 0x21,
101    CACA_ANTIALIASING_PREFILTER = 0x22,
102#define CACA_ANTIALIASING_MIN     0x21
103#define CACA_ANTIALIASING_MAX     0x22
104
105    /* Dithering methods */
106    CACA_DITHERING          = 0x30,
107    CACA_DITHERING_NONE     = 0x31,
108    CACA_DITHERING_ORDERED2 = 0x32,
109    CACA_DITHERING_ORDERED4 = 0x33,
110    CACA_DITHERING_ORDERED8 = 0x34,
111    CACA_DITHERING_RANDOM   = 0x35,
112#define CACA_DITHERING_MIN    0x31
113#define CACA_DITHERING_MAX    0x35
114
115    /* Unknown feature */
116    CACA_UNKNOWN_FEATURE = 0xffff
117};
118
119const char *caca_get_feature_name(enum caca_feature);
120
121/* Backwards compatibility */
122#define caca_dithering caca_feature
123#define caca_set_dithering caca_set_feature
124#define caca_get_dithering_name caca_get_feature_name
125#define CACA_DITHER_NONE    CACA_DITHERING_NONE
126#define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
127#define CACA_DITHER_RANDOM  CACA_DITHERING_RANDOM
128
129/**
130 * The event types returned by caca_get_event().
131 */
132enum caca_event
133{
134    CACA_EVENT_NONE =        0x00000000,
135    CACA_EVENT_KEY_PRESS =   0x01000000,
136    CACA_EVENT_KEY_RELEASE = 0x02000000,
137    CACA_EVENT_MOUSE_CLICK = 0x04000000
138};
139
140/**
141 * The special key values returned by caca_get_event().
142 */
143enum caca_key
144{
145    CACA_KEY_UP = 273,
146    CACA_KEY_DOWN = 274,
147    CACA_KEY_LEFT = 275,
148    CACA_KEY_RIGHT = 276,
149
150    CACA_KEY_F1 = 282,
151    CACA_KEY_F2 = 283,
152    CACA_KEY_F3 = 284,
153    CACA_KEY_F4 = 285,
154    CACA_KEY_F5 = 286,
155    CACA_KEY_F6 = 287,
156    CACA_KEY_F7 = 288,
157    CACA_KEY_F8 = 289,
158    CACA_KEY_F9 = 290,
159    CACA_KEY_F10 = 291,
160    CACA_KEY_F11 = 292,
161    CACA_KEY_F12 = 293,
162    CACA_KEY_F13 = 294,
163    CACA_KEY_F14 = 295,
164    CACA_KEY_F15 = 296
165};
166
167/*
168 * Basic functions
169 */
170int caca_init(void);
171void caca_set_delay(unsigned int);
172enum caca_feature caca_get_feature(enum caca_feature);
173void caca_set_feature(enum caca_feature);
174unsigned int caca_get_rendertime(void);
175unsigned int caca_get_width(void);
176unsigned int caca_get_height(void);
177void caca_refresh(void);
178void caca_end(void);
179
180/*
181 * Events
182 */
183unsigned int caca_get_event(void);
184
185/*
186 * Character graphics
187 */
188void caca_set_color(enum caca_color, enum caca_color);
189enum caca_color caca_get_fg_color(void);
190enum caca_color caca_get_bg_color(void);
191void caca_putchar(int, int, char);
192void caca_putstr(int, int, const char *);
193void caca_printf(int, int, const char *, ...);
194void caca_clear(void);
195
196/*
197 * Graphics primitives
198 */
199void caca_draw_line(int, int, int, int, char);
200void caca_draw_polyline(const int[], const int[], int, char);
201void caca_draw_thin_line(int, int, int, int);
202void caca_draw_thin_polyline(const int[], const int[], int);
203
204void caca_draw_circle(int, int, int, char);
205void caca_draw_ellipse(int, int, int, int, char);
206void caca_draw_thin_ellipse(int, int, int, int);
207void caca_fill_ellipse(int, int, int, int, char);
208
209void caca_draw_box(int, int, int, int, char);
210void caca_draw_thin_box(int, int, int, int);
211void caca_fill_box(int, int, int, int, char);
212
213void caca_draw_triangle(int, int, int, int, int, int, char);
214void caca_draw_thin_triangle(int, int, int, int, int, int);
215void caca_fill_triangle(int, int, int, int, int, int, char);
216
217/*
218 * Maths
219 */
220int caca_rand(int, int);
221unsigned int caca_sqrt(unsigned int);
222
223/*
224 * Sprite handling
225 */
226struct caca_sprite;
227struct caca_sprite * caca_load_sprite(const char *);
228int caca_get_sprite_frames(const struct caca_sprite *);
229int caca_get_sprite_width(const struct caca_sprite *, int);
230int caca_get_sprite_height(const struct caca_sprite *, int);
231int caca_get_sprite_dx(const struct caca_sprite *, int);
232int caca_get_sprite_dy(const struct caca_sprite *, int);
233void caca_draw_sprite(int, int, const struct caca_sprite *, int);
234void caca_free_sprite(struct caca_sprite *);
235
236/*
237 * Bitmap handling
238 */
239struct caca_bitmap;
240struct caca_bitmap *caca_create_bitmap(unsigned int, unsigned int,
241                                       unsigned int, unsigned int,
242                                       unsigned int, unsigned int,
243                                       unsigned int, unsigned int);
244void caca_set_bitmap_palette(struct caca_bitmap *, unsigned int[],
245                             unsigned int[], unsigned int[], unsigned int[]);
246void caca_draw_bitmap(int, int, int, int, const struct caca_bitmap *, void *);
247void caca_free_bitmap(struct caca_bitmap *);
248
249#ifdef __cplusplus
250}
251#endif
252
253#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.