Main Page | Modules | File List | Globals

caca.h

Go to the documentation of this file.
00001 /*
00002  *  libcaca       ASCII-Art library
00003  *  Copyright (c) 2002, 2003 Sam Hocevar <sam@zoy.org>
00004  *                All Rights Reserved
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019  *  02111-1307  USA
00020  */
00021 
00097 #ifndef __CACA_H__
00098 #define __CACA_H__
00099 
00100 #ifdef __cplusplus
00101 extern "C"
00102 {
00103 #endif
00104 
00109 enum caca_color
00110 {
00111     CACA_COLOR_BLACK = 0, 
00112     CACA_COLOR_BLUE = 1, 
00113     CACA_COLOR_GREEN = 2, 
00114     CACA_COLOR_CYAN = 3, 
00115     CACA_COLOR_RED = 4, 
00116     CACA_COLOR_MAGENTA = 5, 
00117     CACA_COLOR_BROWN = 6, 
00118     CACA_COLOR_LIGHTGRAY = 7, 
00119     CACA_COLOR_DARKGRAY = 8, 
00120     CACA_COLOR_LIGHTBLUE = 9, 
00121     CACA_COLOR_LIGHTGREEN = 10, 
00122     CACA_COLOR_LIGHTCYAN = 11, 
00123     CACA_COLOR_LIGHTRED = 12, 
00124     CACA_COLOR_LIGHTMAGENTA = 13, 
00125     CACA_COLOR_YELLOW = 14, 
00126     CACA_COLOR_WHITE = 15 
00127 };
00128 
00134 enum caca_feature
00135 {
00136     CACA_BACKGROUND       = 0x10, 
00137     CACA_BACKGROUND_BLACK = 0x11, 
00138     CACA_BACKGROUND_SOLID = 0x12, 
00139 #define CACA_BACKGROUND_MIN 0x11 
00140 #define CACA_BACKGROUND_MAX 0x12 
00142     CACA_ANTIALIASING           = 0x20, 
00143     CACA_ANTIALIASING_NONE      = 0x21, 
00144     CACA_ANTIALIASING_PREFILTER = 0x22, 
00145 #define CACA_ANTIALIASING_MIN     0x21 
00146 #define CACA_ANTIALIASING_MAX     0x22 
00148     CACA_DITHERING          = 0x30, 
00149     CACA_DITHERING_NONE     = 0x31, 
00150     CACA_DITHERING_ORDERED2 = 0x32, 
00151     CACA_DITHERING_ORDERED4 = 0x33, 
00152     CACA_DITHERING_ORDERED8 = 0x34, 
00153     CACA_DITHERING_RANDOM   = 0x35, 
00154 #define CACA_DITHERING_MIN    0x31 
00155 #define CACA_DITHERING_MAX    0x35 
00157     CACA_FEATURE_UNKNOWN = 0xffff 
00158 };
00159 
00160 /*
00161  * Backwards compatibility macros
00162  */
00163 #if !defined(_DOXYGEN_SKIP_ME)
00164 #define caca_dithering caca_feature
00165 #define caca_set_dithering caca_set_feature
00166 #define caca_get_dithering_name caca_get_feature_name
00167 #define CACA_DITHER_NONE    CACA_DITHERING_NONE
00168 #define CACA_DITHER_ORDERED CACA_DITHERING_ORDERED8
00169 #define CACA_DITHER_RANDOM  CACA_DITHERING_RANDOM
00170 #endif
00171 
00176 enum caca_event
00177 {
00178     CACA_EVENT_NONE =          0x00000000, 
00179     CACA_EVENT_KEY_PRESS =     0x01000000, 
00180     CACA_EVENT_KEY_RELEASE =   0x02000000, 
00181     CACA_EVENT_MOUSE_PRESS =   0x04000000, 
00182     CACA_EVENT_MOUSE_RELEASE = 0x08000000, 
00183     CACA_EVENT_MOUSE_MOTION =  0x10000000, 
00184     CACA_EVENT_ANY =           0xff000000  
00185 };
00186 
00192 enum caca_key
00193 {
00194     CACA_KEY_UP = 273, 
00195     CACA_KEY_DOWN = 274, 
00196     CACA_KEY_LEFT = 275, 
00197     CACA_KEY_RIGHT = 276, 
00199     CACA_KEY_F1 = 282, 
00200     CACA_KEY_F2 = 283, 
00201     CACA_KEY_F3 = 284, 
00202     CACA_KEY_F4 = 285, 
00203     CACA_KEY_F5 = 286, 
00204     CACA_KEY_F6 = 287, 
00205     CACA_KEY_F7 = 288, 
00206     CACA_KEY_F8 = 289, 
00207     CACA_KEY_F9 = 290, 
00208     CACA_KEY_F10 = 291, 
00209     CACA_KEY_F11 = 292, 
00210     CACA_KEY_F12 = 293, 
00211     CACA_KEY_F13 = 294, 
00212     CACA_KEY_F14 = 295, 
00213     CACA_KEY_F15 = 296 
00214 };
00215 
00222 int caca_init(void);
00223 void caca_set_delay(unsigned int);
00224 enum caca_feature caca_get_feature(enum caca_feature);
00225 void caca_set_feature(enum caca_feature);
00226 char const *caca_get_feature_name(enum caca_feature);
00227 unsigned int caca_get_rendertime(void);
00228 unsigned int caca_get_width(void);
00229 unsigned int caca_get_height(void);
00230 void caca_refresh(void);
00231 void caca_end(void);
00232 /*  @} */
00233 
00240 unsigned int caca_get_event(unsigned int);
00241 unsigned int caca_wait_event(unsigned int);
00242 /*  @} */
00243 
00249 void caca_set_color(enum caca_color, enum caca_color);
00250 enum caca_color caca_get_fg_color(void);
00251 enum caca_color caca_get_bg_color(void);
00252 char const *caca_get_color_name(enum caca_color);
00253 void caca_putchar(int, int, char);
00254 void caca_putstr(int, int, char const *);
00255 void caca_printf(int, int, char const *, ...);
00256 void caca_clear(void);
00257 /*  @} */
00258 
00265 void caca_draw_line(int, int, int, int, char);
00266 void caca_draw_polyline(int const x[], int const y[], int, char);
00267 void caca_draw_thin_line(int, int, int, int);
00268 void caca_draw_thin_polyline(int const x[], int const y[], int);
00269 
00270 void caca_draw_circle(int, int, int, char);
00271 void caca_draw_ellipse(int, int, int, int, char);
00272 void caca_draw_thin_ellipse(int, int, int, int);
00273 void caca_fill_ellipse(int, int, int, int, char);
00274 
00275 void caca_draw_box(int, int, int, int, char);
00276 void caca_draw_thin_box(int, int, int, int);
00277 void caca_fill_box(int, int, int, int, char);
00278 
00279 void caca_draw_triangle(int, int, int, int, int, int, char);
00280 void caca_draw_thin_triangle(int, int, int, int, int, int);
00281 void caca_fill_triangle(int, int, int, int, int, int, char);
00282 /*  @} */
00283 
00289 int caca_rand(int, int);
00290 unsigned int caca_sqrt(unsigned int);
00291 /*  @} */
00292 
00299 struct caca_sprite;
00300 struct caca_sprite * caca_load_sprite(char const *);
00301 int caca_get_sprite_frames(struct caca_sprite const *);
00302 int caca_get_sprite_width(struct caca_sprite const *, int);
00303 int caca_get_sprite_height(struct caca_sprite const *, int);
00304 int caca_get_sprite_dx(struct caca_sprite const *, int);
00305 int caca_get_sprite_dy(struct caca_sprite const *, int);
00306 void caca_draw_sprite(int, int, struct caca_sprite const *, int);
00307 void caca_free_sprite(struct caca_sprite *);
00308 /*  @} */
00309 
00316 struct caca_bitmap;
00317 struct caca_bitmap *caca_create_bitmap(unsigned int, unsigned int,
00318                                        unsigned int, unsigned int,
00319                                        unsigned int, unsigned int,
00320                                        unsigned int, unsigned int);
00321 void caca_set_bitmap_palette(struct caca_bitmap *,
00322                              unsigned int r[], unsigned int g[],
00323                              unsigned int b[], unsigned int a[]);
00324 void caca_draw_bitmap(int, int, int, int, struct caca_bitmap const *, void *);
00325 void caca_free_bitmap(struct caca_bitmap *);
00326 /*  @} */
00327 
00328 #ifdef __cplusplus
00329 }
00330 #endif
00331 
00332 #endif /* __CACA_H__ */