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 247 2003-12-11 16:56:35Z 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 |
---|
57 | extern "C" |
---|
58 | { |
---|
59 | #endif |
---|
60 | |
---|
61 | /** |
---|
62 | * The colour definitions to be used with caca_set_color(). |
---|
63 | */ |
---|
64 | enum 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 | |
---|
84 | const char *caca_get_color_name(enum caca_color); |
---|
85 | |
---|
86 | /** |
---|
87 | * The dithering modes to be used with caca_set_dithering(). |
---|
88 | */ |
---|
89 | enum caca_dithering |
---|
90 | { |
---|
91 | CACA_DITHERING_NONE = 0, |
---|
92 | CACA_DITHERING_ORDERED2 = 1, |
---|
93 | CACA_DITHERING_ORDERED4 = 2, |
---|
94 | CACA_DITHERING_ORDERED8 = 3, |
---|
95 | CACA_DITHERING_RANDOM = 4 |
---|
96 | }; |
---|
97 | |
---|
98 | const char *caca_get_dithering_name(enum caca_dithering); |
---|
99 | |
---|
100 | /* Backwards compatibility */ |
---|
101 | #define CACA_DITHER_NONE CACA_DITHERING_NONE |
---|
102 | #define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8 |
---|
103 | #define CACA_DITHER_RANDOM CACA_DITHERING_RANDOM |
---|
104 | |
---|
105 | /** |
---|
106 | * The event types returned by caca_get_event(). |
---|
107 | */ |
---|
108 | enum caca_event |
---|
109 | { |
---|
110 | CACA_EVENT_NONE = 0x00000000, |
---|
111 | CACA_EVENT_KEY_PRESS = 0x01000000, |
---|
112 | CACA_EVENT_KEY_RELEASE = 0x02000000, |
---|
113 | CACA_EVENT_MOUSE_CLICK = 0x04000000 |
---|
114 | }; |
---|
115 | |
---|
116 | /** |
---|
117 | * The special key values returned by caca_get_event(). |
---|
118 | */ |
---|
119 | enum caca_key |
---|
120 | { |
---|
121 | CACA_KEY_UP = 273, |
---|
122 | CACA_KEY_DOWN = 274, |
---|
123 | CACA_KEY_LEFT = 275, |
---|
124 | CACA_KEY_RIGHT = 276, |
---|
125 | |
---|
126 | CACA_KEY_F1 = 282, |
---|
127 | CACA_KEY_F2 = 283, |
---|
128 | CACA_KEY_F3 = 284, |
---|
129 | CACA_KEY_F4 = 285, |
---|
130 | CACA_KEY_F5 = 286, |
---|
131 | CACA_KEY_F6 = 287, |
---|
132 | CACA_KEY_F7 = 288, |
---|
133 | CACA_KEY_F8 = 289, |
---|
134 | CACA_KEY_F9 = 290, |
---|
135 | CACA_KEY_F10 = 291, |
---|
136 | CACA_KEY_F11 = 292, |
---|
137 | CACA_KEY_F12 = 293, |
---|
138 | CACA_KEY_F13 = 294, |
---|
139 | CACA_KEY_F14 = 295, |
---|
140 | CACA_KEY_F15 = 296 |
---|
141 | }; |
---|
142 | |
---|
143 | /* |
---|
144 | * Basic functions |
---|
145 | */ |
---|
146 | int caca_init(void); |
---|
147 | void caca_set_delay(unsigned int); |
---|
148 | void caca_set_dithering(enum caca_dithering); |
---|
149 | unsigned int caca_get_rendertime(void); |
---|
150 | unsigned int caca_get_width(void); |
---|
151 | unsigned int caca_get_height(void); |
---|
152 | void caca_refresh(void); |
---|
153 | void caca_end(void); |
---|
154 | |
---|
155 | /* |
---|
156 | * Events |
---|
157 | */ |
---|
158 | unsigned int caca_get_event(void); |
---|
159 | |
---|
160 | /* |
---|
161 | * Character graphics |
---|
162 | */ |
---|
163 | void caca_set_color(enum caca_color, enum caca_color); |
---|
164 | enum caca_color caca_get_fg_color(void); |
---|
165 | enum caca_color caca_get_bg_color(void); |
---|
166 | void caca_putchar(int, int, char); |
---|
167 | void caca_putstr(int, int, const char *); |
---|
168 | void caca_printf(int, int, const char *, ...); |
---|
169 | void caca_clear(void); |
---|
170 | |
---|
171 | /* |
---|
172 | * Graphics primitives |
---|
173 | */ |
---|
174 | void caca_draw_line(int, int, int, int, char); |
---|
175 | void caca_draw_polyline(const int[], const int[], int, char); |
---|
176 | void caca_draw_thin_line(int, int, int, int); |
---|
177 | void caca_draw_thin_polyline(const int[], const int[], int); |
---|
178 | |
---|
179 | void caca_draw_circle(int, int, int, char); |
---|
180 | void caca_draw_ellipse(int, int, int, int, char); |
---|
181 | void caca_draw_thin_ellipse(int, int, int, int); |
---|
182 | void caca_fill_ellipse(int, int, int, int, char); |
---|
183 | |
---|
184 | void caca_draw_box(int, int, int, int, char); |
---|
185 | void caca_draw_thin_box(int, int, int, int); |
---|
186 | void caca_fill_box(int, int, int, int, char); |
---|
187 | |
---|
188 | void caca_draw_triangle(int, int, int, int, int, int, char); |
---|
189 | void caca_draw_thin_triangle(int, int, int, int, int, int); |
---|
190 | void caca_fill_triangle(int, int, int, int, int, int, char); |
---|
191 | |
---|
192 | /* |
---|
193 | * Maths |
---|
194 | */ |
---|
195 | int caca_rand(int, int); |
---|
196 | unsigned int caca_sqrt(unsigned int); |
---|
197 | |
---|
198 | /* |
---|
199 | * Sprite handling |
---|
200 | */ |
---|
201 | struct caca_sprite; |
---|
202 | struct caca_sprite * caca_load_sprite(const char *); |
---|
203 | int caca_get_sprite_frames(const struct caca_sprite *); |
---|
204 | int caca_get_sprite_width(const struct caca_sprite *, int); |
---|
205 | int caca_get_sprite_height(const struct caca_sprite *, int); |
---|
206 | int caca_get_sprite_dx(const struct caca_sprite *, int); |
---|
207 | int caca_get_sprite_dy(const struct caca_sprite *, int); |
---|
208 | void caca_draw_sprite(int, int, const struct caca_sprite *, int); |
---|
209 | void caca_free_sprite(struct caca_sprite *); |
---|
210 | |
---|
211 | /* |
---|
212 | * Bitmap handling |
---|
213 | */ |
---|
214 | struct caca_bitmap; |
---|
215 | struct caca_bitmap *caca_create_bitmap(unsigned int, unsigned int, |
---|
216 | unsigned int, unsigned int, |
---|
217 | unsigned int, unsigned int, |
---|
218 | unsigned int, unsigned int); |
---|
219 | void caca_set_bitmap_palette(struct caca_bitmap *, unsigned int[], |
---|
220 | unsigned int[], unsigned int[], unsigned int[]); |
---|
221 | void caca_draw_bitmap(int, int, int, int, const struct caca_bitmap *, void *); |
---|
222 | void caca_free_bitmap(struct caca_bitmap *); |
---|
223 | |
---|
224 | #ifdef __cplusplus |
---|
225 | } |
---|
226 | #endif |
---|
227 | |
---|
228 | #endif /* __CACA_H__ */ |
---|