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

Last change on this file since 205 was 205, checked in by Sam Hocevar, 19 years ago
  • src/: + Doxygenated a few things.
  • Property svn:keywords set to Id
File size: 5.7 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 205 2003-11-22 12:45:25Z 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
84/**
85 * The dithering modes to be used with caca_set_dithering().
86 */
87enum caca_dithering
88{
89    CACA_DITHER_NONE,
90    CACA_DITHER_ORDERED,
91    CACA_DITHER_RANDOM
92};
93
94/**
95 * The event types returned by caca_get_event().
96 */
97enum caca_event
98{
99    CACA_EVENT_NONE =        0x00000000,
100    CACA_EVENT_KEY_PRESS =   0x01000000,
101    CACA_EVENT_KEY_RELEASE = 0x02000000,
102    CACA_EVENT_MOUSE_CLICK = 0x04000000
103};
104
105/**
106 * The special key values returned by caca_get_event().
107 */
108enum caca_key
109{
110    CACA_KEY_UP = 273,
111    CACA_KEY_DOWN = 274,
112    CACA_KEY_LEFT = 275,
113    CACA_KEY_RIGHT = 276,
114
115    CACA_KEY_F1 = 282,
116    CACA_KEY_F2 = 283,
117    CACA_KEY_F3 = 284,
118    CACA_KEY_F4 = 285,
119    CACA_KEY_F5 = 286,
120    CACA_KEY_F6 = 287,
121    CACA_KEY_F7 = 288,
122    CACA_KEY_F8 = 289,
123    CACA_KEY_F9 = 290,
124    CACA_KEY_F10 = 291,
125    CACA_KEY_F11 = 292,
126    CACA_KEY_F12 = 293,
127    CACA_KEY_F13 = 294,
128    CACA_KEY_F14 = 295,
129    CACA_KEY_F15 = 296
130};
131
132/*
133 * Basic functions
134 */
135int caca_init(void);
136void caca_set_delay(unsigned int);
137void caca_set_dithering(enum caca_dithering);
138unsigned int caca_get_rendertime(void);
139unsigned int caca_get_width(void);
140unsigned int caca_get_height(void);
141const char *caca_get_color_name(unsigned int);
142void caca_refresh(void);
143void caca_end(void);
144
145/*
146 * Events
147 */
148int caca_get_event(void);
149
150/*
151 * Character graphics
152 */
153void caca_set_color(enum caca_color);
154enum caca_color caca_get_color(void);
155void caca_putchar(int, int, char);
156void caca_putstr(int, int, const char *);
157void caca_printf(int, int, const char *, ...);
158void caca_clear(void);
159
160/*
161 * Graphics primitives
162 */
163void caca_draw_line(int, int, int, int, char);
164void caca_draw_polyline(const int[], const int[], int, char);
165void caca_draw_thin_line(int, int, int, int);
166void caca_draw_thin_polyline(const int[], const int[], int);
167
168void caca_draw_circle(int, int, int, char);
169void caca_draw_ellipse(int, int, int, int, char);
170void caca_draw_thin_ellipse(int, int, int, int);
171void caca_fill_ellipse(int, int, int, int, char);
172
173void caca_draw_box(int, int, int, int, char);
174void caca_draw_thin_box(int, int, int, int);
175void caca_fill_box(int, int, int, int, char);
176
177void caca_draw_triangle(int, int, int, int, int, int, char);
178void caca_draw_thin_triangle(int, int, int, int, int, int);
179void caca_fill_triangle(int, int, int, int, int, int, char);
180
181/*
182 * Maths
183 */
184int caca_rand(int, int);
185unsigned int caca_sqrt(unsigned int);
186
187/*
188 * Sprite handling
189 */
190struct caca_sprite;
191struct caca_sprite * caca_load_sprite(const char *);
192int caca_get_sprite_frames(struct caca_sprite *);
193int caca_get_sprite_width(struct caca_sprite *, int);
194int caca_get_sprite_height(struct caca_sprite *, int);
195int caca_get_sprite_dx(struct caca_sprite *, int);
196int caca_get_sprite_dy(struct caca_sprite *, int);
197void caca_draw_sprite(int, int, struct caca_sprite *, int);
198void caca_free_sprite(struct caca_sprite *);
199
200/*
201 * Bitmap handling
202 */
203struct caca_bitmap;
204struct caca_bitmap *caca_create_bitmap(int, int, int, int, int, int, int);
205void caca_draw_bitmap(int, int, int, int, struct caca_bitmap *, char *);
206void caca_free_bitmap(struct caca_bitmap *);
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif /* __CACA_H__ */
Note: See TracBrowser for help on using the repository browser.